/* ==============================================================================
   EZI's HRM - TÙY BIẾN GIAO DIỆN & TỐI ƯU MOBILE / PWA
   ============================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    --primary: #059669;
    --primary-dark: #047857;
    --primary-light: #d1fae5;
    --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

body {
    font-family: var(--font-sans);
    -webkit-tap-highlight-color: transparent;
    padding-bottom: env(safe-area-inset-bottom);
}

/* Tối ưu màn hình điện thoại (Android & iOS) */
.safe-top {
    padding-top: env(safe-area-inset-top, 0px);
}

.safe-bottom {
    padding-bottom: max(8px, env(safe-area-inset-bottom, 8px));
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Khung Camera Viewport */
.camera-container {
    position: relative;
    width: 100%;
    max-width: 380px;
    aspect-ratio: 1 / 1;
    border-radius: 24px;
    overflow: hidden;
    background: #0f172a;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
}

.camera-container video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    -webkit-transform: scaleX(-1);
    transform: scaleX(-1); /* Hiệu ứng gương */
    -webkit-transform-origin: center center;
    transform-origin: center center;
}

/* Khung viền ngắm khuôn mặt */
.face-guide {
    position: absolute;
    inset: 20px;
    border: 2px dashed rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    pointer-events: none;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.3);
}

/* Hiệu ứng quét laser */
.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, #10b981, transparent);
    animation: scanAnimation 2.5s ease-in-out infinite alternate;
}

@keyframes scanAnimation {
    0% { top: 15%; opacity: 0.3; }
    50% { opacity: 1; }
    100% { top: 85%; opacity: 0.3; }
}

/* Badge nhấp nháy cho Cảnh báo quan trọng */
.pulse-badge {
    animation: pulseGlow 1.8s infinite;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.75; transform: scale(1.08); }
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Glassmorphism */
.glass-panel {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Schedule Matrix Table Styling (Chuẩn Calendar Google Sheet) */
.schedule-table-container {
    overflow-x: auto;
    max-width: 100%;
    border-radius: 1rem;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}
.schedule-table {
    border-collapse: separate;
    border-spacing: 0;
    min-width: 1400px;
    width: 100%;
    font-size: 11px;
}
.schedule-table th, .schedule-table td {
    border: 1px solid #e2e8f0;
    text-align: center;
    padding: 5px 3px;
    vertical-align: middle;
}
.schedule-sticky-col {
    position: sticky;
    left: 0;
    background: #f8fafc;
    z-index: 20;
    font-weight: 800;
    min-width: 130px;
    max-width: 140px;
    border-right: 2px solid #cbd5e1 !important;
    text-align: left !important;
    padding-left: 10px !important;
    color: #1e293b;
    box-shadow: 2px 0 5px -2px rgba(0,0,0,0.06);
}
.schedule-day-header {
    background: #ea580c; /* Cam đậm thương hiệu nổi bật */
    color: #ffffff;
    font-weight: 800;
    font-size: 12px;
    letter-spacing: 0.02em;
}
.schedule-shift-header {
    background: #f59e0b; /* Vàng cam rực rỡ S1..T2 như ảnh user gửi */
    color: #1c1917;
    font-weight: 900;
    font-size: 11px;
}
.schedule-cell {
    min-width: 66px;
    height: 44px;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    background: #fff;
    padding: 2px 3px;
}
.schedule-cell:hover {
    background: #ecfdf5;
    outline: 2px solid #10b981;
    z-index: 10;
}
.shift-leader-badge {
    color: #064e3b !important; /* Xanh lá đậm */
    font-weight: 900 !important;
    background-color: #d1fae5;
    border: 1px solid #10b981;
    border-radius: 4px;
    padding: 2px 4px;
    display: inline-block;
    box-shadow: 0 1px 2px rgba(6, 78, 59, 0.12);
}
.schedule-cell-red {
    background-color: #dc2626 !important;
    color: #ffffff !important;
    font-weight: 800;
}
.schedule-cell-copied {
    outline: 2px dashed #10b981 !important;
    outline-offset: -2px;
    background-color: #ecfdf5 !important;
    animation: pulseCopiedCell 1.8s infinite ease-in-out;
}
@keyframes pulseCopiedCell {
    0%, 100% { outline-color: #10b981; }
    50% { outline-color: #34d399; }
}
.schedule-cell-active {
    outline: 2px solid #059669 !important;
    outline-offset: -2px;
    box-shadow: inset 0 0 0 1px #ffffff, 0 0 8px rgba(16, 185, 129, 0.35) !important;
    z-index: 15;
}
.schedule-cell-copied.schedule-cell-active {
    outline: 2px dashed #059669 !important;
    box-shadow: inset 0 0 0 1px #ffffff, 0 0 8px rgba(16, 185, 129, 0.45) !important;
}
.schedule-quick-copy-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    display: none;
    align-items: center;
    justify-content: center;
    width: 19px;
    height: 19px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    color: #475569;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.15s ease;
    cursor: pointer;
    z-index: 12;
}
.schedule-cell:hover .schedule-quick-copy-btn {
    display: flex;
}
.schedule-cell.schedule-cell-active .schedule-quick-copy-btn {
    display: flex !important;
}
.schedule-quick-copy-btn:hover {
    background: #10b981;
    color: #ffffff;
    border-color: #10b981;
    transform: scale(1.1);
}
.schedule-quick-copy-btn:active {
    transform: scale(0.95);
}

/* Drag and Drop Schedule Cells (Kéo thả nhân viên trực tiếp giữa các ô ca) */
.schedule-cell-drag-over {
    background-color: #dcfce7 !important;
    outline: 2px dashed #059669 !important;
    outline-offset: -2px;
    box-shadow: inset 0 0 10px rgba(16, 185, 129, 0.3) !important;
    z-index: 25;
}
body.schedule-dragging-active .schedule-cell * {
    pointer-events: none !important;
}
.schedule-staff-tag-draggable {
    display: inline-flex;
    align-items: center;
    cursor: grab !important;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: element !important;
    touch-action: pan-y;
}
.schedule-staff-tag-draggable * {
    pointer-events: none;
}
.schedule-staff-tag-draggable:active {
    cursor: grabbing !important;
}
.schedule-staff-tag-dragging {
    opacity: 0.35;
    transform: scale(0.92);
}
#touchDragGhost {
    position: fixed;
    pointer-events: none;
    z-index: 99999;
    padding: 5px 12px;
    border-radius: 10px;
    background: #064e3b;
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.35);
    white-space: nowrap;
    transform: translate(-50%, -125%);
    transition: opacity 0.15s ease;
}

/* ==============================================================================
   ẨN HOÀN TOÀN WIDGET NETLIFY DRAWER ("POWERED BY NETLIFY") TRÊN MOBILE & DESKTOP
   ============================================================================== */
#netlify-drawer,
netlify-drawer,
[data-netlify-drawer],
[id*="netlify-drawer"],
[class*="netlify-drawer"],
iframe[title*="Netlify"],
iframe[src*="netlify.com"],
div:has(> iframe[src*="netlify.com"]),
.netlify-badge {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    height: 0 !important;
    width: 0 !important;
    max-height: 0 !important;
    max-width: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    top: -9999px !important;
    left: -9999px !important;
    z-index: -99999 !important;
}

/* ==============================================================================
   QUY TẮC CHUẨN TOÀN HỆ THỐNG (MÁY TÍNH & ĐIỆN THOẠI):
   MỌI MODAL LUÔN CANH TỪ LỀ TRÊN XUỐNG (FLEX-START), KHÔNG BAO GIỜ CANH GIỮA
   LÀM MẤT PHẦN ĐẦU KHI NỘI DUNG DÀI
   ============================================================================== */
div[id^="modal"] {
    align-items: flex-start !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    padding-top: max(16px, env(safe-area-inset-top, 16px)) !important;
    padding-bottom: max(32px, env(safe-area-inset-bottom, 32px)) !important;
}

div[id^="modal"] > div {
    margin-top: 0 !important;
    margin-bottom: 24px !important;
}

/* ==============================================================================
   TỐI ƯU GIAO DIỆN ĐIỆN THOẠI (ANDROID & IOS) - DƯỚI 768PX
   ============================================================================== */
@media (max-width: 767px) {
    html, body {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }

    /* Khung camera gọn gàng trên màn hình điện thoại Android để không đẩy phần đầu trang */
    .camera-container {
        max-width: 240px;
        max-height: 240px;
        border-radius: 20px;
        margin: 0 auto;
    }

    div[id^="modal"] {
        padding-top: max(12px, env(safe-area-inset-top, 12px)) !important;
        padding-bottom: max(24px, env(safe-area-inset-bottom, 24px)) !important;
    }

    div[id^="modal"] > div {
        margin-top: 0 !important;
        margin-bottom: 20px !important;
        width: 100% !important;
    }

    /* Ghim thanh tiêu đề của các Modal dài khi cuộn trên điện thoại */
    div[id^="modal"] > div > div:first-child {
        scroll-margin-top: 12px;
    }

    /* Cột cố định bảng lịch tuần gọn hơn trên màn hình điện thoại */
    .schedule-sticky-col {
        min-width: 105px;
        max-width: 115px;
        padding-left: 6px !important;
        font-size: 10px;
    }
}
