/* =====================================================================
   PAUCHA TECHNOLOGY — Base Stylesheet
   Blue-first enterprise theme. Layout/dashboard styles are added in
   later build phases; this file covers auth screens, buttons, badges,
   alerts, and shared primitives used across the app.
   ===================================================================== */

:root {
    --blue: #1a56db;
    --blue-dark: #1442ad;
    --navy: #0f2454;
    --navy-deep: #0a1a3d;
    --bg-soft: #f4f7fd;
    --white: #ffffff;
    --border: #e2e8f5;
    --text: #1e293b;
    --text-muted: #64748b;
    --green: #16a34a;
    --green-bg: #ecfdf3;
    --orange: #f59e0b;
    --orange-bg: #fff7ed;
    --red: #dc2626;
    --red-bg: #fef2f2;
    --purple: #7c3aed;
    --purple-bg: #f3eefe;
    --gray-bg: #f1f5f9;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 10px 30px rgba(15, 36, 84, 0.07);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg-soft);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }

/* ---------------------------------------------------------------------
   Auth pages (login)
   --------------------------------------------------------------------- */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at top left, #eaf1ff 0%, var(--bg-soft) 55%);
}

.auth-wrapper { width: 100%; max-width: 420px; }

.auth-card {
    background: var(--white);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 40px 36px;
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.logo-mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--blue), var(--navy));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 20px;
}

.auth-logo strong { display: block; color: var(--navy); font-size: 15px; letter-spacing: 0.3px; }
.auth-logo small { color: var(--text-muted); font-size: 11px; letter-spacing: 1.5px; }

.auth-card h1 { font-size: 24px; margin: 0 0 6px; color: var(--navy); }
.auth-subtitle { color: var(--text-muted); font-size: 14px; margin: 0 0 24px; }

.auth-card form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    margin: 16px 0 6px;
}

.auth-card form input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: #fbfcfe;
}

.auth-card form input:focus {
    outline: none;
    border-color: var(--blue);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.12);
}

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */
.btn {
    display: inline-block;
    padding: 12px 22px;
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s ease, transform 0.05s ease;
}

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:active { transform: translateY(1px); }
.btn-block { display: block; width: 100%; margin-top: 22px; }

.btn-secondary { background: var(--gray-bg); color: var(--text); }
.btn-secondary:hover { background: #e6ebf2; }

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

/* ---------------------------------------------------------------------
   Alerts
   --------------------------------------------------------------------- */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }
.alert-error { background: var(--red-bg); color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: var(--green-bg); color: #166534; border: 1px solid #bbf7d0; }
.alert-info { background: #eef4ff; color: var(--blue-dark); border: 1px solid #c7d9fb; }

/* ---------------------------------------------------------------------
   Status badges (used across jobs, payments, payroll)
   --------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.badge-blue   { background: #eaf1ff; color: var(--blue-dark); }
.badge-green  { background: var(--green-bg); color: var(--green); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-red    { background: var(--red-bg); color: var(--red); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-gray   { background: var(--gray-bg); color: var(--text-muted); }

/* ---------------------------------------------------------------------
   Error page (fail_safely())
   --------------------------------------------------------------------- */
.error-page {
    max-width: 480px;
    margin: 80px auto;
    text-align: center;
    background: #fff;
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.error-page h1 { color: var(--navy); }

/* ---------------------------------------------------------------------
   Shared card primitive
   --------------------------------------------------------------------- */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

/* =====================================================================
   APP SHELL — sidebar + topbar + main content
   ===================================================================== */
.app-shell { display: flex; min-height: 100vh; }

/* ---------------------------------------------------------------------
   Sidebar
   --------------------------------------------------------------------- */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 22px; }
.sidebar-brand .brand-text strong { display: block; color: #fff; font-size: 14px; letter-spacing: 0.4px; }
.sidebar-brand .brand-text small { color: #93a5c9; font-size: 10px; letter-spacing: 1.8px; }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.06);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 18px;
}
.sidebar-user strong { display: block; color: #fff; font-size: 13px; }
.sidebar-user small { color: #93a5c9; font-size: 11px; }

.avatar-circle {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--blue), #4f7ff0);
    color: #fff; font-weight: 700; font-size: 14px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.avatar-circle.small { width: 30px; height: 30px; font-size: 12px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-section-label {
    font-size: 10.5px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #6b7fa8;
    margin: 16px 10px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: #b9c6e3;
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: var(--blue); color: #fff; }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.nav-group-toggle { position: relative; }
.nav-chevron { margin-left: auto; transition: transform 0.15s ease; }
.nav-chevron svg { width: 14px; height: 14px; }
.nav-group-toggle.active .nav-chevron,
.nav-group-toggle[aria-expanded="true"] .nav-chevron { transform: rotate(90deg); }

.nav-submenu { display: flex; flex-direction: column; padding-left: 34px; margin: 2px 0 4px; }
.nav-subitem {
    padding: 8px 10px;
    border-radius: 8px;
    color: #94a6cc;
    font-size: 13px;
    text-decoration: none;
}
.nav-subitem:hover { color: #fff; }
.nav-subitem.active { color: #fff; font-weight: 600; }

.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.08); padding-top: 10px; margin-top: 10px; }

/* ---------------------------------------------------------------------
   Topbar
   --------------------------------------------------------------------- */
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: 68px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-menu-btn { display: none; background: none; border: none; cursor: pointer; color: var(--navy); padding: 4px; }

.topbar-search {
    flex: 1;
    max-width: 420px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-soft);
    border-radius: 10px;
    padding: 9px 14px;
    color: var(--text-muted);
}
.topbar-search input {
    border: none;
    background: none;
    outline: none;
    font-size: 13.5px;
    width: 100%;
    color: var(--text);
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 18px; }

.icon-btn {
    position: relative;
    background: var(--gray-bg);
    border: none;
    border-radius: 10px;
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: var(--navy);
}
.icon-btn:hover { background: #e7ecf5; }

.notif-count {
    position: absolute; top: -4px; right: -4px;
    background: var(--red); color: #fff;
    font-size: 10px; font-weight: 700;
    min-width: 17px; height: 17px; border-radius: 999px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 3px;
}

.topbar-notif { position: relative; }
.notif-dropdown {
    display: none;
    position: absolute; right: 0; top: 48px;
    width: 320px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(15,36,84,0.16);
    border: 1px solid var(--border);
    overflow: hidden;
    z-index: 50;
}
.notif-dropdown.open { display: block; }
.notif-dropdown-header { padding: 14px 16px; font-weight: 700; color: var(--navy); border-bottom: 1px solid var(--border); font-size: 14px; }
.notif-item { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border-bottom: 1px solid #f1f4fa; text-decoration: none; }
.notif-item:hover { background: var(--bg-soft); }
.notif-item.unread { background: #f5f9ff; }
.notif-item strong { color: var(--text); font-size: 13px; }
.notif-item span { color: var(--text-muted); font-size: 12.5px; }
.notif-item small { color: #a3b0c4; font-size: 11px; }
.notif-empty { padding: 24px 16px; text-align: center; color: var(--text-muted); font-size: 13px; }
.notif-dropdown-footer { display: block; text-align: center; padding: 11px; font-size: 13px; font-weight: 600; color: var(--blue); border-top: 1px solid var(--border); }

.topbar-account { display: flex; align-items: center; gap: 10px; }
.account-name { font-size: 13.5px; font-weight: 600; color: var(--navy); display: none; }

/* ---------------------------------------------------------------------
   Main content / page heading
   --------------------------------------------------------------------- */
.main-content { padding: 26px 28px 100px; flex: 1; }

.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-heading h1 { margin: 0 0 4px; font-size: 24px; color: var(--navy); }
.page-heading p { margin: 0; color: var(--text-muted); font-size: 13.5px; }
.page-heading-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------------------------------------------------------------------
   KPI cards
   --------------------------------------------------------------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.kpi-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }
.kpi-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; }
.kpi-icon svg { width: 18px; height: 18px; }
.kpi-icon.blue { background: var(--blue); }
.kpi-icon.green { background: var(--green); }
.kpi-icon.orange { background: var(--orange); }
.kpi-icon.purple { background: var(--purple); }
.kpi-icon.red { background: var(--red); }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--navy); }
.kpi-delta { font-size: 12px; margin-top: 6px; color: var(--text-muted); }
.kpi-delta.up { color: var(--green); }
.kpi-delta.down { color: var(--red); }

/* ---------------------------------------------------------------------
   Tables
   --------------------------------------------------------------------- */
.table-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table-card-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 10px; }
.table-card-header h2 { margin: 0; font-size: 16px; color: var(--navy); }

.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
    text-align: left; padding: 12px 20px; background: #fafcff;
    color: var(--text-muted); font-weight: 600; font-size: 11.5px;
    text-transform: uppercase; letter-spacing: 0.4px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td { padding: 14px 20px; border-bottom: 1px solid #f1f4fa; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafcff; }
.data-table a.row-link { color: var(--navy); font-weight: 600; text-decoration: none; }
.data-table a.row-link:hover { color: var(--blue); }
.cell-muted { color: var(--text-muted); font-size: 12.5px; }
.text-right { text-align: right; }

.empty-state { text-align: center; padding: 56px 20px; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; color: #cbd6ea; margin-bottom: 12px; }
.empty-state h3 { color: var(--navy); margin: 0 0 6px; font-size: 16px; }
.empty-state p { margin: 0 0 16px; font-size: 13.5px; }

/* ---------------------------------------------------------------------
   Filters / toolbar
   --------------------------------------------------------------------- */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-bar select, .filter-bar input[type=text], .filter-bar input[type=date] {
    padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 13px; background: #fbfcfe; color: var(--text);
}

/* ---------------------------------------------------------------------
   Forms (module pages)
   --------------------------------------------------------------------- */
.form-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px; max-width: 880px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-field label { display: block; font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 6px; }
.form-field .hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.form-field input[type=text], .form-field input[type=email], .form-field input[type=number],
.form-field input[type=date], .form-field input[type=password], .form-field select, .form-field textarea {
    width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 14px; background: #fbfcfe; font-family: inherit; color: var(--text);
}
.form-field textarea { resize: vertical; min-height: 90px; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
    outline: none; border-color: var(--blue); background: #fff; box-shadow: 0 0 0 3px rgba(26,86,219,0.1);
}
.form-actions { display: flex; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

.customer-search-box { position: relative; }
.customer-search-results {
    display: none; position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px;
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
    box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; z-index: 30;
}
.customer-search-results.open { display: block; }
.customer-search-result { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid #f1f4fa; font-size: 13.5px; }
.customer-search-result:hover { background: var(--bg-soft); }
.customer-search-result strong { display: block; color: var(--navy); }
.customer-search-result span { color: var(--text-muted); font-size: 12px; }
.selected-customer-chip {
    display: none; align-items: center; justify-content: space-between; gap: 10px;
    background: #eaf1ff; border: 1px solid #c7d9fb; border-radius: var(--radius-sm);
    padding: 10px 14px; margin-top: 8px;
}
.selected-customer-chip.open { display: flex; }
.selected-customer-chip button { background: none; border: none; color: var(--blue-dark); cursor: pointer; font-weight: 700; }

/* ---------------------------------------------------------------------
   Profile / detail view cards
   --------------------------------------------------------------------- */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
.detail-header { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin-bottom: 20px; }
.detail-header-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.detail-title { display: flex; align-items: center; gap: 14px; }
.detail-title h2 { margin: 0; font-size: 19px; color: var(--navy); }
.detail-title p { margin: 2px 0 0; color: var(--text-muted); font-size: 13px; }
.detail-meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px; margin-top: 20px; }
.meta-item .meta-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); margin-bottom: 4px; }
.meta-item .meta-value { font-size: 15px; font-weight: 700; color: var(--navy); }

.stack-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.stack-card h3 { margin: 0 0 14px; font-size: 14.5px; color: var(--navy); }
.timeline-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid #f1f4fa; }
.timeline-item:last-child { border-bottom: none; }
.timeline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); margin-top: 6px; flex-shrink: 0; }
.timeline-item strong { display: block; font-size: 13.5px; color: var(--text); }
.timeline-item small { color: var(--text-muted); font-size: 12px; }

/* ---------------------------------------------------------------------
   Progress bar
   --------------------------------------------------------------------- */
.progress-bar { background: var(--gray-bg); border-radius: 999px; height: 7px; overflow: hidden; width: 100%; }
.progress-bar-fill { background: var(--blue); height: 100%; border-radius: 999px; }

/* ---------------------------------------------------------------------
   Modal
   --------------------------------------------------------------------- */
.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,36,84,0.4); z-index: 100; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0,0,0,0.25); width: 100%; max-width: 480px; padding: 24px; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-header h3 { margin: 0; font-size: 17px; color: var(--navy); }
.modal-close { background: var(--gray-bg); border: none; border-radius: 8px; width: 30px; height: 30px; cursor: pointer; color: var(--text-muted); }

/* ---------------------------------------------------------------------
   Toasts
   --------------------------------------------------------------------- */
.toast-stack { position: fixed; bottom: 90px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 13.5px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); min-width: 220px; animation: toast-in 0.2s ease; }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------------------------------------------------------------
   Quick action tiles (dashboard)
   --------------------------------------------------------------------- */
.quick-actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 14px; }
.quick-action-tile { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 10px; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); text-decoration: none; color: var(--navy); font-size: 12.5px; font-weight: 600; text-align: center; }
.quick-action-tile .tile-icon { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #fff; }

/* ---------------------------------------------------------------------
   Pagination
   --------------------------------------------------------------------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 18px 20px; border-top: 1px solid var(--border); }
.pagination .page-link { font-size: 13px; font-weight: 600; color: var(--blue); text-decoration: none; }
.pagination .page-link:hover { color: var(--blue-dark); }
.pagination .page-info { font-size: 12.5px; color: var(--text-muted); }

/* ---------------------------------------------------------------------
   Mobile bottom nav + sheet (hidden on desktop; see mobile.css)
   --------------------------------------------------------------------- */
.mobile-bottom-nav { display: none; }
.mobile-sheet-backdrop { display: none; }
.mobile-sheet { display: none; }
