/* ==========================================================================
   ai-books Portal UI Stylesheet (Customer Portal & Admin Console)
   Pure CSS3 with Zero External Dependencies
   Inherits design language from ai-books glassmorphic theme
   ========================================================================== */

:root {
    /* Palette & Elevation */
    --bg-base: #090a0f;
    --bg-surface: #0f111a;
    --bg-surface-elevated: #151824;
    --bg-card: rgba(21, 24, 38, 0.75);
    --bg-card-hover: rgba(30, 35, 55, 0.9);
    --bg-glass: rgba(15, 17, 26, 0.85);
    --bg-glass-modal: rgba(9, 10, 15, 0.88);

    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-medium: rgba(255, 255, 255, 0.16);
    --border-focus: #6366f1;
    --border-accent: rgba(99, 102, 241, 0.4);

    /* Typography */
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --text-dim: #475569;

    /* Accents */
    --accent-primary: #6366f1;
    --accent-secondary: #a855f7;
    --accent-cyan: #06b6d4;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #38bdf8 100%);
    --accent-glow: rgba(99, 102, 241, 0.3);

    /* Fonts */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-display: 'Outfit', sans-serif;
    --font-arabic: 'Amiri', 'Traditional Arabic', 'Scheherazade New', serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Metrics */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 22px;
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.45);
    --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    min-height: 100vh;
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --------------------------------------------------------------------------
   Layout Containers
   -------------------------------------------------------------------------- */
.portal-container {
    max-width: 1380px;
    margin: 0 auto;
    padding: 0 24px 64px 24px;
}

/* --------------------------------------------------------------------------
   Top Navigation Bar
   -------------------------------------------------------------------------- */
.portal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    margin-bottom: 24px;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.brand-icon {
    font-size: 24px;
    line-height: 1;
}

.brand-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-badge {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    font-size: 0.85rem;
}

.user-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-emerald);
    box-shadow: 0 0 8px var(--accent-emerald);
}

/* --------------------------------------------------------------------------
   Zero Trust Banner (Admin)
   -------------------------------------------------------------------------- */
.zt-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 20px;
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.12) 0%, rgba(168, 85, 247, 0.08) 100%);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    font-size: 0.88rem;
}

.zt-banner-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.zt-shield-icon {
    font-size: 1.1rem;
}

.zt-banner-link {
    color: #a5b4fc;
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-fast);
}

.zt-banner-link:hover {
    color: #ffffff;
    text-decoration: underline;
}

/* --------------------------------------------------------------------------
   Buttons & Inputs
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 9px 18px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    line-height: 1;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent-primary);
    color: #ffffff;
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
    background: #4f46e5;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
    background: var(--bg-surface-elevated);
    color: var(--text-secondary);
    border-color: var(--border-medium);
}

.btn-secondary:hover {
    background: rgba(45, 52, 75, 0.8);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.25);
}

.btn-success {
    background: var(--accent-emerald);
    color: #ffffff;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--accent-rose);
    color: #ffffff;
}

.btn-danger:hover {
    background: #e11d48;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.input-text, .input-select, .input-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-text:focus, .input-select:focus, .input-textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.input-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   Cards & Glass Panels
   -------------------------------------------------------------------------- */
.glass-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 24px;
    margin-bottom: 24px;
}

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

.panel-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.panel-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* --------------------------------------------------------------------------
   Search Bar (Customer)
   -------------------------------------------------------------------------- */
.customer-search-section {
    text-align: center;
    max-width: 820px;
    margin: 40px auto 48px auto;
}

.search-headline {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 12px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.search-subheadline {
    color: var(--text-secondary);
    font-size: 1.05rem;
    margin-bottom: 28px;
}

.customer-search-bar {
    display: flex;
    align-items: center;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-xl);
    padding: 6px 8px 6px 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.customer-search-bar:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 12px 36px rgba(99, 102, 241, 0.3);
}

.customer-search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-family: inherit;
    padding: 8px 12px;
}

.customer-search-input:focus {
    outline: none;
}

/* --------------------------------------------------------------------------
   Quotes Grid (Customer)
   -------------------------------------------------------------------------- */
.quotes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 24px;
    margin-top: 24px;
}

.quote-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-card);
    transition: transform var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base);
}

.quote-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-accent);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5), var(--shadow-glow);
}

.quote-cover-wrapper {
    height: 220px;
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    border-bottom: 1px solid var(--border-subtle);
}

.quote-cover-img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    transition: transform var(--transition-base);
}

.quote-card:hover .quote-cover-img {
    transform: scale(1.03);
}

.quote-cover-placeholder {
    font-size: 3rem;
    opacity: 0.4;
}

.quote-card-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.quote-title-arabic {
    font-family: var(--font-arabic);
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1.4;
    direction: rtl;
    text-align: right;
    color: #f1f5f9;
    margin-bottom: 8px;
}

.quote-title-latin {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.quote-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.quote-meta-pill {
    padding: 2px 8px;
    background: var(--bg-surface-elevated);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.quote-pricing-box {
    margin-top: auto;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pricing-line {
    display: flex;
    justify-content: space-between;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.pricing-total-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
    border-top: 1px solid var(--border-subtle);
    padding-top: 8px;
}

.quote-eta-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.1);
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(56, 189, 248, 0.25);
    margin-top: 12px;
}

.quote-stock-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 999px;
}

.stock-in {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.stock-out {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* --------------------------------------------------------------------------
   Zelle Instructions & Order Status
   -------------------------------------------------------------------------- */
.zelle-instruction-card {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(16, 185, 129, 0.08) 100%);
    border: 1px solid rgba(99, 102, 241, 0.35);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-top: 20px;
}

.zelle-field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.zelle-field-row:last-child {
    border-bottom: none;
}

.memo-code-badge {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: #a5b4fc;
    background: rgba(99, 102, 241, 0.2);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(99, 102, 241, 0.4);
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.copy-btn {
    background: transparent;
    border: none;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px;
    border-radius: 4px;
    transition: color var(--transition-fast);
}

.copy-btn:hover {
    color: #ffffff;
}

/* Gates meter */
.gate-meter-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 20px 0;
}

.gate-box {
    padding: 16px;
    border-radius: var(--radius-md);
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.gate-box.met {
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.08);
}

.gate-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.gate-status-text {
    font-size: 1rem;
    font-weight: 700;
}

.gate-box.met .gate-status-text {
    color: #34d399;
}

.gate-box.pending .gate-status-text {
    color: #fbbf24;
}

/* --------------------------------------------------------------------------
   Timeline (Notifications)
   -------------------------------------------------------------------------- */
.notification-timeline {
    list-style: none;
    position: relative;
    padding-left: 28px;
    margin-top: 16px;
}

.notification-timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--border-medium);
}

.timeline-item {
    position: relative;
    margin-bottom: 18px;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-dot {
    position: absolute;
    left: -28px;
    top: 4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-primary);
    border: 3px solid var(--bg-base);
}

.timeline-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.timeline-msg {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-top: 2px;
}

/* --------------------------------------------------------------------------
   Admin Dashboard & Tabs
   -------------------------------------------------------------------------- */
.admin-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 24px;
    overflow-x: auto;
}

.admin-tab-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 12px 18px;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.admin-tab-btn:hover {
    color: var(--text-primary);
}

.admin-tab-btn.active {
    color: #ffffff;
    border-bottom-color: var(--accent-primary);
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* KPI metric cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.kpi-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-value {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    color: #ffffff;
}

/* Admin Data Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.admin-table th {
    background: var(--bg-surface-elevated);
    padding: 12px 16px;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-medium);
    white-space: nowrap;
}

.admin-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: middle;
}

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

.admin-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.font-mono {
    font-family: var(--font-mono);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
}

.badge-risk {
    background: rgba(244, 63, 94, 0.15);
    color: #fda4af;
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.badge-safe {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-review {
    background: rgba(245, 158, 11, 0.15);
    color: #fde68a;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* --------------------------------------------------------------------------
   Modal Backdrop & Modal Dialog
   -------------------------------------------------------------------------- */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-glass-modal);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.modal-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-dialog {
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px;
    position: relative;
    transform: translateY(20px);
    transition: transform var(--transition-base);
}

.modal-backdrop.show .modal-dialog {
    transform: translateY(0);
}

.modal-dialog-large {
    max-width: 880px;
}

.modal-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    line-height: 1;
}

.modal-close-btn:hover {
    color: var(--text-primary);
}

.modal-title {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 8px;
}

/* Snapshot code pre block */
.snapshot-code-block {
    background: var(--bg-base);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: #e2e8f0;
    max-height: 400px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* --------------------------------------------------------------------------
   Helpers & Utility Classes
   -------------------------------------------------------------------------- */
.hidden {
    display: none !important;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--text-muted);
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
