/* ============================================================
   Insta Payroll — Theme
   Modern, consistent design system layered over style.css
   ============================================================ */

:root {
    /* Brand */
    --brand:        #0d47a1;
    --brand-600:    #0a3d8f;
    --brand-700:    #093a80;
    --brand-100:    #e3edff;
    --brand-50:     #f0f5ff;

    /* Semantic */
    --success:      #16a34a;
    --success-50:   #ecfdf5;
    --warning:      #f59e0b;
    --warning-50:   #fffbeb;
    --danger:       #dc2626;
    --danger-50:    #fef2f2;
    --info:         #0284c7;
    --info-50:      #f0f9ff;

    /* Neutrals */
    --bg:           #f4f7fc;
    --surface:      #ffffff;
    --surface-alt:  #f8fafc;
    --border:       #e2e8f0;
    --border-strong:#cbd5e1;
    --text:         #1e293b;
    --text-muted:   #64748b;
    --text-light:   #94a3b8;

    /* Sizing */
    --radius-sm:    6px;
    --radius:       8px;
    --radius-lg:    12px;
    --radius-xl:    16px;

    /* Shadow */
    --shadow-sm:    0 1px 2px rgba(15,23,42,.06);
    --shadow:       0 2px 8px rgba(15,23,42,.06);
    --shadow-md:    0 4px 16px rgba(15,23,42,.08);
    --shadow-lg:    0 12px 32px rgba(15,23,42,.10);

    /* Motion */
    --t-fast:       120ms ease;
    --t-base:       200ms ease;
}

/* ---------- Base ---------- */
html { scroll-behavior: smooth; }
body {
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--brand-700); text-decoration: none; }

h1,h2,h3,h4 { color: var(--text); font-weight: 600; letter-spacing: -.01em; }

/* ---------- Layout ---------- */
.container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
    background: var(--brand);
    color: #fff;
    padding: 0;
    display: block;
    box-shadow: 0 1px 3px rgba(0,0,0,.12);
    position: sticky; top: 0; z-index: 100;
}
.navbar .nav-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex; align-items: center;
    height: 62px;
    gap: 20px;
}
.navbar .brand {
    display: flex; align-items: center; gap: 10px;
    font-size: 18px; font-weight: 700;
    color: #fff; letter-spacing: .2px;
    white-space: nowrap;
}
.navbar .brand img {
    width: 32px; height: 32px; object-fit: contain;
    background: rgba(255,255,255,.1);
    border-radius: 8px; padding: 3px;
}
.navbar .brand span { color: #6ee7b7; }

.navbar .nav-links {
    display: flex; align-items: center; gap: 4px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}
.navbar .nav-links::-webkit-scrollbar { display: none; }

.navbar .nav-links a {
    color: rgba(255,255,255,.85);
    padding: 8px 12px;
    font-size: 13.5px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    margin: 0;
    white-space: nowrap;
    transition: background var(--t-fast), color var(--t-fast);
    position: relative;
}
.navbar .nav-links a:hover {
    background: rgba(255,255,255,.10);
    color: #fff;
}
.navbar .nav-links a.active {
    background: rgba(255,255,255,.16);
    color: #fff;
}
.navbar .nav-links a.active::after {
    content: '';
    position: absolute; left: 12px; right: 12px; bottom: -1px;
    height: 2px; background: #6ee7b7; border-radius: 2px;
}

.navbar .badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 5px;
    background: var(--danger); color: #fff;
    font-size: 11px; font-weight: 700;
    border-radius: 999px;
    margin-left: 6px;
    vertical-align: middle;
}

.navbar .nav-right {
    display: flex; align-items: center; gap: 8px;
    margin-left: auto;
}
.navbar .nav-right a.icon-btn {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    color: #fff; background: rgba(255,255,255,.08);
    font-size: 16px; padding: 0; margin: 0;
    transition: background var(--t-fast);
}
.navbar .nav-right a.icon-btn:hover { background: rgba(255,255,255,.18); }

.navbar .user-chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 5px 12px 5px 5px;
    background: rgba(255,255,255,.10);
    border-radius: 999px;
    color: #fff; font-size: 13px; font-weight: 500;
}
.navbar .user-chip .avatar {
    width: 26px; height: 26px; border-radius: 50%;
    background: #6ee7b7; color: var(--brand-700);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12px;
}

.navbar .hamburger {
    display: none;
    background: none; border: none;
    color: #fff; font-size: 22px;
    padding: 6px; margin: 0;
    cursor: pointer;
}

@media (max-width: 960px) {
    .navbar .nav-links { display: none; }
    .navbar .nav-links.open {
        display: flex; flex-direction: column;
        position: absolute; top: 62px; left: 0; right: 0;
        background: var(--brand-700);
        padding: 12px; gap: 2px;
        box-shadow: var(--shadow-lg);
    }
    .navbar .nav-links a { width: 100%; padding: 10px 14px; }
    .navbar .hamburger { display: inline-flex; }
    .navbar .nav-inner { padding: 0 16px; }
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 18px 22px;
    margin: 20px 0;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    color: var(--text);
}
.page-header h1 {
    font-size: 20px; font-weight: 600;
    margin: 0;
    color: var(--text);
    letter-spacing: -.01em;
}
.page-header .actions { display: flex; gap: 8px; align-items: center; }
.page-header a:not(.btn) {
    color: var(--brand);
    font-size: 13.5px; font-weight: 500;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 22px 24px;
    margin: 16px 0;
}
.card h2 {
    font-size: 16px; font-weight: 600;
    color: var(--text);
    margin: 0 0 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.card h3 {
    font-size: 15px; font-weight: 600;
    margin: 0 0 14px;
}

/* Stat cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
}
.stat-card .stat-value {
    font-size: 26px; font-weight: 700;
    color: var(--brand);
    line-height: 1.2;
}
.stat-card .stat-label {
    font-size: 12.5px; color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase; letter-spacing: .5px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn, button:not(.icon-btn):not(.hamburger):not(.close-x) {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px;
    font-family: inherit;
    font-size: 13.5px; font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
    line-height: 1.3;
    background: var(--brand);
    color: #fff;
}
.btn:hover, button:hover:not(.icon-btn):not(.hamburger) {
    background: var(--brand-600);
}
.btn:active { transform: translateY(1px); }

.btn-secondary, button.secondary {
    background: #fff;
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-secondary:hover, button.secondary:hover {
    background: var(--surface-alt);
    border-color: var(--brand);
    color: var(--brand);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: #b91c1c; }

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover { background: #15803d; }

.btn-ghost {
    background: transparent;
    color: var(--brand);
    border-color: transparent;
}
.btn-ghost:hover { background: var(--brand-50); }

.btn-sm {
    padding: 5px 10px;
    font-size: 12.5px;
}

/* ============================================================
   TABLES
   ============================================================ */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 8px 0 0;
    font-size: 13.5px;
    background: #fff;
}
table thead th {
    background: var(--brand);
    color: #fff;
    padding: 11px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12.5px;
    letter-spacing: .3px;
    text-transform: uppercase;
}
table thead th:first-child { border-top-left-radius: var(--radius); }
table thead th:last-child  { border-top-right-radius: var(--radius); }

table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table tbody tr:nth-child(even) td { background: var(--surface-alt); }
table tbody tr:hover td {
    background: var(--brand-50);
}
table tbody tr:last-child td { border-bottom: none; }

/* Card-wrapped table */
.card table {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

/* Numeric right align */
table .num, table td.num, table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Row action cluster */
.row-actions { display: flex; gap: 6px; align-items: center; }
.row-actions form { display: inline; }

/* ============================================================
   FORMS
   ============================================================ */
label {
    display: block;
    font-size: 13px; font-weight: 600;
    color: var(--text);
    margin: 14px 0 6px;
}
label:first-child { margin-top: 0; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    outline: none;
    transition: border var(--t-fast), box-shadow var(--t-fast);
}
input:focus, select:focus, textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(13,71,161,.12);
}
textarea { resize: vertical; min-height: 80px; }

input[type="file"] {
    padding: 6px 10px;
    background: var(--surface-alt);
    cursor: pointer;
}

/* Form grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px 18px;
}
.form-grid label { margin: 0; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    border-left: 4px solid;
    font-size: 13.5px;
    margin: 14px 0;
    background: var(--info-50);
    border-color: var(--info);
    color: #075985;
}
.alert-success { background: var(--success-50); border-color: var(--success); color: #166534; }
.alert-warning { background: var(--warning-50); border-color: var(--warning); color: #92400e; }
.alert-error   { background: var(--danger-50);  border-color: var(--danger);  color: #991b1b; }

/* ============================================================
   BADGES / PILLS
   ============================================================ */
.pill {
    display: inline-block;
    padding: 2px 9px;
    font-size: 11.5px; font-weight: 600;
    border-radius: 999px;
    background: var(--brand-100);
    color: var(--brand-700);
    letter-spacing: .2px;
}
.pill-success { background: var(--success-50); color: #166534; }
.pill-warning { background: var(--warning-50); color: #92400e; }
.pill-danger  { background: var(--danger-50);  color: #991b1b; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15,23,42,.55);
    backdrop-filter: blur(3px);
    z-index: 999;
    padding: 30px 16px;
    overflow-y: auto;
}
.modal-overlay.open { display: block; }
.modal-box {
    background: #fff;
    width: 100%; max-width: 520px;
    margin: 40px auto;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 24px 26px;
    animation: modalIn 150ms ease-out;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(-8px) scale(.98); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}
.modal-box h3 {
    margin: 0 0 16px;
    font-size: 17px; font-weight: 600;
    color: var(--brand);
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.modal-box label { margin-top: 12px; }
.modal-box button { margin-top: 16px; }
.modal-box button + button { margin-left: 8px; }

/* ============================================================
   UTILITIES
   ============================================================ */
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ============================================================
   PRINT
   ============================================================ */
@media print {
    body { background: #fff; }
    .navbar, .no-print, .print-btn { display: none !important; }
    .container { max-width: 100%; padding: 0; }
    .card, .page-header { box-shadow: none; border: 1px solid #ccc; }
}

/* ============================================================
   RESPONSIVE TABLE WRAPPER
   ============================================================ */
.card table {
    width: 100%;
}
.card {
    overflow-x: auto;
}

/* Compact tables — smaller padding when many columns */
table.compact th,
table.compact td {
    padding: 8px 10px;
    font-size: 12.5px;
    white-space: nowrap;
}

/* Allow select columns to wrap */
table td.wrap { white-space: normal; }

/* Hide columns marked as .hide-sm on small screens */
@media (max-width: 1100px) {
    table .hide-md { display: none; }
}
@media (max-width: 800px) {
    table .hide-sm { display: none; }
}

/* Prevent the header row text from wrapping awkwardly */
table thead th {
    white-space: nowrap;
}

/* Employee list action cell — keep buttons compact */
.row-actions button,
.row-actions a {
    padding: 4px 9px !important;
    font-size: 12px !important;
}

/* Employee table — tighter columns to fit all 7 visible at once */
table.emp-table th,
table.emp-table td {
    padding: 7px 9px;
    font-size: 12.5px;
    white-space: nowrap;
}
table.emp-table th { font-size: 11.5px; letter-spacing: .4px; }

/* Email column can shrink with ellipsis */
table.emp-table td:nth-child(4) {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Action buttons stay compact */
table.emp-table .row-actions button,
table.emp-table button {
    padding: 4px 10px !important;
    font-size: 12px !important;
}

/* ---------- Employee List: hide non-essential columns ---------- */
/* Column order: 1 Code | 2 Biometric | 3 Full Name | 4 Email | 5 Role |
                 6 Dept | 7 Type | 8 Base/Hourly | 9 Lunch | 10 Company | 11 Actions */
table.emp-table th:nth-child(2),
table.emp-table td:nth-child(2),
table.emp-table th:nth-child(5),
table.emp-table td:nth-child(5),
table.emp-table th:nth-child(6),
table.emp-table td:nth-child(6),
table.emp-table th:nth-child(9),
table.emp-table td:nth-child(9) {
    display: none !important;
}

/* Tighter padding so the remaining 7 columns fit */
table.emp-table th,
table.emp-table td {
    padding: 8px 10px !important;
    font-size: 12.5px !important;
    white-space: nowrap;
}
table.emp-table th { font-size: 11.5px !important; }

/* Email column can shrink */
table.emp-table td:nth-child(4) {
    max-width: 230px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Action buttons compact */
table.emp-table .row-actions button,
table.emp-table button {
    padding: 4px 10px !important;
    font-size: 12px !important;
}

/* ============================================================
   ADD EMPLOYEE FORM — two-column layout
   ============================================================ */
.employee-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 24px;
    align-items: start;
}
.employee-form > * {
    margin: 0 !important;
}
.employee-form label {
    display: block;
    margin: 0 0 6px !important;
}
.employee-form input,
.employee-form select,
.employee-form textarea {
    width: 100%;
}
/* Full-width rows for elements with .full-span */
.employee-form .full-span {
    grid-column: 1 / -1;
}
/* Stack on narrow screens */
@media (max-width: 720px) {
    .employee-form { grid-template-columns: 1fr; }
}

/* Toggle rows that show/hide for contractor vs regular */
.employee-form .toggle-row {
    grid-column: 1 / -1;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

/* Form full-span row helper */
.employee-form .full-span { grid-column: 1 / -1; }

/* Checkbox inline */
.employee-form input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
    vertical-align: middle;
}
.employee-form label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    font-weight: 500;
}

/* Submit button — full width row */
.employee-form .full-span button {
    min-width: 180px;
}

/* Navbar brand — use transparent logo without the light chip */
.navbar .brand img {
    background: transparent !important;
    border-radius: 0 !important;
    padding: 0 !important;
    width: 34px;
    height: 34px;
    object-fit: contain;
}
