/* Full ngày (+) */
.cell-full {
  background-color: var(--color-full) !important;
  font-weight: 600;
  color: black;
}
.cell-duty-checkin {
  background-color: var(--color-duty-checkin) !important;
  color: black;
}
.cell-has-checkin {
  background-color: var(--color-has-checkin) !important;
  color: black;
}
/* 1/2 ngày (1/2) */
.cell-half {
  background-color: var(--color-half) !important;
  color: black;
}

/* Nhóm nghỉ có lương/chế độ (F, Nb, L) */
.cell-leave {
  background-color: var(--color-leave) !important;
  color: black;
}

/* Nhóm nghỉ có BHXH (Ô, Cô, Ts) */
.cell-absence {
  background-color: var(--color-absence) !important;
  color: black;
}

/* Nhóm công tác, học tập (CT, Hq, Lđ) */
.cell-collaborate {
  background-color: var(--color-collaborate) !important;
  color: black;
}

/* Nghỉ không lương, ngừng việc (No, N) */
.cell-unpaid {
  background-color: var(--color-unpaid) !important;
  color: black;
}

.cell-absent {
  background-color: var(--color-absent) !important;
  color: black;
}

.cell-shift {
  background-color: var(--color-shift) !important;
  color: black;
}

.cell-late-early {
  background-color: var(--color-late-early) !important;
  color: black;
}

.cell-forget-checkin {
    background-color: var(--color-forget-checkin) !important;
    color: black;
}

.attendance-container {
    overflow: auto;    /* Cho phép cuộn cả ngang và dọc */
}

.attendance-table {
    border-separate: separate; /* Quan trọng để sticky hoạt động */
    border-spacing: 0;
}

.col-reason {
    width: 300px;
    min-width: 300px;
    white-space: normal !important;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.col-type {
    width: 250px;
    min-width: 250px;
    white-space: normal !important;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Định nghĩa chung cho các cột cố định */
.sticky-col {
    position: sticky;
    z-index: 10;
    background-color: white !important; /* Phải có nền để không bị lộ chữ bên dưới khi cuộn */
    box-shadow: inset 1px 0 0 #dee2e6, inset -1px 0 0 #dee2e6; /* Giữ đường kẻ border */
}

/* Cố định checkbox (Cột 1) */
.col-checkbox {
    left: 0;
    width: 50px;
    min-width: 50px;
    vertical-align: middle;
}
.col-stt-checkbox {
    left: 50px;
    width: 50px;
    min-width: 50px;
    vertical-align: middle;
}
.col-status-checkbox {
    left: 100px;
    min-width: 100px;
    vertical-align: middle;
}
.col-name-checkbox {
    left: 200px;
    min-width: 200px;
    vertical-align: middle;
}

/* Cố định STT (Cột 1) */
.col-stt {
    left: 0;
    width: 50px;
    min-width: 50px;
    vertical-align: middle;
}

/* Cố định Status (Cột 1) */
.col-status {
    left: 50px;
    min-width: 100px;
    vertical-align: middle;
}

/* Cố định Nhân viên (Cột 2) */
.col-name-status {
    left: 150px; /* Bằng chiều rộng của cột STT */
    min-width: 200px;
    vertical-align: middle;
}

.col-name {
    left: 50px; /* Bằng chiều rộng của cột STT */
    min-width: 200px;
    vertical-align: middle;
}

.col-title {
    left: 250px; /* Bằng chiều rộng của cột STT */
    min-width: 120px;
    word-wrap: break-word;
    white-space: normal;
    vertical-align: middle;
}

.col-date {
    left: 0;
    width: 50px;
    min-width: 50px;
    vertical-align: middle;
}

/* Cố định Tổng công (Cột cuối cùng) */
.col-total {
    right: 0;
    width: 100px;
    min-width: 100px;
    border-left: 2px solid #dee2e6 !important; /* Kẻ vạch rõ rệt ngăn cách với khu vực ngày */
    position: static;
    font-size: 0.5rem !important;
    vertical-align: middle;
}

.col-total-value {
    right: 0;
    width: 100px;
    min-width: 100px;
    border-left: 2px solid #dee2e6 !important; /* Kẻ vạch rõ rệt ngăn cách với khu vực ngày */
    position: static;
    vertical-align: middle;
}

/* Đảm bảo Header luôn nằm trên cùng khi cuộn dọc */
thead th {
    position: sticky;
    top: 0;
    z-index: 20;
}

/* Ưu tiên z-index cho các ô vừa sticky top vừa sticky left/right */
thead th.sticky-col {
    z-index: 30;
}

.total_title {
    word-wrap: break-word;
    white-space: normal;
}

.attendance-table thead tr th {
    background-color: #ffffff !important;
    color: #0d6efd;
    box-shadow: inset 0 -1px 0 0 #212529;
}

.day-cell {
    width: 100px !important;     /* Độ rộng mong muốn */
    min-width: 100px !important; /* Không cho phép nhỏ hơn */
    max-width: 100px !important; /* Không cho phép lớn hơn */
    padding: 0 !important;
    text-align: center;
    vertical-align: middle;
}

.time-row {
    white-space: nowrap;
    font-size: 0.8rem;
    display: flex;          /* Kích hoạt flexbox */
    justify-content: space-around; /* Căn giữa theo chiều ngang */
    align-items: center;     /* Căn giữa theo chiều dọc */
    min-height: 50px;        /* Đảm bảo div có chiều cao để thấy rõ việc căn giữa */
    text-align: center;      /* Dự phòng cho các trình duyệt cũ */
}

.attendance-row {
    height: 70px;
}

.legend-box {
    width: 35px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.legend-text {
    font-size: 13px;
    color: #555;
}

.avatar-timesheet {
    width: 2rem;
    height: 2rem;
    margin-right: 5px;
}

.attendance-summary-row .sticky-col {
    position: sticky;
    left: 0;
    z-index: 2;
    border-right: 1px solid #dee2e6;
}

.info-summary-row .sticky-col {
    position: sticky;
    left: 0;
    z-index: 2;
    border-right: 1px solid #dee2e6;
}

.legend-item-wrapper {
    transition: all 0.2s ease;
}

.calendar-day {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 5px;
    position: relative;
    display: flex;
    justify-content: space-between;
}

.calendar-day span {
    font-size: 13px;
    color: #94a3b8;
    font-weight: 500;
}

.calendar-day-session {
    min-height: 46px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 5px;
    position: relative;
    display: flex;
    justify-content: space-between;
}

@media (max-width: 575.98px) {
    /* Ép khoảng cách lưới siêu nhỏ để không bị tràn màn hình */
    .responsive-calendar .g-1, 
    .responsive-calendar .row-cols-7 > .col {
        padding-left: 1px !important;
        padding-right: 1px !important;
    }
    
    .calendar-header-row {
        font-size: 9px !important;
    }

    /* Định vị lại số ngày dạng nhãn nhỏ đè góc trên bên trái */
    .day-label-mini {
        /* position: absolute;
        top: 2px;
        left: 4px; */
        font-size: 8px;
        font-weight: bold;
        /* color: #495057; */
        /* z-index: 3; */
    }

    /* Khung ô vuông lịch thu nhỏ chiều cao */
    .calendar-day {
        min-height: 55px !important;
        border-radius: 3px !important;
        padding: 0px !important;
    }

    .calendar-day-session {
        min-height: 28px !important;
        border-radius: 3px !important;
        padding: 0px !important;
    }

    .calendar-day-nonboder {
        min-height: 55px !important;
        position: relative;
        display: flex;
        justify-content: space-between;
    }

    /* Thu nhỏ cỡ chữ giờ giấc về dạng font Monospace không chân để không bị vỡ dòng */
    .detail-time-mini {
        font-size: 7.5px !important;
        font-family: 'Courier New', Courier, monospace;
        line-height: 1.1 !important;
        transform: scale(0.95); /* Scale nhỏ thêm bằng cứng phần cứng đồ họa */
        height: 100% !important;
        max-height: 100% !important;
    }

    .time-row-mini {
        padding: 1px 0 !important;
        white-space: nowrap !important; /* Tuyệt đối không cho phép xuống dòng làm méo ô */
    }

    /* Thu nhỏ text trạng thái chữ to (Nghỉ phép / Lễ) */
    .text-status-mini {
        font-size: 8px !important;
        line-height: 1.1 !important;
        display: -webkit-box;
        -line-clamp: 2; /* Giới hạn tối đa 2 dòng văn bản */
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .summary-box .value {
        font-size: 18px;
        font-weight: 600;
        color: #334155;
        margin-bottom: 5px;
    }
    .summary-box .title {
        font-size: 10px;
        color: #64748b;
        line-height: 1.4;
    }
}

/* --- Cấu hình cho Màn hình máy tính/tablet lớn hơn --- */
@media (min-width: 576px) {
    .day-label-mini {
        font-size: 11px;
        font-weight: bold;
        margin-bottom: 2px;
        text-align: left;
    }
    .calendar-day {
        min-height: 100px;
    }

    .calendar-day-session {
        min-height: 46px !important;
        border-radius: 5px !important;
        padding: 5px !important;
    }

    .calendar-day-nonboder {
        min-height: 100px;
        position: relative;
        display: flex;
        justify-content: space-between;
    }

    .detail-time-mini {
        font-size: 10px;
        width: 100%;
    }
    .time-row-mini {
        padding: 2px 0;
        font-size: 0.8rem;
    }
    .text-status-mini {
        font-size: 11px;
    }

    .summary-box .value {
        font-size: 24px;
        font-weight: 600;
        color: #334155;
        margin-bottom: 5px;
    }
    .summary-box .title {
        font-size: 12px;
        color: #64748b;
        line-height: 1.4;
    }
}