/* ============================================================
   Modern T&A UI — Universal Attendance System
   Responsive, accessible, no dependencies.
   ============================================================ */

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: #0f172a;
    background: #f1f5f9;
    -webkit-font-smoothing: antialiased;
}
img, svg, canvas { max-width: 100%; height: auto; display: block; }
a { color: #ffffff; text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

/* ===== Layout: sidebar + main ===== */
.app {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: #0f172a;
    color: #cbd5e1;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 0 1.25rem 1.5rem;
    border-bottom: 1px solid #1e293b;
    margin-bottom: 1rem;
}
.sidebar-brand .logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 800;
    font-size: .9rem;
}
.sidebar-brand .name {
    font-weight: 700;
    color: #fff;
    font-size: .95rem;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-brand .sub {
    font-size: .7rem;
    color: #8b7c64;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 .5rem; }

.sidebar-nav a {
    transition: background .18s ease, color .18s ease,
                border-color .18s ease, transform .18s ease;
}

button, .btn {
    transition: transform .15s ease, box-shadow .15s ease,
                background .15s ease;
}

.sidebar-nav a:hover { background: #1e293b; color: #fff; text-decoration: none; }
.sidebar-nav a.active { background: #1e293b; color: #fff; }
.sidebar-nav a .icon { width: 18px; text-align: center; }

.sidebar-footer {
    margin-top: auto;
    padding: 1rem 1.25rem;
    border-top: 1px solid #1e293b;
    font-size: .8rem;
}
.sidebar-footer .user {
    color: #fff;
    font-weight: 600;
    display: block;
    margin-bottom: .2rem;
}
.sidebar-footer .role {
    color: #64748b;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.sidebar-footer a {
    display: block;
    margin-top: .75rem;
    color: #94a3b8;
    font-size: .8rem;
}
.sidebar-footer a:hover { color: #fff; }

/* ===== Main content ===== */
.main { padding: 1.5rem 2rem; max-width: 1400px; }
@media (max-width: 768px) { .main { padding: 1rem; } }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.topbar h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
}
.topbar .subtitle {
    color: #64748b;
    font-size: .875rem;
    margin: 0;
}

/* ===== Cards ===== */
.card {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 2px 8px rgba(15, 23, 42, .04);
    border: 1px solid #e2e8f0;
    margin-bottom: 1.25rem;
}
.card h2 {
    margin: 0 0 1.25rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.card h2 .badge-count {
    background: #eff6ff;
    color: #1d4ed8;
    padding: .1rem .5rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
}

/* ===== Buttons ===== */
button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem 1rem;
    border-radius: 8px;
    border: 1px solid transparent;
    background: #0f172a;
    color: #fff;
    font-size: .875rem;
    font-weight: 600;
    text-decoration: none;
    transition: all .12s;
    white-space: nowrap;
}
button:hover, .btn:hover { background: #1e293b; text-decoration: none; transform: translateY(-1px); }
button:disabled, .btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

button.primary, .btn.primary { background: #2563eb; }
button.primary:hover, .btn.primary:hover { background: #1d4ed8; }

button.ok, .btn.ok { background: #16a34a; }
button.ok:hover, .btn.ok:hover { background: #15803d; }

button.warn, .btn.warn { background: #d97706; }
button.warn:hover, .btn.warn:hover { background: #b45309; }

button.out, .btn.out { background: #475569; }
button.out:hover, .btn.out:hover { background: #334155; }

button.danger, .btn.danger { background: #dc2626; }
button.danger:hover, .btn.danger:hover { background: #b91c1c; }

button.ghost, .btn.ghost {
    background: transparent;
    color: #475569;
    border: 1px solid #cbd5e1;
}
button.ghost:hover, .btn.ghost:hover { background: #f1f5f9; color: #0f172a; }

.btn-small {
    padding: .3rem .6rem;
    font-size: .75rem;
    border-radius: 6px;
}
.btn-small.ghost { background: transparent; color: #475569; border: 1px solid #cbd5e1; }

/* ===== Forms ===== */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }

label {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    font-size: .85rem;
    font-weight: 600;
    color: #0a0a0a;
}
label input, label select, label textarea {
    padding: .55rem .75rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 400;
    color: #0f172a;
    background: #fff;
    transition: border-color .12s, box-shadow .12s;
    width: 100%;
}
label input:focus, label select:focus, label textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
label input[type="checkbox"] {
    width: auto;
    margin-right: .4rem;
}

fieldset {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1rem;
    margin-top: 1rem;
}
fieldset legend {
    font-size: .8rem;
    font-weight: 700;
    color: #475569;
    padding: 0 .5rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}

form > button[type="submit"] { margin-top: 1rem; }

/* ===== Tables ===== */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .875rem;
}
table thead th {
    text-align: left;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #64748b;
    font-weight: 700;
    padding: .75rem .75rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    white-space: nowrap;
}
table thead th:first-child { border-top-left-radius: 8px; }
table thead th:last-child  { border-top-right-radius: 8px; }
table tbody td {
    padding: .75rem .75rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
table tbody tr:hover { background: #f8fafc; }
table tbody tr:last-child td { border-bottom: none; }

table code {
    background: #f1f5f9;
    color: #334155;
    padding: .15rem .4rem;
    border-radius: 4px;
    font-size: .8rem;
}

/* ===== Badges / status pills ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .25rem .6rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    text-transform: capitalize;
    white-space: nowrap;
}
.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .9;
}
.badge.in, .badge.present { background: #dcfce7; color: #166534; }
.badge.out { background: #dbeafe; color: #1e40af; }
.badge.late { background: #fef3c7; color: #92400e; }
.badge.absent { background: #f1f5f9; color: #64748b; }
.badge.no_show { background: #fee2e2; color: #991b1b; }
.badge.excused, .badge.leave { background: #ede9fe; color: #5b21b6; }

/* ===== Flash messages ===== */
.flash {
    padding: .75rem 1rem;
    border-radius: 10px;
    font-size: .875rem;
    font-weight: 500;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    border: 1px solid transparent;
    animation: flash-in .2s ease-out;
}
.flash::before { font-size: 1.1rem; }
.flash-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.flash-success::before { content: "✓"; }
.flash-error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.flash-error::before { content: "✕"; }
.flash-info { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.flash-info::before { content: "ℹ"; }

@keyframes flash-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Toolbar ===== */
.toolbar, .toolbar-card {
    display: flex;
    gap: .75rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.toolbar-card {
    background: #fff;
    padding: .75rem 1rem;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}
.toolbar-card label {
    flex-direction: row;
    align-items: center;
    gap: .5rem;
    font-weight: 600;
    font-size: .85rem;
}
.toolbar-card select { width: auto; }

/* ===== Empty state ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #64748b;
}
.empty-state::before {
    content: "📋";
    display: block;
    font-size: 2.5rem;
    margin-bottom: .5rem;
    opacity: .6;
}
.empty-state a { font-weight: 600; }

/* ===== QR Cards ===== */
.qr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 1rem;
}
.qr-card {
    background: #fff;
    padding: 12px;
    border-radius: 10px;
    text-align: center;
    border: 1px solid #e2e8f0;
    page-break-inside: avoid;
    transition: box-shadow .15s, transform .15s;
}
.qr-card:hover {
    box-shadow: 0 4px 12px rgba(15, 23, 42, .08);
    transform: translateY(-2px);
}
.qr-card strong {
    display: block;
    font-size: .95rem;
    color: #0f172a;
    margin-bottom: .15rem;
}
.qr-card span {
    display: block;
    font-size: .75rem;
    color: #64748b;
}
.qr-box {
    margin: 8px auto 0;
    display: inline-block;
}
.qr-box img, .qr-box canvas { display: block; }

/* ===== Login ===== */
.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 50%, #8b5cf6 100%);
    padding: 1rem;
}
.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 2rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, .25);
}
.login-card .brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.5rem;
}
.login-card .logo-lg {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 800;
}
.login-card h1 {
    margin: 0;
    font-size: 1.15rem;
    color: #0f172a;
}
.login-card .sub {
    font-size: .8rem;
    color: #64748b;
    margin: .15rem 0 0;
}
.login-card .field { margin-bottom: 1rem; }
.login-card button {
    width: 100%;
    padding: .75rem;
    font-size: .95rem;
    margin-top: .5rem;
}
.login-card .error {
    background: #fef2f2;
    color: #991b1b;
    padding: .6rem .8rem;
    border-radius: 8px;
    font-size: .85rem;
    margin-bottom: 1rem;
    border: 1px solid #fecaca;
}

/* ===== Week roster ===== */
.week-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin-top: 1rem;
}
.day-col {
    background: #fff;
    border-radius: 10px;
    padding: 8px;
    min-height: 180px;
    border: 1px solid #e2e8f0;
}
.day-col h4 {
    margin: 0 0 .5rem;
    font-size: .75rem;
    color: #1e3a8a;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.chip {
    padding: 6px;
    border-radius: 6px;
    font-size: .72rem;
    margin-bottom: 5px;
    color: #fff;
    position: relative;
}
.chip strong { display: block; font-size: .75rem; }
.chip a.del {
    position: absolute;
    top: 2px;
    right: 4px;
    color: #fff;
    text-decoration: none;
    opacity: .7;
    font-weight: 700;
}
.chip a.del:hover { opacity: 1; }

@media (max-width: 900px) {
    .week-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 500px) {
    .week-grid { grid-template-columns: 1fr; }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {

img, svg, canvas { max-width: 100%; height: auto; display: block; }
a { color: #ffff; text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: relative;
        height: auto;
        padding: .75rem 0;
    }
    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 0 .5rem;
    }
    .sidebar-nav a {
        flex: 1 1 auto;
        justify-content: center;
        padding: .5rem .6rem;
        font-size: .8rem;
    }
        .sidebar-nav a .label {
            display: none;
        }

         .sidebar-nav  .label {
            color: #dcfce7;
        }
    
        .sidebar-nav a .icon {
            font-size: 1.1rem;
        }
    
        .sidebar-brand {
            padding: .75rem 1rem;
            border-bottom: none;
            margin-bottom: 0;
        }
    
        .sidebar-footer {
            display: none;
        }
    
        .topbar h1 {
            font-size: 1.15rem;
        }
    
        table {
            font-size: .8rem;
        }
    
        table thead th,
        table tbody td {
            padding: .5rem .4rem;
        }
    
        .card {
            padding: 1rem;
        }
}

/* ===== Print ===== */
@media print {
    .sidebar, .topbar, .toolbar, .toolbar-card, .no-print, nav, .flash { display: none !important; }
    .app { grid-template-columns: 1fr; }
    .main { padding: 0; max-width: none; }
    .card { box-shadow: none; border: 1px solid #e2e8f0; }
    body { background: #fff; }
    .qr-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
    .qr-card { border: 1px dashed #cbd5e1; }
}

/* ===== Utility ===== */
.text-muted { color: #64748b; }
.text-sm { font-size: .85rem; }
.text-xs { font-size: .75rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.flex-end { display: flex; gap: .5rem; justify-content: flex-end; align-items: center; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-brand img.logo {
    width: auto;
    height: 40px;
    max-width: 140px;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    padding: 4px;
    flex-shrink: 0;
}

/* ===== Final responsive polish ===== */
:root { color-scheme: light; }
html { scroll-behavior: smooth; }
body { background: #f5f7fb; }
.card { border-radius: 16px; box-shadow: 0 5px 22px rgba(15,23,42,.045); }
.sidebar { background: linear-gradient(180deg,#111827 0%,#172554 100%); }
.sidebar-nav a { border-radius: 10px; padding: .72rem .8rem; }
.sidebar-nav a.active { background: linear-gradient(110deg,#2563eb,#4f46e5); box-shadow: 0 5px 14px rgba(37,99,235,.22); }
input, select, textarea { border: 1px solid #dbe2ea; border-radius: 9px; padding: .65rem .75rem; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(59,130,246,.16); border-color: #3b82f6; }
table { width: 100%; border-collapse: collapse; }
th { color: #64748b; font-size: .75rem; text-transform: uppercase; letter-spacing: .045em; }
td, th { padding: .8rem .85rem; border-bottom: 1px solid #edf0f5; text-align: left; }
tr:hover td { background: #f8fafc; }
button, .btn { border-radius: 10px; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
button.primary, .btn.primary { background: linear-gradient(110deg,#2563eb,#4f46e5); box-shadow: 0 4px 12px rgba(37,99,235,.16); }
button.primary:hover, .btn.primary:hover { box-shadow: 0 7px 18px rgba(37,99,235,.23); }
.login-wrap { min-height: 100vh; padding: 1.25rem; background: radial-gradient(ellipse at top left,#dbeafe 0%,#f5f7fb 48%,#eef2ff 100%); }
.login-card { border: 1px solid rgba(226,232,240,.9); border-radius: 22px; box-shadow: 0 24px 70px rgba(15,23,42,.12); }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; top: auto; height: auto; max-height: none; }
  .sidebar-nav { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .sidebar-footer { margin-top: .75rem; }
  .main { max-width: none; padding: 1rem; min-width: 0; }
  .card { padding: 1rem; overflow-x: auto; }
  table { min-width: 620px; }
}
@media (max-width: 480px) {
  .sidebar-nav { grid-template-columns: 1fr 1fr; }
  .topbar { align-items: flex-start; }
  .topbar h1 { font-size: 1.3rem; }
  .grid-3 { grid-template-columns: 1fr !important; }
}


/* =====================================
   TIMETRACK - MODERN RESPONSIVE NAV
===================================== */

.app-nav,
.app-nav * {
    box-sizing: border-box;
}

.app-nav {
    --nav-primary: #4f46e5;
    --nav-text: #475569;

    width: 100%;
    min-height: 82px;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    background: #ffffff;
    border: 1px solid #e8edf5;
    border-radius: 18px;
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}

/* Brand */

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    color: #172554;
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -0.7px;
    white-space: nowrap;
}

.brand-icon {
    display: grid;
    place-items: center;
    width: 43px;
    height: 43px;
    border-radius: 14px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    font-size: 29px;
    box-shadow: 0 5px 12px rgba(79, 70, 229, 0.22);
}

.brand-highlight {
    color: var(--nav-primary);
}

/* Tabs */

.nav-tabs {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px;
    background: #f5f7fc;
    border: 1px solid #edf0f7;
    border-radius: 15px;
    min-width: 0;
}

.nav-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 15px;
    border-radius: 11px;
    color: var(--nav-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 650;
    white-space: nowrap;
    transition:
        background 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease;
}

.nav-icon {
    font-size: 19px;
    line-height: 1;
}

.nav-tab:hover {
    background: #e9eaff;
    color: var(--nav-primary);
    transform: translateY(-1px);
}

/* Active tab */

.nav-tab.active,
.nav-tab[aria-current="page"] {
    color: #ffffff;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.20);
}

.nav-tab.active:hover,
.nav-tab[aria-current="page"]:hover {
    color: #ffffff;
    background: #4338ca;
}

/* Logout */

.nav-actions {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.nav-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 43px;
    padding: 0 16px;
    border: 1px solid #fee2e2;
    border-radius: 11px;
    background: #fff5f5;
    color: #dc2626;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.nav-logout:hover {
    color: #ffffff;
    background: #dc2626;
    border-color: #dc2626;
}

/* Keyboard accessibility */

.nav-tab:focus-visible,
.nav-logout:focus-visible {
    outline: 3px solid #a5b4fc;
    outline-offset: 3px;
}

/* Tablet */

@media (max-width: 1050px) {
    .app-nav {
        flex-wrap: wrap;
        gap: 12px;
        padding: 16px;
    }

    .nav-brand {
        margin-right: auto;
    }

    .nav-tabs {
        order: 3;
        width: 100%;
        overflow-x: auto;
        scrollbar-width: thin;
        scrollbar-color: #c7d2fe transparent;
    }

    .nav-tab {
        flex: 0 0 auto;
    }
}

/* Mobile */

@media (max-width: 600px) {
    .app-nav {
        padding: 12px;
        gap: 12px;
        border-radius: 14px;
    }

    .nav-brand {
        font-size: 19px;
    }

    .brand-icon {
        width: 38px;
        height: 38px;
        border-radius: 12px;
    }

    .nav-tabs {
        margin: 0 -2px;
        gap: 4px;
        padding: 5px;
        border-radius: 12px;
    }

    .nav-tab {
        min-height: 42px;
        padding: 0 12px;
        font-size: 13px;
    }

    .nav-icon {
        font-size: 17px;
    }

    .nav-logout {
        min-height: 38px;
        padding: 0 12px;
        font-size: 12px;
    }
}

/* Reduced motion accessibility */

@media (prefers-reduced-motion: reduce) {
    .nav-tab,
    .nav-logout {
        transition: none;
    }
}
.sidebar-nav a:hover {
  color: #ff9c01;
}
               