/* ==========================================================================
   Taxifier portal — shared design system
   Same look as the Bulk Invoices screen (taxifier.com/bulkInvoices).
   Page-specific refinements live in theme.css, loaded after each page's own styles.
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500&display=swap');

:root {
    /* Brand + neutrals (shared with bulkInvoices/bulk.css) */
    --brand-900: #0a2a66;
    --brand-800: #0d3b8c;
    --brand-700: #0d47a1;
    --brand-600: #1565c0;
    --brand-100: #e3edfb;
    --brand-50:  #f2f6fd;

    --ink-900: #0f172a;
    --ink-700: #334155;
    --ink-500: #64748b;
    --ink-400: #94a3b8;
    --ink-300: #cbd5e1;
    --line:    #e2e8f0;
    --line-soft: #eef2f7;
    --surface: #ffffff;
    --bg:      #f3f6fb;
    --calc-bg: #f6f8fc;

    --green-700: #15803d;
    --green-600: #16a34a;
    --green-100: #bbf7d0;
    --green-50:  #ecfdf3;
    --amber-700: #b45309;
    --amber-500: #f59e0b;
    --amber-100: #fde68a;
    --amber-50:  #fffbeb;
    --red-700:   #b91c1c;
    --red-600:   #dc2626;
    --red-100:   #fee2e2;
    --red-50:    #fef2f2;

    --font: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    --focus: 0 0 0 3px rgba(21, 101, 192, .18);
    --gradient-brand: linear-gradient(120deg, var(--brand-900), var(--brand-700) 60%, var(--brand-600));
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");

    /* Older names used by the page styles, mapped onto the new palette */
    --primary-color: var(--brand-700);
    --primary-dark: var(--brand-800);
    --primary-light: var(--brand-600);
    --secondary-color: var(--green-600);
    --accent-color: var(--brand-600);
    --text-dark: var(--ink-900);
    --text-medium: var(--ink-700);
    --text-light: var(--ink-500);
    --text-muted: var(--ink-400);
    --bg-light: var(--bg);
    --bg-white: var(--surface);
    --border-color: var(--line);
    --border-light: var(--line-soft);
    --success: var(--green-700);
    --success-bg: var(--green-50);
    --danger: var(--red-600);
    --danger-bg: var(--red-50);
    --warning: var(--amber-700);
    --warning-bg: var(--amber-50);
    --info: var(--brand-600);
    --info-bg: var(--brand-50);

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-md: 0 1px 3px rgba(15, 23, 42, .06), 0 6px 16px rgba(15, 23, 42, .06);
    --shadow-lg: 0 12px 40px rgba(15, 23, 42, .18);
    --radius-sm: 7px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --sidebar-width: 248px;
    --header-height: 64px;
    --transition: .15s ease;
}

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

body {
    font-family: var(--font);
    background-color: var(--bg);
    color: var(--ink-900);
    line-height: 1.5;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea { font-family: inherit; }

/* ===================================
   Authentication pages (login)
   =================================== */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(66, 165, 245, .35), transparent 60%),
        radial-gradient(900px 500px at 110% 110%, rgba(21, 101, 192, .45), transparent 60%),
        var(--brand-900);
}

.auth-card {
    background: var(--surface);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 40px 36px;
    animation: fadeInUp .4s ease;
    position: relative;
    z-index: 1;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo img { max-width: 220px; height: auto; }
.auth-title { text-align: center; color: var(--ink-900); font-size: 21px; font-weight: 700; letter-spacing: -.2px; margin-bottom: 6px; }
.auth-subtitle { text-align: center; color: var(--ink-500); font-size: 14px; margin-bottom: 26px; }

.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--ink-500);
    font-weight: 600;
    font-size: 11.5px;
    letter-spacing: .4px;
    text-transform: uppercase;
}

.form-control {
    width: 100%;
    height: 42px;
    padding: 0 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: border-color var(--transition), box-shadow var(--transition);
    background-color: var(--surface);
    color: var(--ink-900);
}
textarea.form-control { height: auto; padding: 10px 14px; }
.form-control:hover { border-color: var(--ink-300); }
.form-control:focus { outline: none; border-color: var(--brand-600); box-shadow: var(--focus); }
.form-control::placeholder { color: var(--ink-400); }
.form-control-lg { height: 46px; font-size: 15px; }

.form-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: var(--chevron);
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 15px;
    padding-right: 36px;
}

/* ===================================
   Buttons
   =================================== */
.btn {
    height: 38px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), transform .05s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    line-height: 1;
    white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--brand-700); color: #fff; width: 100%; box-shadow: 0 1px 2px rgba(13, 71, 161, .3); }
.btn-primary:hover:not(:disabled) { background: var(--brand-800); }
.btn-success { background: var(--green-600); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--green-700); }
.btn-danger { background: var(--red-600); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--red-700); }
.btn-info { background: var(--brand-600); color: #fff; }
.btn-info:hover:not(:disabled) { background: var(--brand-700); }
.btn-warning { background: var(--amber-500); color: #fff; }
.btn-warning:hover:not(:disabled) { background: var(--amber-700); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }

.auth-footer { text-align: center; margin-top: 22px; color: var(--ink-500); font-size: 13px; line-height: 1.7; }
.auth-footer a { color: var(--brand-700); text-decoration: none; font-weight: 600; }
.auth-footer a:hover { text-decoration: underline; }

/* ===================================
   App shell
   =================================== */
.dashboard-wrapper { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--line);
    position: fixed;
    height: 100vh;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform .3s ease;
}

.sidebar-header {
    height: var(--header-height);
    padding: 0 22px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--line);
}
.sidebar-header img { max-width: 150px; height: auto; }

.sidebar-menu { list-style: none; padding: 14px 12px; flex-shrink: 0; }
.sidebar-menu li { margin-bottom: 2px; }

.sidebar-menu a {
    display: flex;
    align-items: center;
    height: 40px;
    padding: 0 12px;
    color: var(--ink-700);
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
    font-size: 13.5px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    position: relative;
}
.sidebar-menu a:hover { background: var(--bg); color: var(--brand-700); }

.sidebar-menu a.active {
    background: var(--brand-50);
    color: var(--brand-700);
    font-weight: 600;
    box-shadow: inset 0 0 0 1px var(--brand-100);
}
.sidebar-menu a.active::before {
    content: '';
    position: absolute;
    left: -12px; top: 9px; bottom: 9px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--brand-600);
}

.sidebar-menu a i {
    margin-right: 11px;
    width: 28px;
    height: 28px;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-style: normal;
    color: var(--ink-500);
    transition: background var(--transition), color var(--transition);
}
.sidebar-menu a:hover i { color: var(--brand-700); }
.sidebar-menu a.active i { background: var(--brand-700); color: #fff; }

.sidebar-menu-sep { height: 1px; background: var(--line); margin: 10px 12px; }

.sidebar-menu a.sidebar-logout:hover { background: var(--red-50); color: var(--red-700); }
.sidebar-menu a.sidebar-logout:hover i { color: var(--red-700); }

/* Main content */
.main-content { margin-left: var(--sidebar-width); flex: 1; min-width: 0; min-height: 100vh; background: var(--bg); }

/* Top bar — same gradient as the Bulk Invoices header */
.top-navbar {
    background: var(--gradient-brand);
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 999;
    box-shadow: 0 2px 10px rgba(10, 42, 102, .25);
}
.navbar-title { font-size: 17px; font-weight: 700; color: #fff; letter-spacing: -.1px; }
.navbar-date { font-size: 12.5px; font-weight: 500; color: rgba(255, 255, 255, .7); }

.navbar-user { display: flex; align-items: center; gap: 12px; }
.navbar-user > a {
    display: flex; align-items: center;
    padding: 4px 8px; border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.navbar-user > a:hover { background: rgba(255, 255, 255, .1); }
.user-info { text-align: right; }
.user-name { font-size: 13.5px; font-weight: 600; color: #fff; }
.user-role { font-size: 11px; color: rgba(255, 255, 255, .65); text-transform: uppercase; letter-spacing: .4px; }

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #42a5f5, #1e88e5 55%, #1565c0);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25), 0 4px 12px rgba(0, 0, 0, .2);
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.logout-btn {
    height: 34px;
    padding: 0 14px;
    background: rgba(255, 255, 255, .1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 600;
    transition: background var(--transition), border-color var(--transition);
}
.logout-btn:hover { background: var(--red-600); border-color: var(--red-600); }

/* Page area */
.main-panel { padding: 24px; }
.container { max-width: 1400px; margin: 0 auto; }

.page-header { margin-bottom: 22px; }
.page-header h3 { font-size: 22px; font-weight: 700; color: var(--ink-900); letter-spacing: -.3px; }

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 18px;
    border: 1px solid var(--line);
}
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-title { font-size: 14px; font-weight: 700; color: var(--ink-900); margin-bottom: 0; }
.card-body { padding: 20px; }
.card-action { padding: 16px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; }

/* Form bits */
.form-check { margin-right: 20px; }
.form-check-input { margin-right: 8px; accent-color: var(--brand-700); }
.form-check-label { font-size: 14px; color: var(--ink-900); }
input[type=checkbox], input[type=radio] { accent-color: var(--brand-700); }

/* Tables */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; margin-top: 16px; }
.table thead { background: #f8fafc; }
.table th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--ink-500);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .4px;
    border-bottom: 1px solid var(--line);
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; color: var(--ink-900); }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--brand-50); }
.action-buttons { display: flex; gap: 8px; }

/* Stats (kept for compatibility) */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { background: var(--surface); color: var(--ink-900); padding: 20px; border-radius: var(--radius-lg); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.stat-card h4 { font-size: 12px; font-weight: 600; color: var(--ink-500); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; margin-bottom: 4px; }

/* ===================================
   Mobile app shell
   =================================== */
html { -webkit-text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; }

/* Notched phones / installed app: keep the top bar clear of the status bar */
.top-navbar {
    height: calc(var(--header-height) + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
}

.nav-toggle, .nav-backdrop, .drawer-head { display: none; }

.nav-toggle {
    width: 40px; height: 40px;
    margin-right: 2px;
    flex-shrink: 0;
    align-items: center; justify-content: center;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 10px;
    background: rgba(255, 255, 255, .1);
    color: #fff;
    cursor: pointer;
}
.nav-toggle svg { width: 22px; height: 22px; }
.nav-toggle:active { background: rgba(255, 255, 255, .22); }

@media (max-width: 1023px) {
    /* Sidebar becomes a slide-in drawer */
    .sidebar {
        width: min(300px, 86vw);
        transform: translateX(-105%);
        transition: transform .28s cubic-bezier(.2, .8, .2, 1), box-shadow .28s;
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        overflow-y: auto;
        overscroll-behavior: contain;
        z-index: 1200;
    }
    .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(15, 23, 42, .3); }
    .sidebar-header { height: 60px; }
    .sidebar-menu a { height: 46px; font-size: 15px; }
    .sidebar-menu a:hover { transform: none; }

    .drawer-head {
        display: flex; align-items: center; gap: 10px;
        padding: 14px 12px 14px 16px;
        border-bottom: 1px solid var(--line);
        background: var(--brand-50);
    }
    .drawer-user { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
    .drawer-avatar {
        width: 40px; height: 40px; flex-shrink: 0;
        border-radius: 10px; overflow: hidden;
        display: grid; place-items: center;
        background: linear-gradient(135deg, #42a5f5, #1e88e5 55%, #1565c0);
        color: #fff; font-weight: 700;
    }
    .drawer-avatar img { width: 100%; height: 100%; object-fit: cover; }
    .drawer-user-text { min-width: 0; }
    .drawer-name { font-weight: 700; font-size: 14px; color: var(--ink-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .drawer-sub { font-size: 12px; color: var(--ink-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .drawer-close {
        width: 38px; height: 38px; flex-shrink: 0;
        display: grid; place-items: center;
        border: 1px solid var(--line); border-radius: 10px;
        background: #fff; color: var(--ink-700); cursor: pointer;
    }
    .drawer-close svg { width: 18px; height: 18px; }

    .nav-backdrop {
        display: block;
        position: fixed; inset: 0;
        z-index: 1100;
        background: rgba(15, 23, 42, .45);
        opacity: 0; pointer-events: none;
        transition: opacity .25s;
    }
    body.drawer-open { overflow: hidden; }
    body.drawer-open .nav-backdrop { opacity: 1; pointer-events: auto; }

    .nav-toggle { display: inline-flex; }
    .main-content { margin-left: 0; }
    .top-navbar { justify-content: flex-start; }
    .navbar-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .navbar-date { display: none; }
    .user-info { display: none; }   /* name is shown at the top of the drawer */
}

@media (max-width: 640px) {
    :root { --header-height: 58px; }
    .top-navbar {
        gap: 10px;
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }
    .navbar-title { font-size: 16px; }
    .navbar-user { gap: 8px; }
    .navbar-user > a { padding: 0; }
    .user-info, .logout-btn { display: none; }   /* Logout lives in the drawer */
    .user-avatar { width: 36px; height: 36px; }

    .main-panel {
        padding: 12px max(12px, env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)) !important;
    }
    .page-header { margin-bottom: 14px; }
    .card { border-radius: 12px; }

    /* 16px stops iPhone Safari from zooming in when a field is tapped */
    input:not([type=checkbox]):not([type=radio]), select, textarea { font-size: 16px !important; }

    .stats-grid { grid-template-columns: 1fr; }
}

/* Installed app (home-screen icon): no text selection on chrome, native feel */
@media (display-mode: standalone) {
    .top-navbar, .sidebar-menu, .nav-toggle { -webkit-user-select: none; user-select: none; }
}

/* Larger touch targets on touch screens */
@media (pointer: coarse) {
    .btn { min-height: 42px; }
    .sidebar-menu a:hover { background: transparent; color: var(--ink-700); }
    .sidebar-menu a.active:hover { background: var(--brand-50); color: var(--brand-700); }
}

/* Utility classes */
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-10 { gap: 10px; }
.mb-3 { margin-bottom: 1rem; }
.mt-3 { margin-top: 1rem; }
.text-center { text-align: center; }
.fw-bold { font-weight: 700; }

.row { display: flex; flex-wrap: wrap; margin: 0 -10px; }
.col-md-6 { flex: 0 0 50%; padding: 0 10px; }
.col-md-12 { flex: 0 0 100%; padding: 0 10px; }
.col-lg-4 { flex: 0 0 33.333%; padding: 0 10px; }
@media (max-width: 768px) {
    .col-md-6, .col-lg-4 { flex: 0 0 100%; }
}

/* Sidebar footer */
.sidebar-footer {
    margin-top: auto;
    padding: 16px 20px;
    border-top: 1px solid var(--line);
    background: #fbfcfe;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.sidebar-version-divider { width: 100%; height: 1px; background: var(--line); }
.sidebar-version {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--brand-700);
    letter-spacing: .3px;
    background: var(--brand-50);
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--brand-100);
    font-variant-numeric: tabular-nums;
}
.sidebar-logo { max-width: 92px; height: auto; max-height: 44px; object-fit: contain; opacity: .75; transition: opacity var(--transition); }
.sidebar-logo:hover { opacity: 1; }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ink-300); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-400); background-clip: padding-box; }

::selection { background: rgba(21, 101, 192, .16); color: var(--ink-900); }
