﻿/* ══════════════════════════════════════════════════════════════
   carrier-dashboard.css
   Design system: Plus Jakarta Sans · same tokens as Jobs/Employees
   ══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ── Tokens ── */
:root {
    --f: 'Plus Jakarta Sans', sans-serif;
    --ink: #0d1117;
    --ink-1: #0d1117;
    --ink-2: #374151;
    --ink-3: #6b7280;
    --ink-4: #9ca3af;
    --border: #e5e7eb;
    --border-2: #f3f4f6;
    --surface: #ffffff;
    --bg: #f9fafb;
    --carrier: #0f766e;
    --carrier-mid: #14b8a6;
    --carrier-light: #f0fdfa;
    --carrier-border: #99f6e4;
    --blue: #2563eb;
    --blue-light: #eff6ff;
    --blue-border: #bfdbfe;
    --green: #16a34a;
    --green-light: #f0fdf4;
    --green-border: #bbf7d0;
    --amber: #d97706;
    --amber-light: #fffbeb;
    --amber-border: #fde68a;
    --red: #dc2626;
    --red-light: #fef2f2;
    --red-border: #fecaca;
    --indigo: #4f46e5;
    --indigo-light: #eef2ff;
    --indigo-border: #c7d2fe;
}

/* ── Page shell ── */
.page-container {
    font-family: var(--f);
    background: var(--bg);
    min-height: 100vh;
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

/* ══════════════════════════════════════════════════════════════
   CONNECTION STATUS BAR
   ══════════════════════════════════════════════════════════════ */
.connection-status {
    position: fixed;
    top: 62px; /* just below the navbar */
    right: 1.25rem;
    z-index: 900;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.connection-badge {
    font-family: var(--f) !important;
    font-size: 0.68rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.3px;
    padding: 4px 10px !important;
    border-radius: 20px !important;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* ══════════════════════════════════════════════════════════════
   PAGE HEADER  (the entire top command area)
   ══════════════════════════════════════════════════════════════ */
.page-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

/* ── Top row: title + action buttons ── */
.page-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 2rem;
    min-height: 76px;
    flex-wrap: wrap;
}

/* title block */
.page-title {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    font-size: 1.22rem;
    font-weight: 800;
    color: var(--ink);
    margin: 0;
    letter-spacing: -0.4px;
    line-height: 1.2;
}

.page-title-icon {
    width: 42px;
    height: 42px;
    background: var(--carrier-light);
    border: 1px solid var(--carrier-border);
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

    .page-title-icon i {
        font-size: 1rem;
        color: var(--carrier);
    }

.page-subtitle {
    font-size: 0.76rem;
    color: var(--ink-4);
    margin: 3px 0 0 52px; /* indent to align with title text */
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ── Carrier identity strip ── */
.carrier-identity-strip {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0 2rem;
    background: var(--bg);
    border-top: 1px solid var(--border-2);
    overflow-x: auto;
    scrollbar-width: none;
    min-height: 56px;
}

    .carrier-identity-strip::-webkit-scrollbar {
        display: none;
    }

.cid-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 1.1rem;
    border-right: 1px solid var(--border-2);
    flex-shrink: 0;
    min-width: 0;
}

    .cid-item:first-child {
        padding-left: 0;
    }

.cid-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

    .cid-icon i {
        font-size: 0.72rem;
        color: white;
    }

.cid-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--ink-4);
    margin-bottom: 1px;
    line-height: 1;
}

.cid-value {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--ink);
    line-height: 1.1;
    letter-spacing: -0.3px;
}

    .cid-value.normal {
        font-size: 0.82rem;
        font-weight: 600;
        letter-spacing: 0;
    }

/* ══════════════════════════════════════════════════════════════
   CARRIER SELECTOR (admin view)
   ══════════════════════════════════════════════════════════════ */
.carrier-selector-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin: 1.5rem 2rem 0;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
    flex-wrap: wrap;
}

.selector-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex-shrink: 0;
}

.selector-icon {
    width: 38px;
    height: 38px;
    background: var(--carrier-light);
    border: 1px solid var(--carrier-border);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

    .selector-icon i {
        font-size: 0.9rem;
        color: var(--carrier);
    }

.selector-title {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--ink);
    margin: 0 0 2px;
    letter-spacing: -0.2px;
}

.selector-subtitle {
    font-size: 0.72rem;
    color: var(--ink-4);
    margin: 0;
}

/* ══════════════════════════════════════════════════════════════
   STATS ROW
   ══════════════════════════════════════════════════════════════ */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
    padding: 1.5rem 2rem 0;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.14s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

    .stat-card::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 3px;
        background: var(--stat-accent, var(--carrier));
        border-radius: 12px 12px 0 0;
    }

    .stat-card:hover {
        box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    }

.stat-icon-wrap {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    margin-bottom: 0.15rem;
    flex-shrink: 0;
}

.stat-number {
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--ink);
    line-height: 1;
    letter-spacing: -0.6px;
}

.stat-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--ink-4);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ══════════════════════════════════════════════════════════════
   DASHBOARD GRID
   ══════════════════════════════════════════════════════════════ */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr) 260px;
    gap: 0.75rem;
    padding: 1rem 2rem;
    align-items: start;
}

.dash-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
    display: flex;
    flex-direction: column;
}

.dash-card-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.9rem 1.1rem;
    border-bottom: 1px solid var(--border-2);
    background: var(--bg);
}

.dch-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

    .dch-icon i {
        font-size: 0.82rem;
        color: white;
    }

.dch-title {
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--ink);
    line-height: 1.2;
}

.dch-sub {
    font-size: 0.68rem;
    color: var(--ink-4);
    margin-top: 1px;
}

.dash-card-body {
    padding: 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    flex: 1;
}

/* ── Fleet card visuals ── */
.fleet-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--carrier-light);
    border: 1px solid var(--carrier-border);
    border-radius: 10px;
    padding: 0.85rem 1rem;
}

.fh-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--carrier);
    line-height: 1;
    letter-spacing: -0.8px;
}

.fh-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--carrier);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.fh-sub {
    font-size: 0.72rem;
    color: var(--ink-4);
    margin-top: 3px;
}

/* mini bar chart */
.mini-bar-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.mini-bar-row {
    display: grid;
    grid-template-columns: 80px 1fr 28px;
    align-items: center;
    gap: 0.5rem;
}

.mini-bar-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--ink-3);
}

.mini-bar-track {
    height: 6px;
    background: var(--border-2);
    border-radius: 3px;
    overflow: hidden;
}

.mini-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

.mini-bar-val {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--ink-2);
    text-align: right;
}

/* perf score ring */
.perf-score {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0;
}

.perf-ring {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 800;
    flex-shrink: 0;
}

.perf-label {
    font-size: 0.77rem;
    font-weight: 700;
    color: var(--ink-2);
}

.perf-sub {
    font-size: 0.68rem;
    margin-top: 1px;
}

/* data rows inside cards */
.dc-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border-2);
}

    .dc-row:last-child {
        border-bottom: none;
    }

.dc-row-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.dc-row-icon {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    flex-shrink: 0;
}

.dc-label {
    font-size: 0.76rem;
    font-weight: 500;
    color: var(--ink-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dc-value {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--ink);
    flex-shrink: 0;
}

    .dc-value.teal {
        color: var(--carrier);
    }

    .dc-value.amber {
        color: var(--amber);
    }

    .dc-value.mono {
        font-family: 'JetBrains Mono', monospace;
        font-size: 0.72rem;
    }

/* alert banner */
.alert-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    font-size: 0.75rem;
}

    .alert-banner.amber {
        background: var(--amber-light);
        border: 1px solid var(--amber-border);
    }

.alert-banner-text {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
}

/* balance hero */
.balance-hero {
    background: linear-gradient(135deg, #1e1b4b, #312e81);
    border-radius: 10px;
    padding: 1rem 1.1rem;
    color: white;
    margin-bottom: 0.25rem;
}

.balance-hero-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: rgba(255,255,255,0.6);
    margin-bottom: 4px;
}

.balance-hero-amount {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.balance-hero-held {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.5);
    margin-top: 6px;
}

/* ══════════════════════════════════════════════════════════════
   DRIVERS LIST
   ══════════════════════════════════════════════════════════════ */
.list-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin: 0 2rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
}

.list-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--border-2);
    background: var(--bg);
}

.list-card-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--ink-2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.driver-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.8rem 1.25rem;
    border-bottom: 1px solid var(--border-2);
    transition: background 0.12s;
}

    .driver-item:last-child {
        border-bottom: none;
    }

    .driver-item:hover {
        background: #f8faff;
    }

.driver-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--carrier-light);
    border: 1px solid var(--carrier-border);
    color: var(--carrier);
    font-size: 0.68rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    letter-spacing: 0.3px;
}

.driver-info {
    flex: 1;
    min-width: 0;
}

.driver-name {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.3;
}

.driver-details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.72rem;
    color: var(--ink-4);
    margin-top: 2px;
}

    .driver-details i {
        font-size: 0.6rem;
    }

/* ══════════════════════════════════════════════════════════════
   TRANSACTIONS
   ══════════════════════════════════════════════════════════════ */
.transactions-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin: 0.75rem 2rem 2rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
}

.transactions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--border-2);
    background: var(--bg);
}

.transactions-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--ink-2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.transaction-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1.25rem;
    border-bottom: 1px solid var(--border-2);
    gap: 1rem;
    transition: background 0.12s;
}

    .transaction-item:last-child {
        border-bottom: none;
    }

    .transaction-item:hover {
        background: #f8faff;
    }

.transaction-info {
    flex: 1;
    min-width: 0;
}

.transaction-type {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--ink);
}

.transaction-date {
    font-size: 0.7rem;
    color: var(--ink-4);
    margin-top: 2px;
}

.transaction-amount {
    font-size: 0.88rem;
    font-weight: 800;
    letter-spacing: -0.3px;
    font-variant-numeric: tabular-nums;
}

.amount-credit {
    color: var(--green);
}

.amount-debit {
    color: var(--red);
}

/* ══════════════════════════════════════════════════════════════
   PILLS / BADGES
   ══════════════════════════════════════════════════════════════ */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 20px;
    letter-spacing: 0.2px;
    font-family: var(--f);
    white-space: nowrap;
}

    .pill i {
        font-size: 0.5rem;
    }

.pill-green {
    background: var(--green-light);
    color: var(--green);
    border: 1px solid var(--green-border);
}

.pill-amber {
    background: var(--amber-light);
    color: var(--amber);
    border: 1px solid var(--amber-border);
}

.pill-red {
    background: var(--red-light);
    color: var(--red);
    border: 1px solid var(--red-border);
}

.pill-blue {
    background: var(--blue-light);
    color: var(--blue);
    border: 1px solid var(--blue-border);
}

.pill-indigo {
    background: var(--indigo-light);
    color: var(--indigo);
    border: 1px solid var(--indigo-border);
}

.pill-teal {
    background: var(--carrier-light);
    color: var(--carrier);
    border: 1px solid var(--carrier-border);
}

.pill-gray {
    background: var(--bg);
    color: var(--ink-4);
    border: 1px solid var(--border);
}

/* ══════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════ */
.btn-base {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    border-radius: 8px;
    font-size: 0.79rem;
    font-weight: 600;
    font-family: var(--f);
    border: none;
    cursor: pointer;
    transition: all 0.14s;
    letter-spacing: -0.1px;
    line-height: 1;
    text-decoration: none;
}

    .btn-base i {
        font-size: 0.7rem;
    }

    .btn-base.btn-sm {
        padding: 0.35rem 0.8rem;
        font-size: 0.74rem;
    }

    .btn-base.w-100 {
        width: 100%;
        justify-content: center;
    }

.btn-carrier {
    background: var(--carrier);
    color: white;
    box-shadow: 0 1px 3px rgba(15,118,110,0.3), 0 4px 12px rgba(15,118,110,0.2);
}

    .btn-carrier:hover:not(:disabled) {
        background: #0d6460;
        transform: translateY(-1px);
        box-shadow: 0 2px 6px rgba(15,118,110,0.4), 0 6px 16px rgba(15,118,110,0.25);
    }

.btn-ghost {
    background: var(--surface);
    color: var(--ink-2);
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

    .btn-ghost:hover:not(:disabled) {
        background: var(--bg);
        border-color: #d1d5db;
        color: var(--ink);
    }

.btn-base:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ══════════════════════════════════════════════════════════════
   LOADING STATES
   ══════════════════════════════════════════════════════════════ */
.loading-container-inline {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5rem 2rem;
    gap: 1.25rem;
}

.loading-spinner {
    display: flex;
    gap: 6px;
}

    .loading-spinner span {
        width: 10px;
        height: 10px;
        background: var(--carrier);
        border-radius: 50%;
        animation: cd-bounce 1.2s ease-in-out infinite;
        opacity: 0.6;
    }

        .loading-spinner span:nth-child(2) {
            animation-delay: 0.2s;
        }

        .loading-spinner span:nth-child(3) {
            animation-delay: 0.4s;
        }

@keyframes cd-bounce {
    0%, 80%, 100% {
        transform: scale(0.7);
        opacity: 0.4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.loading-text {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ink-4);
}

/* ══════════════════════════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════════════════════════ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    gap: 0.5rem;
    text-align: center;
}

.empty-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--ink-4);
    margin-bottom: 0.25rem;
}

/* ── Animations ── */
.fade-in-up {
    animation: cd-fadeup 0.3s ease-out both;
}

@keyframes cd-fadeup {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }

        .dashboard-grid > div:last-child {
            grid-column: 1 / -1;
        }
}

@media (max-width: 900px) {
    .page-header-inner, .carrier-selector-section {
        padding: 0.85rem 1rem;
    }

    .carrier-identity-strip {
        padding: 0 1rem;
    }

    .stats-container {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        padding: 1rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        padding: 0.75rem 1rem;
    }

    .list-card, .transactions-card {
        margin: 0.75rem 1rem;
    }
}

@media (max-width: 600px) {
    .page-title {
        font-size: 1rem;
    }

    .stats-container {
        grid-template-columns: repeat(2, 1fr);
        padding: 0.75rem;
        gap: 0.5rem;
    }

    .cid-item {
        padding: 0.5rem 0.7rem;
    }
}
