/* ================================================================
   polyARB Design System — custom.css
   Color palette derived from polyarb_deployment_plan.html
   Must override Bootstrap 5.3 dark theme defaults
   ================================================================ */

/* ---- Google Fonts loaded in base.html ---- */
/* <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;700&family=Space+Grotesk:wght@400;500;700&display=swap" rel="stylesheet"> */

/* ================================================================
   CSS VARIABLES
   ================================================================ */
:root {
    --pa-bg-page: #f8fafc;
    --pa-bg-card: #ffffff;
    --pa-bg-card-hover: #f1f5f9;
    --pa-text: #111827;
    --pa-text-secondary: #6b7280;
    --pa-text-muted: #9ca3af;
    --pa-border: #e5e7eb;
    --pa-accent: #10b981;
    --pa-accent-hover: #059669;
    --pa-danger: #ef4444;
    --pa-warning: #f59e0b;
    --pa-purple: #8b5cf6;
    --pa-rally: #10b981;
    --pa-drop: #f59e0b;
    --pa-endgame: #8b5cf6;
    --pa-font-heading: 'Space Grotesk', system-ui, sans-serif;
    --pa-font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --chart-grid-color: #e5e7eb;
    --chart-text-color: #374151;
}

[data-bs-theme="dark"] {
    --pa-bg-page: #030712;
    --pa-bg-card: #111827;
    --pa-bg-card-hover: #1f2937;
    --pa-text: #f3f4f6;
    --pa-text-secondary: #9ca3af;
    --pa-text-muted: #6b7280;
    --pa-border: #1f2937;
    --chart-grid-color: #1f2937;
    --chart-text-color: #9ca3af;

    /* Override Bootstrap's own dark theme variables */
    --bs-body-bg: #030712 !important;
    --bs-body-color: #f3f4f6 !important;
    --bs-border-color: #1f2937 !important;
    --bs-secondary-bg: #111827 !important;
    --bs-tertiary-bg: #1f2937 !important;
    --bs-emphasis-color: #f3f4f6 !important;
    --bs-secondary-color: #9ca3af !important;

    /* Legacy variables used by existing templates */
    --bg-card: #111827;
    --text-primary: #f3f4f6;
    --border-color: #1f2937;
    --badge-bg-light: #1f2937;
    --badge-text-light: #f3f4f6;
    --table-bg-light: #111827;
    --table-border-light: #1f2937;
}

/* ================================================================
   GLOBAL TYPOGRAPHY & BODY
   ================================================================ */
body {
    font-family: var(--pa-font-mono) !important;
    font-size: 14px;
    background-color: var(--pa-bg-page);
    color: var(--pa-text);
}

[data-bs-theme="dark"] body {
    background-color: #030712 !important;
    color: #f3f4f6 !important;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6,
.navbar-brand,
.breadcrumb {
    font-family: var(--pa-font-heading) !important;
    font-weight: 700;
}
.table td, .table th,
.badge,
code, pre,
.font-monospace {
    font-family: var(--pa-font-mono) !important;
}

/* ================================================================
   NAVBAR
   ================================================================ */
.navbar {
    border-bottom: 1px solid var(--pa-border);
}

[data-bs-theme="dark"] .navbar,
[data-bs-theme="dark"] .navbar.bg-dark,
[data-bs-theme="dark"] .navbar.navbar-dark {
    background-color: #030712 !important;
    border-bottom-color: #1f2937 !important;
}

.navbar-brand {
    font-family: var(--pa-font-heading) !important;
    font-weight: 700 !important;
    font-size: 1.4rem !important;
    letter-spacing: -0.5px;
}

[data-bs-theme="dark"] .nav-link {
    color: #9ca3af !important;
}
[data-bs-theme="dark"] .nav-link:hover,
[data-bs-theme="dark"] .nav-link.active {
    color: #f3f4f6 !important;
}

/* ================================================================
   CARDS
   ================================================================ */
.card {
    background-color: var(--pa-bg-card);
    color: var(--pa-text);
    border-color: var(--pa-border);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

[data-bs-theme="dark"] .card {
    background-color: #111827 !important;
    border-color: #1f2937 !important;
    color: #f3f4f6 !important;
}

[data-bs-theme="dark"] .card-header {
    background-color: #0d1117 !important;
    border-bottom-color: #1f2937 !important;
    color: #f3f4f6 !important;
}

[data-bs-theme="dark"] .card-footer {
    background-color: #0d1117 !important;
    border-top-color: #1f2937 !important;
}

.card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

[data-bs-theme="dark"] .card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* Section cards used on deployment, privacy, wallets pages */
[data-bs-theme="dark"] .section-card {
    background-color: #111827 !important;
    border: 1px solid #1f2937 !important;
    border-radius: 0.75rem !important;
    padding: 1.5rem !important;
    margin-bottom: 1.5rem !important;
    color: #f3f4f6 !important;
}
[data-bs-theme="dark"] .section-card > h6:first-child {
    margin-bottom: 1rem !important;
}

/* ================================================================
   TABLES
   ================================================================ */
[data-bs-theme="dark"] .table {
    --bs-table-bg: #111827 !important;
    --bs-table-color: #f3f4f6 !important;
    --bs-table-border-color: #1f2937 !important;
    background-color: #111827 !important;
    color: #f3f4f6 !important;
}

[data-bs-theme="dark"] .table th {
    background-color: #0d1117 !important;
    border-color: #1f2937 !important;
    color: #9ca3af !important;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

[data-bs-theme="dark"] .table td {
    border-color: #1f2937 !important;
}

[data-bs-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-bg-type: rgba(255, 255, 255, 0.02) !important;
}

[data-bs-theme="dark"] .table-hover > tbody > tr:hover > * {
    --bs-table-bg-state: rgba(16, 185, 129, 0.05) !important;
}

/* DataTables overrides */
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_length,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_filter,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_info,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_paginate {
    color: #9ca3af !important;
}

/* ================================================================
   FORMS
   ================================================================ */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #1f2937 !important;
    border-color: #374151 !important;
    color: #f3f4f6 !important;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: #1f2937 !important;
    border-color: #10b981 !important;
    color: #f3f4f6 !important;
    box-shadow: 0 0 0 0.2rem rgba(16, 185, 129, 0.25) !important;
}

[data-bs-theme="dark"] .form-control::placeholder {
    color: #6b7280 !important;
}

[data-bs-theme="dark"] .form-check-input {
    background-color: #1f2937;
    border-color: #374151;
}

[data-bs-theme="dark"] .form-check-input:checked {
    background-color: #10b981;
    border-color: #10b981;
}

/* ================================================================
   BUTTONS — Emerald accent
   ================================================================ */
.btn-primary {
    background-color: #10b981 !important;
    border-color: #10b981 !important;
    color: #fff !important;
}
.btn-primary:hover {
    background-color: #059669 !important;
    border-color: #059669 !important;
}

.btn-success {
    background-color: #10b981 !important;
    border-color: #10b981 !important;
}
.btn-success:hover {
    background-color: #059669 !important;
    border-color: #059669 !important;
}

.btn-outline-primary {
    color: #10b981 !important;
    border-color: #10b981 !important;
}
.btn-outline-primary:hover {
    background-color: #10b981 !important;
    color: #fff !important;
}

.btn-outline-success {
    color: #10b981 !important;
    border-color: #10b981 !important;
}
.btn-outline-success:hover {
    background-color: #10b981 !important;
    color: #fff !important;
}

.btn:focus {
    box-shadow: 0 0 0 0.2rem rgba(16, 185, 129, 0.25) !important;
}

/* ================================================================
   BADGES
   ================================================================ */
.badge.bg-success { background-color: #10b981 !important; }
.badge.bg-primary { background-color: #10b981 !important; }
.badge.bg-warning { background-color: #f59e0b !important; color: #000 !important; }
.badge.bg-danger { background-color: #ef4444 !important; }
.badge.bg-info { background-color: #06b6d4 !important; }

[data-bs-theme="dark"] .badge.bg-secondary {
    background-color: #1f2937 !important;
    color: #9ca3af !important;
}

/* ================================================================
   TEXT COLORS — Override Bootstrap utility classes
   ================================================================ */
.text-success { color: #10b981 !important; }
.text-danger { color: #ef4444 !important; }
.text-warning { color: #f59e0b !important; }
.text-info { color: #06b6d4 !important; }

[data-bs-theme="dark"] .text-muted {
    color: #6b7280 !important;
}

[data-bs-theme="dark"] .text-body-secondary {
    color: #9ca3af !important;
}

/* ================================================================
   ALGO COLOR CODING
   ================================================================ */
.algo-rally { color: #10b981; }
.algo-drop { color: #f59e0b; }
.algo-endgame { color: #8b5cf6; }
.algo-latency { color: #3b82f6; }
.algo-spread { color: #06b6d4; }
.algo-mm { color: #f97316; }
.algo-momentum { color: #ec4899; }
.algo-vol { color: #14b8a6; }
.algo-hedge { color: #f43f5e; }
.algo-fade { color: #a855f7; }
.algo-cwc { color: #eab308; }
.algo-cam { color: #ef4444; }

.algo-rally-bg { background: rgba(16, 185, 129, 0.08) !important; border-color: rgba(16, 185, 129, 0.2) !important; }
.algo-drop-bg { background: rgba(245, 158, 11, 0.08) !important; border-color: rgba(245, 158, 11, 0.2) !important; }
.algo-endgame-bg { background: rgba(139, 92, 246, 0.08) !important; border-color: rgba(139, 92, 246, 0.2) !important; }
.algo-latency-bg { background: rgba(59, 130, 246, 0.08) !important; border-color: rgba(59, 130, 246, 0.2) !important; }
.algo-spread-bg { background: rgba(6, 182, 212, 0.08) !important; border-color: rgba(6, 182, 212, 0.2) !important; }
.algo-mm-bg { background: rgba(249, 115, 22, 0.08) !important; border-color: rgba(249, 115, 22, 0.2) !important; }
.algo-momentum-bg { background-color: rgba(236, 72, 153, 0.1); }
.algo-vol-bg { background-color: rgba(20, 184, 166, 0.1); }
.algo-hedge-bg { background-color: rgba(244, 63, 94, 0.1); }

/* ================================================================
   DROPDOWNS
   ================================================================ */
[data-bs-theme="dark"] .dropdown-menu {
    background-color: #111827 !important;
    border-color: #1f2937 !important;
}

[data-bs-theme="dark"] .dropdown-item {
    color: #d1d5db !important;
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
    background-color: #1f2937 !important;
    color: #f3f4f6 !important;
}

[data-bs-theme="dark"] .dropdown-item.active {
    background-color: rgba(16, 185, 129, 0.15) !important;
    color: #10b981 !important;
}

[data-bs-theme="dark"] .dropdown-divider {
    border-color: #1f2937 !important;
}

/* ================================================================
   MODALS
   ================================================================ */
[data-bs-theme="dark"] .modal-content {
    background-color: #111827 !important;
    border-color: #1f2937 !important;
    color: #f3f4f6 !important;
}

[data-bs-theme="dark"] .modal-header {
    border-bottom-color: #1f2937 !important;
}

[data-bs-theme="dark"] .modal-footer {
    border-top-color: #1f2937 !important;
}

/* ================================================================
   PROGRESS BARS
   ================================================================ */
.progress,
[data-bs-theme="dark"] .progress {
    background-color: #1f2937 !important;
}

.progress-bar,
.progress-bar.bg-success {
    background: linear-gradient(90deg, #059669, #10b981) !important;
}

/* ================================================================
   ALERTS
   ================================================================ */
[data-bs-theme="dark"] .alert {
    border-color: #1f2937;
}

[data-bs-theme="dark"] .alert-success {
    background-color: rgba(16, 185, 129, 0.1) !important;
    border-color: rgba(16, 185, 129, 0.2) !important;
    color: #10b981 !important;
}

[data-bs-theme="dark"] .alert-danger {
    background-color: rgba(239, 68, 68, 0.1) !important;
    border-color: rgba(239, 68, 68, 0.2) !important;
    color: #ef4444 !important;
}

[data-bs-theme="dark"] .alert-warning {
    background-color: rgba(245, 158, 11, 0.1) !important;
    border-color: rgba(245, 158, 11, 0.2) !important;
    color: #f59e0b !important;
}

/* ================================================================
   ALGO ITEMS
   ================================================================ */
.algo-item {
    transition: background-color 0.15s;
}

[data-bs-theme="dark"] .algo-item {
    background-color: #111827 !important;
    border-color: #1f2937 !important;
    color: #f3f4f6 !important;
}

[data-bs-theme="dark"] .algo-item:hover {
    background-color: #1f2937 !important;
}

[data-bs-theme="dark"] .algo-item .text-muted {
    color: #6b7280 !important;
}

/* ================================================================
   TRADE ROW TINTS
   ================================================================ */
[data-bs-theme="dark"] .buy-row {
    background-color: rgba(16, 185, 129, 0.08) !important;
}

[data-bs-theme="dark"] .sell-row {
    background-color: rgba(239, 68, 68, 0.08) !important;
}

/* ================================================================
   TOASTS
   ================================================================ */
.toast.bg-success { background-color: #059669 !important; color: #fff !important; }
.toast.bg-danger { background-color: #ef4444 !important; color: #fff !important; }
.toast.bg-warning { background-color: #f59e0b !important; color: #000 !important; }
.toast.bg-info { background-color: #06b6d4 !important; color: #000 !important; }

.toast .btn-close { filter: invert(1); }
[data-bs-theme="dark"] .toast .btn-close { filter: none; }

.toast-container { z-index: 1050; }
.toast-container .toast { margin-bottom: 0.5rem; }

[data-bs-theme="dark"] .toast-container .toast {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.4);
}

/* ================================================================
   LOADING & SKELETON STATES
   ================================================================ */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: flex; }
.htmx-request.htmx-indicator { display: inline; }

#global-loading {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(3, 7, 18, 0.7);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.skeleton {
    background: linear-gradient(90deg, #e5e7eb 25%, #d1d5db 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    height: 1.2em;
    border-radius: 4px;
}

[data-bs-theme="dark"] .skeleton {
    background: linear-gradient(90deg, #1f2937 25%, #374151 50%, #1f2937 75%) !important;
    background-size: 200% 100%;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ================================================================
   KPI HELPERS
   ================================================================ */
.kpi-value {
    font-family: var(--pa-font-mono);
    font-weight: 700;
}

.kpi-label {
    font-size: 11px;
    color: var(--pa-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ================================================================
   CHART CONTAINERS
   ================================================================ */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

[data-bs-theme="dark"] .chart-container canvas {
    background-color: transparent !important;
}

/* ================================================================
   SCROLLBARS (webkit)
   ================================================================ */
[data-bs-theme="dark"] ::-webkit-scrollbar { width: 6px; height: 6px; }
[data-bs-theme="dark"] ::-webkit-scrollbar-track { background: #030712; }
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb { background: #374151; border-radius: 3px; }
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #4b5563; }

/* ================================================================
   MISC OVERRIDES
   ================================================================ */
.token-column {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 150px;
}

.hover-scale:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* ================================================================
   DEPLOYMENT PAGE SPECIFIC
   ================================================================ */
.deploy-phase { border-color: var(--pa-border); }
[data-bs-theme="dark"] .deploy-phase { border-color: #1f2937 !important; }
[data-bs-theme="dark"] .deploy-phase.current { border-color: #10b981 !important; background: rgba(16, 185, 129, 0.03) !important; }
[data-bs-theme="dark"] .deploy-phase-header:hover { background: rgba(255,255,255,0.02) !important; }
[data-bs-theme="dark"] .deploy-phase-body { border-top-color: #1f2937 !important; }

.metric-box { background: rgba(0,0,0,0.15) !important; }
[data-bs-theme="dark"] .metric-box { background: rgba(0,0,0,0.25) !important; }
.metric-box .val { color: #10b981; font-weight: 600; }

.go-nogo { background: rgba(16, 185, 129, 0.06); }
.go-nogo .label { color: #10b981; font-weight: 600; text-transform: uppercase; font-size: 10px; letter-spacing: 0.5px; }

.progress-bar-custom { height: 20px; background: #1f2937; border-radius: 4px; overflow: hidden; position: relative; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, #059669, #10b981); border-radius: 4px; }
.progress-bar-label { position: absolute; right: 8px; top: 1px; font-size: 11px; color: white; font-weight: 500; }

/* ================================================================
   PRIVACY / WALLET PURPLE ACCENT (PR204b)
   ================================================================ */
.bg-purple { background-color: #a855f7 !important; }
.text-purple { color: #a855f7 !important; }
.border-purple { border-color: #a855f7 !important; }
.btn-purple { background-color: #a855f7; border-color: #a855f7; color: white; }
.btn-purple:hover { background-color: #9333ea; border-color: #9333ea; color: white; }
.btn-outline-purple { border-color: #a855f7; color: #a855f7; }
.btn-outline-purple:hover { background-color: #a855f7; color: white; }
.copy-btn { cursor: pointer; opacity: 0.6; }
.copy-btn:hover { opacity: 1; }
.wallet-row:hover { background-color: rgba(168, 85, 247, 0.1) !important; }

/* ================================================================
   EXTRACTED INLINE STYLES (PR198d)
   ================================================================ */
.icon-xl { font-size: 3rem; }
.icon-lg { font-size: 2rem; }
.icon-xs { font-size: 0.5rem; }
.table-scroll-400 { max-height: 400px; overflow-y: auto; }
.badge-xs { font-size: 0.65rem; }
.status-bar-text { font-size: 0.7rem; }
.cursor-pointer { cursor: pointer; }
.text-xs { font-size: 12px; }

/* ================================================================
   UTILITY CLASSES — inline style extraction (PR213)
   ================================================================ */
.icon-3x { font-size: 3rem; }
.icon-2x { font-size: 2rem; }
.icon-1-5x { font-size: 1.5rem; }
.scroll-container { max-height: 400px; overflow-y: auto; }
.scroll-container-lg { max-height: 500px; overflow-y: auto; }
.col-checkbox { width: 32px; }
.progress-cell { min-width: 100px; }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 768px) {
    .card-body h5 { font-size: 1rem; }
    .card-body .h4 { font-size: 1.5rem; }
    .table-responsive { font-size: 0.8rem; }
}
