/* ======================================================
   Staff Attendance System - Main Stylesheet
   Mobile-first, responsive design
====================================================== */

:root {
    --primary: #2c5aa0;
    --primary-dark: #1e3f73;
    --primary-light: #4a7bc8;
    --accent: #f0a500;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --light: #f8f9fa;
    --dark: #343a40;
    --gray: #6c757d;
    --border: #dee2e6;
    --shadow: 0 2px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.15);
    --radius: 12px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
    background: #eef2f7;
    color: #333;
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.5;
}

/* ====== Header / Navbar ====== */
.navbar {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
}

.navbar-brand img {
    height: 36px;
    width: auto;
    border-radius: 4px;
}

.navbar-brand .brand-text { line-height: 1.1; }
.navbar-brand .brand-sub { font-size: 11px; opacity: 0.8; font-weight: 400; }

.navbar-right { display: flex; align-items: center; gap: 12px; }

.nav-user {
    font-size: 13px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-logout {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    transition: all .2s;
}
.btn-logout:hover { background: rgba(255,255,255,0.25); }

/* ====== Sidebar Nav ====== */
.sidebar {
    width: 220px;
    background: #fff;
    box-shadow: var(--shadow);
    min-height: calc(100vh - 60px);
    padding: 16px 0;
    position: fixed;
    top: 60px;
    left: 0;
    z-index: 900;
    transition: transform .3s;
}

.sidebar-nav { list-style: none; }

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: #555;
    text-decoration: none;
    font-size: 14px;
    transition: all .2s;
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    background: #eef2fb;
    color: var(--primary);
    border-left-color: var(--primary);
}

.sidebar-nav li a .icon { font-size: 18px; width: 22px; }

.sidebar-nav .nav-section {
    padding: 14px 20px 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gray);
    font-weight: 600;
}

/* ====== Main Content ====== */
.main-content {
    margin-left: 220px;
    padding: 24px;
    min-height: calc(100vh - 60px);
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ====== Cards ====== */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.card-header {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 18px;
    text-align: center;
    box-shadow: var(--shadow);
    border-top: 4px solid var(--primary);
    transition: transform .2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card.success { border-top-color: var(--success); }
.stat-card.danger  { border-top-color: var(--danger); }
.stat-card.warning { border-top-color: var(--warning); }
.stat-card.info    { border-top-color: var(--info); }

.stat-card .stat-num {
    font-size: 32px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}
.stat-card.success .stat-num { color: var(--success); }
.stat-card.danger  .stat-num { color: var(--danger); }
.stat-card.warning .stat-num { color: var(--warning); }
.stat-card.info    .stat-num { color: var(--info); }

.stat-card .stat-label {
    font-size: 12px;
    color: var(--gray);
    margin-top: 4px;
    font-weight: 500;
}

/* ====== Clock In/Out Button ====== */
.clock-widget {
    text-align: center;
    padding: 30px 20px;
}

.time-display {
    font-size: 48px;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 2px;
    margin-bottom: 4px;
}

.date-display {
    font-size: 14px;
    color: var(--gray);
    margin-bottom: 24px;
}

.btn-clock {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    border: none;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all .3s;
    box-shadow: var(--shadow-lg);
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    outline: none;
}

.btn-clock-in {
    background: linear-gradient(135deg, var(--success), #1e7e34);
    color: #fff;
}

.btn-clock-in:hover { transform: scale(1.05); box-shadow: 0 12px 40px rgba(40,167,69,0.4); }

.btn-clock-out {
    background: linear-gradient(135deg, var(--danger), #a71d2a);
    color: #fff;
}

.btn-clock-out:hover { transform: scale(1.05); box-shadow: 0 12px 40px rgba(220,53,69,0.4); }

.btn-clock-disabled {
    background: #e9ecef;
    color: #aaa;
    cursor: not-allowed;
}

.btn-clock .clock-icon { font-size: 36px; }

/* ====== GPS Status ====== */
.gps-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 16px 0;
    font-size: 13px;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: #f8f9fa;
}

.gps-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.gps-dot.ok { background: var(--success); animation: pulse 1.5s infinite; }
.gps-dot.error { background: var(--danger); }
.gps-dot.loading { background: var(--warning); animation: pulse 0.8s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

/* ====== Caution Mode Timer ====== */
.caution-timer {
    background: linear-gradient(135deg, #fff3cd, #ffe69c);
    border: 2px solid var(--warning);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    margin: 16px 0;
}

.caution-timer h3 {
    color: #856404;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.caution-countdown {
    font-size: 40px;
    font-weight: 800;
    color: #856404;
    letter-spacing: 2px;
}

.caution-timer .next-check {
    font-size: 12px;
    color: #856404;
    margin-top: 4px;
}

.btn-caution-confirm {
    background: var(--warning);
    color: #000;
    border: none;
    padding: 12px 28px;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 14px;
    width: 100%;
    max-width: 280px;
    transition: all .2s;
}
.btn-caution-confirm:hover { background: #e0a800; }
.btn-caution-confirm.urgent {
    background: var(--danger);
    color: #fff;
    animation: pulse-btn 1s infinite;
}

@keyframes pulse-btn {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

/* ====== Buttons ====== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all .2s;
    white-space: nowrap;
}
.btn:hover { filter: brightness(0.9); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-warning { background: var(--warning); color: #000; }
.btn-info    { background: var(--info);    color: #fff; }
.btn-light   { background: var(--light);   color: #333; border: 1px solid var(--border); }
.btn-sm      { padding: 5px 12px; font-size: 12px; }

/* ====== Forms ====== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: #444; }
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: border-color .2s, box-shadow .2s;
    outline: none;
    background: #fff;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(44,90,160,0.12);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ====== Tables ====== */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    background: var(--primary);
    color: #fff;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}
tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    vertical-align: middle;
}
tbody tr:hover { background: #f5f7fb; }
tbody tr:last-child td { border-bottom: none; }

/* ====== Badges ====== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-success { background: #d4edda; color: #155724; }
.badge-danger  { background: #f8d7da; color: #721c24; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-info    { background: #d1ecf1; color: #0c5460; }
.badge-secondary { background: #e2e3e5; color: #383d41; }
.badge-primary { background: #cce5ff; color: #004085; }

/* ====== Alerts ====== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert-success { background: #d4edda; color: #155724; border-left: 4px solid var(--success); }
.alert-danger  { background: #f8d7da; color: #721c24; border-left: 4px solid var(--danger); }
.alert-warning { background: #fff3cd; color: #856404; border-left: 4px solid var(--warning); }
.alert-info    { background: #d1ecf1; color: #0c5460; border-left: 4px solid var(--info); }

/* ====== Login Page ====== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
    padding: 20px;
}

.login-box {
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 40px 36px;
    width: 100%;
    max-width: 420px;
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}
.login-logo img { height: 60px; margin-bottom: 10px; }
.login-logo h1 { font-size: 22px; color: var(--primary-dark); font-weight: 800; }
.login-logo p  { font-size: 13px; color: var(--gray); }

/* ====== Modal ====== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal-box {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 24px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
}
.modal-title { font-size: 17px; font-weight: 700; color: var(--primary-dark); }
.modal-close { cursor: pointer; font-size: 22px; color: var(--gray); border: none; background: none; }

/* ====== Attendance Card (Today Status) ====== */
.today-status {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 16px;
}

.status-item {
    text-align: center;
    background: var(--light);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    min-width: 100px;
}
.status-item .status-val { font-size: 20px; font-weight: 700; color: var(--primary); }
.status-item .status-lbl { font-size: 11px; color: var(--gray); margin-top: 2px; }

/* ====== Tabs ====== */
.tabs { display: flex; gap: 2px; margin-bottom: 20px; border-bottom: 2px solid var(--border); }
.tab-btn {
    padding: 10px 18px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all .2s;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ====== Mobile Sidebar Toggle ====== */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
}

/* ====== Responsive ====== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-toggle { display: block; }
    .main-content { margin-left: 0; padding: 16px; }
    .form-row { grid-template-columns: 1fr; }
    .time-display { font-size: 36px; }
    .btn-clock { width: 130px; height: 130px; }
    .btn-clock .clock-icon { font-size: 28px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 800;
    }
    .sidebar-overlay.active { display: block; }
}

/* ====== Loading ====== */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ====== Toast ====== */
.toast-container {
    position: fixed;
    top: 72px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    background: #333;
    color: #fff;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    max-width: 300px;
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}
.toast.success { background: var(--success); }
.toast.danger  { background: var(--danger);  }
.toast.warning { background: #856404; }

@keyframes slideIn {
    from { transform: translateX(100px); opacity: 0; }
    to   { transform: translateX(0);     opacity: 1; }
}

/* ====== Misc ====== */
.text-center { text-align: center; }
.text-right  { text-align: right;  }
.mt-16 { margin-top: 16px; }
.mt-8  { margin-top: 8px; }
.gap-8 { gap: 8px; }
.flex  { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--gray);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }
