/* =====================================================================
   Simba ERP - Application styles
   Single-file, no framework. CSS variables for theming.
   ===================================================================== */

:root {
    --brand: #1e3a8a;          /* deep blue */
    --brand-2: #2563eb;        /* primary blue */
    --brand-soft: #eff6ff;
    --accent: #f59e0b;
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --text: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --success: #16a34a;
    --danger:  #dc2626;
    --warning: #d97706;
    --info:    #0284c7;
    --sidebar-bg: #0f172a;
    --sidebar-fg: #cbd5e1;
    --sidebar-fg-active: #ffffff;
    --sidebar-hover: rgba(255,255,255,.06);
    --sidebar-active: rgba(37, 99, 235, .25);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
    --shadow:    0 4px 12px rgba(0,0,0,.06);
    --radius: 10px;
    --radius-sm: 6px;
    --header-h: 60px;
    --sidebar-w: 250px;
    --sidebar-w-collapsed: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

/* ---------------------------------------------------------------------
   Auth pages
   --------------------------------------------------------------------- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background:
      radial-gradient(1200px 600px at -10% -20%, rgba(37,99,235,.18), transparent 60%),
      radial-gradient(900px 600px at 110% 120%, rgba(245,158,11,.15), transparent 60%),
      linear-gradient(135deg, #0b1227 0%, #1e3a8a 60%, #2563eb 100%);
}
.auth-shell {
    width: 100%;
    max-width: 980px;
    min-height: 560px;
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 30px 60px rgba(0,0,0,.25);
    background: var(--surface);
}
.auth-showcase {
    color: #fff;
    padding: 42px 36px;
    position: relative;
    background:
        linear-gradient(160deg, rgba(255,255,255,.08), rgba(255,255,255,0) 45%),
        linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 55%, #0f172a 100%);
}
.auth-showcase::after {
    content: "";
    position: absolute;
    right: -80px;
    bottom: -80px;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    background: rgba(255,255,255,.08);
}
.auth-showcase-inner {
    position: relative;
    z-index: 2;
}
.auth-showcase .showcase-badge {
    display: inline-flex;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255,255,255,.16);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .3px;
    margin-bottom: 18px;
}
.auth-showcase h2 {
    margin: 0 0 12px;
    font-size: 30px;
    line-height: 1.2;
}
.auth-showcase p {
    margin: 0 0 18px;
    opacity: .92;
    line-height: 1.6;
}
.auth-showcase ul {
    margin: 0;
    padding-left: 18px;
    opacity: .95;
    line-height: 1.9;
}
.auth-card {
    width: 100%;
    max-width: none;
    background: var(--surface);
    border-radius: 0;
    padding: 44px 36px;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.auth-brand .logo {
    width: 44px; height: 44px; border-radius: 12px;
    background: linear-gradient(135deg, var(--brand-2), var(--brand));
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.auth-brand .logo .logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #fff;
    border-radius: 12px;
}
.auth-title { font-size: 22px; font-weight: 700; margin: 0; }
.auth-subtitle { color: var(--text-muted); margin: 4px 0 0 0; font-size: 13px; }
@media (max-width: 900px) {
    .auth-shell { grid-template-columns: 1fr; min-height: 0; }
    .auth-showcase { display: none; }
    .auth-card {
        border-radius: 16px;
        padding: 34px 24px;
    }
}

/* ---------------------------------------------------------------------
   App shell
   --------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-fg);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: width .2s ease;
    overflow: hidden;
}
.sidebar .brand {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 8px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}
.sidebar .brand .brand-full-logo {
    width: 100%;
    max-height: calc(var(--header-h) - 10px);
    object-fit: contain;
    display: block;
}
.sidebar nav { flex: 1; overflow-y: auto; padding: 12px 8px 32px; }
.sidebar nav::-webkit-scrollbar { width: 6px; }
.sidebar nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 3px; }

.nav-section {
    padding: 12px 12px 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(203, 213, 225, 0.5);
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px;
    color: var(--sidebar-fg);
    border-radius: 8px;
    margin: 2px 4px;
    font-size: 13.5px;
    cursor: pointer;
    user-select: none;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-fg-active); text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: var(--sidebar-fg-active); }
.nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }
.nav-item .label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item .chev { margin-left: auto; opacity: .6; transition: transform .15s; font-size: 11px; }
.nav-item.open .chev { transform: rotate(90deg); }

.nav-sub { display: none; padding: 2px 0 6px 36px; }
.nav-sub.open { display: block; }
.nav-sub a {
    display: block;
    padding: 7px 10px;
    color: rgba(203, 213, 225, 0.85);
    font-size: 13px;
    border-radius: 6px;
}
.nav-sub a:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-sub a.active { color: #fff; background: var(--sidebar-active); }

/* Main content area */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-width: 0;
    transition: margin-left .2s ease;
}

/* Topbar */
.topbar {
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky; top: 0; z-index: 30;
}
.topbar .menu-toggle {
    background: transparent; border: none; cursor: pointer;
    padding: 6px;
    color: var(--text-muted);
}
.topbar .title { font-size: 16px; font-weight: 600; flex: 1; }
.topbar .user {
    display: flex; align-items: center; gap: 12px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 8px;
    position: relative;
}
.topbar .user:hover { background: var(--surface-2); }
.topbar .avatar {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--brand-2), var(--brand));
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
}
.topbar .user-name { font-weight: 600; font-size: 13.5px; }
.topbar .user-role { font-size: 11.5px; color: var(--text-muted); }
.topbar .user-menu {
    position: absolute; right: 0; top: calc(100% + 6px);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; box-shadow: var(--shadow);
    min-width: 200px; padding: 6px;
    display: none; z-index: 100;
}
.topbar .user-menu.open { display: block; }
.topbar .user-menu a, .topbar .user-menu button {
    display: block; width: 100%;
    padding: 9px 12px;
    color: var(--text);
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    font-size: 13.5px;
}
.topbar .user-menu a:hover, .topbar .user-menu button:hover {
    background: var(--brand-soft); text-decoration: none;
}

.tenant-badge {
    padding: 4px 10px; background: var(--brand-soft); color: var(--brand);
    border-radius: 999px; font-size: 12px; font-weight: 600;
}
.impersonation-bar {
    background: var(--warning); color: #fff;
    text-align: center; padding: 6px 12px; font-size: 13px;
}
.impersonation-bar form { display: inline; }
.impersonation-bar button {
    background: transparent; border: 1px solid #fff;
    color: #fff; padding: 2px 10px; border-radius: 4px;
    margin-left: 12px; cursor: pointer; font-size: 12px;
}

/* Content area */
.content { padding: 24px; }
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.page-header h1 { font-size: 22px; font-weight: 700; margin: 0; }
.page-header .subtitle { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ---------------------------------------------------------------------
   Cards
   --------------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}
.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px;
}
.card-header h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card-body { padding: 18px; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--border); }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px; margin-bottom: 24px;
}
.stat {
    background: var(--surface);
    padding: 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex; gap: 16px; align-items: center;
}
.stat .icon-circle {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: var(--brand-soft); color: var(--brand-2);
    font-size: 20px;
}
.stat .label { color: var(--text-muted); font-size: 12.5px; }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 2px; }
.stat.green .icon-circle { background: #dcfce7; color: var(--success); }
.stat.orange .icon-circle { background: #ffedd5; color: var(--warning); }
.stat.red .icon-circle { background: #fee2e2; color: var(--danger); }
.stat.purple .icon-circle { background: #ede9fe; color: #6d28d9; }

/* ---------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label {
    font-size: 12.5px; color: var(--text-muted);
    font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
}
.form-group label .req { color: var(--danger); }
.form-control, input.form-control, select.form-control, textarea.form-control {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
    font-family: inherit;
}
.form-control:focus {
    outline: none;
    border-color: var(--brand-2);
    box-shadow: 0 0 0 3px rgba(37,99,235,.18);
}
textarea.form-control { resize: vertical; min-height: 80px; }
.form-error { color: var(--danger); font-size: 12px; }
.form-hint  { color: var(--text-muted); font-size: 12px; }

.form-actions {
    display: flex; gap: 10px; justify-content: flex-end;
    margin-top: 16px; padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 13.5px; font-weight: 500;
    cursor: pointer; user-select: none;
    background: var(--surface); color: var(--text); border-color: var(--border);
    transition: all .15s;
    text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-primary  { background: var(--brand-2); color: #fff; border-color: var(--brand-2); }
.btn-primary:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-success  { background: var(--success); color: #fff; border-color: var(--success); }
.btn-danger   { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-warning  { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-ghost    { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm       { padding: 5px 10px; font-size: 12px; }
.btn-xs       { padding: 3px 8px; font-size: 11.5px; }
.btn-block    { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }

/* ---------------------------------------------------------------------
   Tables
   --------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: 13.5px;
}
.table th, .table td {
    padding: 11px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table th {
    background: var(--surface-2);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 11.5px;
    letter-spacing: .5px;
}
.table tbody tr:hover { background: var(--surface-2); }
.table .actions { display: flex; gap: 6px; }
.table-empty { padding: 36px; text-align: center; color: var(--text-muted); }

/* Pills / badges */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--text-muted);
    text-transform: capitalize;
}
.badge.green   { background: #dcfce7; color: var(--success); }
.badge.red     { background: #fee2e2; color: var(--danger); }
.badge.orange  { background: #ffedd5; color: var(--warning); }
.badge.blue    { background: var(--brand-soft); color: var(--brand-2); }
.badge.gray    { background: #e5e7eb; color: #4b5563; }
.badge.purple  { background: #ede9fe; color: #6d28d9; }

/* Alerts */
.alert {
    padding: 11px 14px; border-radius: var(--radius-sm);
    border-left: 4px solid var(--brand-2);
    background: var(--brand-soft); color: var(--brand);
    margin-bottom: 14px; font-size: 13.5px;
}
.alert.success { border-color: var(--success); background: #ecfdf5; color: #065f46; }
.alert.error   { border-color: var(--danger);  background: #fef2f2; color: #991b1b; }
.alert.warning { border-color: var(--warning); background: #fffbeb; color: #92400e; }

/* Tabs */
.tabs { display: flex; border-bottom: 1px solid var(--border); gap: 4px; margin-bottom: 18px; flex-wrap: wrap; }
.tab {
    padding: 9px 16px; cursor: pointer;
    color: var(--text-muted); font-size: 13.5px; font-weight: 500;
    border-bottom: 2px solid transparent;
    text-decoration: none;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--brand-2); border-bottom-color: var(--brand-2); }

/* Filter row */
.filters {
    display: flex; flex-wrap: wrap; gap: 10px;
    margin-bottom: 14px;
    align-items: center;
}
.filters .form-control { padding: 7px 10px; min-width: 140px; }
.filters .spacer { flex: 1; }

/* Modal-ish inline form panel */
.collapsible {
    border-top: 1px dashed var(--border);
    margin-top: 16px; padding-top: 16px;
}

/* Responsive */
@media (max-width: 980px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .topbar .title { font-size: 14px; }
}
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.sidebar.collapsed .label, .sidebar.collapsed .chev, .sidebar.collapsed .nav-section { display: none; }
.sidebar.collapsed .nav-sub { display: none !important; }
.sidebar.collapsed + .main { margin-left: var(--sidebar-w-collapsed); }
@media (max-width: 980px) { .sidebar.collapsed + .main { margin-left: 0; } }

/* Empty state */
.empty {
    text-align: center; padding: 48px 16px; color: var(--text-muted);
}
.empty .icon { font-size: 40px; margin-bottom: 8px; opacity: .4; }

/* Document item */
.doc-card {
    display: flex; align-items: center; gap: 12px;
    padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    margin-bottom: 8px;
    background: var(--surface-2);
}

/* Profile view */
.profile-hero {
    display: flex; gap: 20px; align-items: center;
    padding: 24px;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
    color: #fff;
    border-radius: var(--radius);
    margin-bottom: 20px;
}
.profile-hero .avatar-lg {
    width: 80px; height: 80px; border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 32px; font-weight: 700;
}
.profile-hero h2 { margin: 0; font-size: 22px; }
.profile-hero p { margin: 4px 0 0; opacity: .9; }

/* Setup grid */
.setup-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}
.setup-tile {
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    display: flex; gap: 14px; align-items: center;
    transition: all .15s;
}
.setup-tile:hover { border-color: var(--brand-2); box-shadow: var(--shadow); transform: translateY(-2px); text-decoration: none; }
.setup-tile .icon-circle {
    width: 44px; height: 44px; border-radius: 10px;
    background: var(--brand-soft); color: var(--brand-2);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0;
}
.setup-tile .label { font-weight: 600; font-size: 14px; }
.setup-tile .hint { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

/* Print styles for payslip */
@media print {
    .sidebar, .topbar, .page-header .btn, .no-print { display: none !important; }
    .main { margin-left: 0 !important; }
    .content { padding: 0; }
    .card { box-shadow: none; border-color: #000; }
}
