/* ==========================================================================
   Almond Global Customer Portal — main.css
   Approved style spec v5. Light mode default, dark mode via body.dark-mode.
   Font: Inter (loaded in base.html via Google Fonts)
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Variables
   -------------------------------------------------------------------------- */
:root {
    --ag-blue:          #1a4fd4;
    --ag-blue-dark:     #1255a8;
    --ag-blue-light:    #e8f0fb;
    --ag-red:           #cc2222;
    --ag-red-light:     #fbeaea;
    --ag-green:         #16a34a;
    --ag-amber:         #d97706;

    /* Layout */
    --sidebar-width:    220px;
    --topbar-height:    52px;
    --topbar-bg:        #1e3048;

    /* Light mode tokens */
    --page-bg:          #f0f2f5;
    --card-bg:          #ffffff;
    --sidebar-bg:       #ffffff;
    --text-primary:     #1a1a1a;
    --text-muted:       #6b7280;
    --border:           #e2e8f0;
    --input-bg:         #ffffff;
    --entry-bg:         #ffffff;
    --nav-hover-bg:     #e8f0fb;
    --nav-hover-text:   #1a4fd4;
}

body.dark-mode {
    --page-bg:          #090909;
    --card-bg:          #111820;
    --sidebar-bg:       #0d1520;
    --text-primary:     #b8d4a0;
    --text-muted:       #a0aebd;
    --border:           #243040;
    --input-bg:         #1a2535;
    --entry-bg:         #1a2535;
    --nav-hover-bg:     #1a2535;
    --nav-hover-text:   #6a9fd4;
}

/* --------------------------------------------------------------------------
   Reset & Base
   -------------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    font-size: 14px;
    background: var(--page-bg);
    color: var(--text-primary);
    transition: background 0.2s, color 0.2s;
}

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

/* --------------------------------------------------------------------------
   Login Page
   -------------------------------------------------------------------------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--page-bg);
    padding: 32px 16px;
}

.login-card {
    background: var(--card-bg);
    border: 0.5px solid var(--border);
    border-radius: 12px;
    padding: 44px 40px;
    width: 400px;
    max-width: 100%;
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    margin-bottom: 32px;
}

.login-logo-box {
    width: 48px;
    height: 48px;
    background: #111;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: #fff;
    flex-shrink: 0;
}

.login-logo-name {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
}

.login-logo-sub {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.login-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 6px;
}

.login-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: var(--input-bg);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s;
}

.form-input:focus {
    border-color: var(--ag-blue);
}

.btn-primary {
    width: 100%;
    padding: 11px;
    background: var(--ag-blue);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    margin-top: 4px;
    transition: background 0.15s;
}

.btn-primary:hover {
    background: var(--ag-blue-dark);
}

.login-footer {
    text-align: center;
    margin-top: 22px;
    font-size: 12px;
    color: var(--text-muted);
}

.alert-error {
    background: var(--ag-red-light);
    color: var(--ag-red);
    border: 1px solid #f5c6c6;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 18px;
    text-align: center;
}

/* --------------------------------------------------------------------------
   App Shell — Sidebar + Main
   -------------------------------------------------------------------------- */
.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
    max-width: 1800px;
    margin: 0 auto;
    width: 100%;
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 0.5px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: background 0.2s, border-color 0.2s;
}

.sidebar-header {
    padding: 16px 16px 14px;
    border-bottom: 0.5px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.sidebar-logo-box {
    width: 34px;
    height: 34px;
    background: #111;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-logo-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.sidebar-logo-tag {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 2px;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.nav-item i {
    font-size: 17px;
    flex-shrink: 0;
}

.nav-item:hover {
    background: var(--nav-hover-bg);
    color: var(--nav-hover-text);
    text-decoration: none;
}

.nav-item.active {
    background: var(--ag-blue);
    color: #fff;
}

.nav-item.active:hover {
    background: var(--ag-blue-dark);
    color: #fff;
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 0.5px solid var(--border);
    flex-shrink: 0;
}

.sidebar-footer-text {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ag-green);
    flex-shrink: 0;
}

.sidebar-support {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.sidebar-support a {
    color: var(--ag-blue);
}

/* Dark mode toggle */
.dark-mode-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    padding: 4px 0;
}

.toggle-track {
    width: 34px;
    height: 18px;
    border-radius: 9px;
    background: #9ca3af;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.1);
}

body.dark-mode .toggle-track {
    background: var(--ag-blue);
    border-color: var(--ag-blue-dark);
}

.toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    transition: left 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

body.dark-mode .toggle-thumb {
    left: 18px;
}

/* --------------------------------------------------------------------------
   Main Area
   -------------------------------------------------------------------------- */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* --------------------------------------------------------------------------
   Topbar
   -------------------------------------------------------------------------- */
.topbar {
    background: var(--topbar-bg);
    height: var(--topbar-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.topbar-left .topbar-title {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
}

.topbar-left .topbar-sub {
    font-size: 11px;
    color: #7a9fc0;
    white-space: nowrap;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-icon {
    color: #7a9fc0;
    font-size: 20px;
    cursor: pointer;
    transition: color 0.15s;
    text-decoration: none;
}

.topbar-icon:hover {
    color: #fff;
}

.topbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--ag-blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.topbar-user-name {
    font-size: 13px;
    color: #fff;
    font-weight: 500;
    white-space: nowrap;
}

.topbar-user-co {
    font-size: 11px;
    color: #7a9fc0;
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Page Content
   -------------------------------------------------------------------------- */
.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 18px 20px;
    background: var(--page-bg);
}

/* --------------------------------------------------------------------------
   Summary Cards Row
   -------------------------------------------------------------------------- */
.summary-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.summary-card {
    background: var(--card-bg);
    border: 0.5px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    text-align: center;
}

.summary-card .sc-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
    white-space: nowrap;
}

.summary-card .sc-value {
    font-size: 26px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 6px;
}

.summary-card .sc-delta {
    font-size: 11px;
    white-space: nowrap;
}

.sc-delta.up   { color: var(--ag-green); }
.sc-delta.down { color: var(--ag-red); }
.sc-delta.neutral { color: var(--text-muted); }

/* Balance card state variants */
.balance-card-healthy {
    background: var(--ag-blue);
    border-color: var(--ag-blue);
}
.balance-card-healthy .sc-label,
.balance-card-healthy .sc-value,
.balance-card-healthy .sc-delta { color: #fff; }
.balance-card-healthy .sc-delta a { color: rgba(255,255,255,0.85) !important; }

.balance-card-low {
    background: #7a2d00;
    border-color: #7a2d00;
}
.balance-card-low .sc-label { color: #fde8d0; }
.balance-card-low .sc-value { color: #fbbf24; }

.balance-card-zero {
    background: #5a0000;
    border-color: #5a0000;
}
.balance-card-zero .sc-label { color: #fdd; }
.balance-card-zero .sc-value { color: #fca5a5; }

/* Top-up links inside balance card */
.topup-link-white {
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    text-decoration: underline;
}
.topup-link-white:hover { opacity: 0.8; text-decoration: underline; }

.topup-link-yellow {
    color: #fbbf24;
    font-size: 11px;
    font-weight: 600;
    text-decoration: underline;
}
.topup-link-yellow:hover { opacity: 0.8; text-decoration: underline; }

.topup-link-red {
    color: #fca5a5;
    font-size: 11px;
    font-weight: 600;
    text-decoration: underline;
}
.topup-link-red:hover { opacity: 0.8; text-decoration: underline; }


.balance-banner {
    border-radius: 8px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 16px;
}

.balance-banner.healthy { background: var(--ag-blue); color: #fff; }
.balance-banner.low     { background: #7a2d00;        color: #fff; }
.balance-banner.zero    { background: #5a0000;        color: #fff; }

.bal-label {
    font-size: 11px;
    opacity: 0.85;
    margin-bottom: 3px;
}

.bal-amount {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
}

.balance-banner.low  .bal-amount { color: #fbbf24; }
.balance-banner.zero .bal-amount { color: #fca5a5; }

.bal-alert-text {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
}

.bal-note {
    font-size: 11px;
    opacity: 0.85;
    margin-bottom: 10px;
}

.btn-topup {
    border: none;
    padding: 9px 20px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.15s;
}

.btn-topup:hover { opacity: 0.9; }

.balance-banner.healthy .btn-topup { background: var(--ag-red);  color: #fff; }
.balance-banner.low     .btn-topup { background: #fbbf24; color: #7a2d00; }
.balance-banner.zero    .btn-topup { background: var(--ag-red);  color: #fff; }

/* --------------------------------------------------------------------------
   Two-column Dashboard Panels
   -------------------------------------------------------------------------- */
.dashboard-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* --------------------------------------------------------------------------
   Panel (card container)
   -------------------------------------------------------------------------- */
.panel {
    background: var(--card-bg);
    border: 0.5px solid var(--border);
    border-radius: 8px;
    padding: 16px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.panel-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.panel-link {
    font-size: 12px;
    color: var(--ag-blue);
    white-space: nowrap;
}

.panel-link:hover {
    text-decoration: underline;
}

/* --------------------------------------------------------------------------
   Data Tables
   -------------------------------------------------------------------------- */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 6px 10px;
    text-align: left;
    border-bottom: 0.5px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 8px 10px;
    font-size: 13px;
    color: var(--text-primary);
    border-bottom: 0.5px solid var(--border);
    white-space: nowrap;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: var(--nav-hover-bg);
}

/* Compact variant for dashboard panels */
.data-table.compact th { padding: 5px 8px; }
.data-table.compact td { padding: 6px 8px; font-size: 12px; }

/* --------------------------------------------------------------------------
   Badges / Status Pills
   -------------------------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-blue     { background: var(--ag-blue-light); color: var(--ag-blue); }
.badge-green    { background: #dcfce7; color: #166534; }
.badge-orange   { background: #fef3c7; color: #92400e; }
.badge-red      { background: var(--ag-red-light);  color: var(--ag-red); }
.badge-gray     { background: #f3f4f6; color: #6b7280; }

body.dark-mode .badge-green  { background: #14532d; color: #86efac; }
body.dark-mode .badge-orange { background: #422006; color: #fcd34d; }
body.dark-mode .badge-gray   { background: #1f2937; color: #9ca3af; }

/* --------------------------------------------------------------------------
   Full Pane — Orders / Invoices / Shipments / Inventory
   -------------------------------------------------------------------------- */
.pane-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 180px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: var(--input-bg);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s;
}

.search-input:focus {
    border-color: var(--ag-blue);
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: var(--input-bg);
    color: var(--text-primary);
    outline: none;
    cursor: pointer;
}

/* --------------------------------------------------------------------------
   Top-Up Modal
   -------------------------------------------------------------------------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal-backdrop.hidden {
    display: none;
}

.modal-card {
    background: var(--card-bg);
    border: 0.5px solid var(--border);
    border-radius: 12px;
    padding: 32px;
    width: 440px;
    max-width: 100%;
}

.modal-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.modal-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 22px;
}

.modal-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 0.5px solid var(--border);
    font-size: 13px;
}

.modal-detail-row:last-of-type {
    border-bottom: none;
}

.modal-detail-label {
    color: var(--text-muted);
    font-size: 12px;
}

.modal-detail-value {
    color: var(--text-primary);
    font-weight: 500;
}

.modal-note {
    margin-top: 18px;
    padding: 12px 14px;
    background: var(--ag-blue-light);
    border-radius: 6px;
    font-size: 12px;
    color: var(--ag-blue);
    line-height: 1.5;
}

body.dark-mode .modal-note {
    background: #1a2d4a;
    color: #6a9fd4;
}

.modal-close {
    display: block;
    width: 100%;
    margin-top: 20px;
    padding: 10px;
    background: var(--ag-blue);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.modal-close:hover {
    background: var(--ag-blue-dark);
}

/* --------------------------------------------------------------------------
   Utility
   -------------------------------------------------------------------------- */
.text-muted  { color: var(--text-muted); }
.text-right  { text-align: right; }
.mt-4        { margin-top: 4px; }
.mt-8        { margin-top: 8px; }
.mt-16       { margin-top: 16px; }
.fw-600      { font-weight: 600; }
.fs-12       { font-size: 12px; }
.fs-13       { font-size: 13px; }
