/* ============================================================
   Work From Home System — Custom Styles
   Font: Sarabun (Thai/English)
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Sarabun', sans-serif;
    background: #f0f2f5;
    color: #333;
    font-size: 15px;
}

/* ===  Navbar  ============================================= */
.wfh-navbar {
    background: linear-gradient(135deg, #4a1a8c 0%, #6d28d9 50%, #7c3aed 100%);
    box-shadow: 0 2px 12px rgba(109, 40, 217, 0.35);
    padding: 0.5rem 0;
}
.wfh-navbar .nav-link { font-weight: 500; }
.wfh-navbar .nav-link.active {
    background: rgba(255,255,255,0.15);
    border-radius: 6px;
}
/* ลงเวลา nav button — highlighted */
.wfh-navbar .nav-checkin {
    background: rgba(255,255,255,0.18);
    border-radius: 8px;
    padding: 0.3rem 0.85rem !important;
    border: 1px solid rgba(255,255,255,0.35);
    margin: 0 4px;
    transition: background 0.18s;
}
.wfh-navbar .nav-checkin:hover,
.wfh-navbar .nav-checkin.active {
    background: rgba(255,255,255,0.3);
}

/* ===  Footer  ============================================= */
.wfh-footer {
    background: #fff;
    border-top: 1px solid #e2e8f0;
    margin-top: 3rem;
}

/* ===  Page Layout  ======================================== */
.page-content { padding: 0 12px; }
.page-header {
    background: linear-gradient(135deg, #4a1a8c, #7c3aed);
    color: #fff;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    margin-top: 1rem;
    box-shadow: 0 4px 16px rgba(109,40,217,0.2);
}
.page-header h4 { margin: 0; font-weight: 700; }
.page-header .subtitle { opacity: 0.85; font-size: 0.92rem; }

/* ===  Cards  ============================================== */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
    padding: 1rem 1.25rem;
}

/* ===  Stat Cards  ========================================= */
.stat-card {
    border-radius: 12px;
    padding: 1.25rem 1rem;
    text-align: center;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}
.stat-card .stat-icon { font-size: 2.2rem; opacity: 0.8; }
.stat-card .stat-number { font-size: 2rem; font-weight: 700; }
.stat-card .stat-label { font-size: 0.88rem; opacity: 0.9; }
.stat-wfh     { background: linear-gradient(135deg, #7c3aed, #a855f7); }
.stat-office  { background: linear-gradient(135deg, #059669, #10b981); }
.stat-checkin { background: linear-gradient(135deg, #0284c7, #38bdf8); }
.stat-total   { background: linear-gradient(135deg, #d97706, #fbbf24); }

/* ===  Work Type Badges  ==================================== */
.badge-wfh {
    background-color: #7c3aed;
    color: #fff;
}
.badge-office {
    background-color: #059669;
    color: #fff;
}
.badge-leave {
    background-color: #d97706;
    color: #fff;
}
.badge-holiday {
    background-color: #64748b;
    color: #fff;
}
.badge-leave-sick {
    background-color: #dc2626;
    color: #fff;
}
.badge-leave-personal {
    background-color: #ea580c;
    color: #fff;
}
.badge-leave-vacation {
    background-color: #0891b2;
    color: #fff;
}
.badge-official-trip {
    background-color: #1d4ed8;
    color: #fff;
}

/* ===  Calendar Table  ====================================== */
.calendar-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.07);
    background: #fff;
}
.calendar-table {
    min-width: 780px;
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 0;
}
.calendar-table th, .calendar-table td {
    border: 1px solid #e2e8f0;
    padding: 0;
    vertical-align: middle;
    text-align: center;
}
/* Fixed / Sticky columns */
.calendar-table th.col-no,
.calendar-table td.col-no {
    width: 46px;
    min-width: 46px;
    font-weight: 700;
    position: sticky;
    left: 0;
    z-index: 2;
    background: inherit;
}
.calendar-table th.col-name {
    min-width: 175px;
    text-align: left;
    padding-left: 12px;
    position: sticky;
    left: 46px;
    z-index: 2;
    background: inherit;
    box-shadow: 3px 0 6px -2px rgba(0,0,0,0.12);
}
.calendar-table td.col-name {
    min-width: 175px;
    text-align: left;
    padding: 8px 10px;
    position: sticky;
    left: 46px;
    z-index: 1;
    background: inherit;
    box-shadow: 3px 0 6px -2px rgba(0,0,0,0.08);
}
/* Ensure thead sticky cells sit above tbody sticky cells */
.calendar-table thead th.col-no,
.calendar-table thead th.col-name {
    z-index: 3;
}
/* Date columns */
.calendar-table th.col-date {
    min-width: 80px;
    padding: 6px 4px;
    font-size: 0.82rem;
}
.calendar-table td.col-cell {
    min-width: 80px;
    padding: 4px;
    vertical-align: top;
}

/* Table header rows */
.calendar-table thead tr.tr-month th {
    background: linear-gradient(135deg, #4a1a8c, #7c3aed);
    color: #fff;
    padding: 10px 8px;
    font-size: 1rem;
    font-weight: 700;
}
.calendar-table thead tr.tr-dates th.col-date {
    color: #fff;
    font-weight: 700;
}
.calendar-table tbody tr:hover { background: #faf5ff; }
.calendar-table tbody tr:nth-child(even) { background: #fafafa; }
.calendar-table tbody tr:nth-child(even):hover { background: #f5f0ff; }

/* Date header color cycle */
.dh-0 { background: #7c3aed; }
.dh-1 { background: #d97706; }
.dh-2 { background: #0891b2; }
.dh-3 { background: #ca8a04; }
.dh-4 { background: #db2777; }
.dh-5 { background: #16a34a; }
.dh-6 { background: #0284c7; }
.dh-7 { background: #9333ea; }
.dh-8 { background: #ea580c; }
.dh-9 { background: #0f766e; }

/* Today column highlight */
.col-today { background: #fffbeb !important; }
.col-today-header { background: #f59e0b !important; box-shadow: inset 0 -3px 0 #d97706; }

/* Cell content */
.cell-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 4px;
    min-height: 64px;
    justify-content: center;
}
.cell-WFH            { background: rgba(124, 58, 237, 0.1); }
.cell-wfh            { background: rgba(124, 58, 237, 0.1); }
.cell-office         { background: rgba(5, 150, 105, 0.1); }
.cell-leave          { background: rgba(217, 119, 6, 0.1); }
.cell-leave_sick     { background: rgba(220, 38, 38, 0.1); }
.cell-leave_personal { background: rgba(234, 88, 12, 0.1); }
.cell-leave_vacation { background: rgba(8, 145, 178, 0.1); }
.cell-official_trip  { background: rgba(29, 78, 216, 0.1); }
.cell-holiday        { background: rgba(100, 116, 139, 0.1); }
.cell-none           { background: #f8fafc; }

.work-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}
.time-label {
    font-size: 0.75rem;
    color: #64748b;
    line-height: 1.3;
}
.time-in  { color: #059669; font-weight: 600; }
.time-out { color: #dc2626; font-weight: 600; }
.icon-attach { color: #7c3aed; font-size: 0.78rem; }

/* Buttons inside cells */
.btn-checkin, .btn-checkout {
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 20px;
    white-space: nowrap;
}
.btn-checkin  { background: #7c3aed; color: #fff; border: none; }
.btn-checkin:hover { background: #6d28d9; color: #fff; }
.btn-checkout { background: #dc2626; color: #fff; border: none; }
.btn-checkout:hover { background: #b91c1c; color: #fff; }

/* ===  Schedule Admin Grid  ================================= */
.schedule-grid td.sched-cell {
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}
.sched-cell.type-WFH    { background: #ede9fe; color: #5b21b6; font-weight: 700; }
.sched-cell.type-office { background: #d1fae5; color: #065f46; font-weight: 700; }
.sched-cell.type-leave  { background: #fef3c7; color: #78350f; font-weight: 700; }
.sched-cell.type-none   { background: #f1f5f9; color: #94a3b8; }
.sched-cell:hover       { filter: brightness(0.92); }

/* ===  Login Page  ========================================== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4a1a8c 0%, #7c3aed 60%, #a78bfa 100%);
}
.login-card {
    width: 100%;
    max-width: 420px;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,0.3);
}
.login-card-header {
    background: linear-gradient(135deg, #4a1a8c, #7c3aed);
    color: #fff;
    text-align: center;
    padding: 2rem 1.5rem 1.5rem;
}
.login-card-header h3 { font-weight: 700; margin-bottom: 0.25rem; }
.login-card-body { padding: 2rem 1.75rem; }

/* ===  Form Controls  ====================================== */
.form-control:focus, .form-select:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 0 0.2rem rgba(124,58,237,0.2);
}
.btn-primary {
    background: #7c3aed;
    border-color: #7c3aed;
}
.btn-primary:hover {
    background: #6d28d9;
    border-color: #6d28d9;
}
.btn-outline-primary {
    color: #7c3aed;
    border-color: #7c3aed;
}
.btn-outline-primary:hover {
    background: #7c3aed;
    border-color: #7c3aed;
    color: #fff;
}

/* ===  Print  ============================================== */
@media print {
    .wfh-navbar, .wfh-footer, .btn, .alert, .no-print { display: none !important; }
    .calendar-wrapper { box-shadow: none; border-radius: 0; }
    .calendar-table th, .calendar-table td { border: 1px solid #999 !important; }
    .dh-0, .dh-1, .dh-2, .dh-3, .dh-4, .dh-5, .dh-6, .dh-7, .dh-8, .dh-9 { background: #7c3aed !important; print-color-adjust: exact; }
    .badge-wfh    { background: #7c3aed !important; print-color-adjust: exact; }
    .badge-office { background: #059669 !important; print-color-adjust: exact; }
}
