/* BankingRadar — Mobile-first, mlanalytica-inspired dark theme */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    --navy: #00192f;
    --navy-light: #002244;
    --navy-card: #0a2540;
    --navy-hover: #0d2d4d;
    --gold: #bb9752;
    --gold-light: #f9e6aa;
    --gold-gradient: linear-gradient(135deg, #f9e6aa, #bb9752);
    --white: #ffffff;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.45);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-gold: 0 4px 20px rgba(187, 151, 82, 0.25);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --transition: 0.3s ease;
}

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

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--navy);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--gold-light); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--gold); }

/* === NAVBAR (mobile-first) === */

.navbar {
    background: rgba(0, 25, 47, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(249, 230, 170, 0.1);
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.navbar-brand .logo-icon {
    width: 28px;
    height: 28px;
    background: var(--gold-gradient);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 11px;
    color: var(--navy);
}

.navbar-brand span {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--white);
    letter-spacing: -0.5px;
}

.navbar-brand .brand-accent {
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-links {
    display: flex;
    gap: 0.25rem;
    list-style: none;
}

.nav-links a {
    color: var(--text-secondary);
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    transition: all var(--transition);
}

.nav-links a:hover, .nav-links a.active {
    color: var(--gold-light);
    background: rgba(249, 230, 170, 0.08);
}

/* === LAYOUT (mobile-first: single column, small padding) === */

.page-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
}

.page-header {
    margin-bottom: 1.25rem;
}

.page-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 0.15rem;
}

.page-header h1 .accent {
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.82rem;
}

/* === CARDS === */

.card {
    background: var(--navy-card);
    border: 1px solid rgba(249, 230, 170, 0.08);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
    transition: border-color var(--transition);
}

.card:hover { border-color: rgba(249, 230, 170, 0.15); }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    gap: 0.5rem;
    flex-wrap: wrap;
}

.card-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--white);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.card-header .card-icon {
    width: 26px;
    height: 26px;
    background: rgba(249, 230, 170, 0.1);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}

/* === CONTROLS (mobile: stacked) === */

.controls-row {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.control-group {
    width: 100%;
}

.control-group label {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.3rem;
}

select, input[type="text"], input[type="number"] {
    width: 100%;
    padding: 0.65rem 0.9rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--white);
    font-family: inherit;
    font-size: 16px; /* prevents iOS zoom */
    transition: all var(--transition);
    appearance: none;
    -webkit-appearance: none;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

select:focus, input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(187, 151, 82, 0.15);
}

select option { background: var(--navy-card); color: var(--white); }

/* === BUTTONS === */

.btn {
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    touch-action: manipulation;
}

.btn-gold { background: var(--gold-gradient); color: var(--navy); }
.btn-gold:hover { box-shadow: var(--shadow-gold); transform: translateY(-1px); }

.btn-outline {
    background: transparent;
    border: 1px solid rgba(249, 230, 170, 0.3);
    color: var(--gold-light);
}
.btn-outline:hover { background: rgba(249, 230, 170, 0.08); border-color: var(--gold-light); }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.78rem; }

/* === TABLES (mobile: horizontal scroll) === */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -1rem; padding: 0 1rem; }

table { width: 100%; border-collapse: collapse; }

thead th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    white-space: nowrap;
}

tbody td {
    padding: 0.55rem 0.75rem;
    font-size: 0.82rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    white-space: nowrap;
}

tbody tr:hover { background: rgba(249, 230, 170, 0.03); }
tbody td:first-child { color: var(--white); font-weight: 500; }
td a { color: var(--gold-light); }

/* === CHARTS === */

.chart-container { min-height: 300px; border-radius: var(--radius-sm); }
.chart-container-lg { min-height: 450px; }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.3; }

/* === STATS GRID (mobile: 2 cols) === */

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--navy-card);
    border: 1px solid rgba(249, 230, 170, 0.08);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}

.stat-card .stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.15rem;
}

.stat-card .stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* === BADGE === */

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.badge-warning { background: rgba(249, 230, 170, 0.15); color: var(--gold-light); }
.badge-error { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-info { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }

/* === STATUS DOT === */

.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.status-dot.extracted { background: #4ade80; }
.status-dot.downloaded { background: var(--gold-light); }
.status-dot.error { background: #f87171; }
.status-dot.extracting { background: #60a5fa; }

/* === GRID LAYOUTS (mobile: single column) === */

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 1rem; }

/* === BANK CHIPS === */

.bank-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

.chip {
    padding: 0.3rem 0.6rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    touch-action: manipulation;
}

.chip:hover { border-color: rgba(249, 230, 170, 0.3); color: var(--text-secondary); }

.chip.active {
    background: rgba(187, 151, 82, 0.2);
    border-color: var(--gold);
    color: var(--gold-light);
}

/* === INSIGHTS === */

.insights-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.insight-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    transition: all var(--transition);
}

.insight-card:hover { background: rgba(255, 255, 255, 0.04); border-color: rgba(249, 230, 170, 0.15); }

.insight-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
}

.insight-card p { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.5; margin: 0; }

/* === BANK DETAIL HERO === */

.bank-hero {
    background: var(--navy-card);
    border: 1px solid rgba(249, 230, 170, 0.1);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1rem;
}

.bank-hero .bank-avatar {
    width: 52px;
    height: 52px;
    background: var(--gold-gradient);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--navy);
    flex-shrink: 0;
}

.bank-hero h1 { font-size: 1.25rem; margin-bottom: 0.2rem; }

.bank-hero .bank-meta {
    display: flex;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.78rem;
    flex-wrap: wrap;
    justify-content: center;
}

.bank-hero .bank-meta span { display: flex; align-items: center; gap: 0.2rem; }

/* === CHAT WIDGET (mobile-first) === */

.chat-fab {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    width: 50px;
    height: 50px;
    background: var(--gold-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-gold), 0 4px 16px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    transition: all var(--transition);
    color: var(--navy);
    touch-action: manipulation;
}

.chat-fab:hover { transform: scale(1.1); }
.chat-fab.hidden { transform: scale(0); opacity: 0; pointer-events: none; }

.chat-window {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: var(--navy-card);
    border: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    z-index: 2001;
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.chat-window.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: all;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    background: rgba(0, 25, 47, 0.95);
    border-bottom: 1px solid rgba(249, 230, 170, 0.1);
    flex-shrink: 0;
}

.chat-header-left { display: flex; align-items: center; gap: 0.6rem; }

.chat-avatar {
    width: 32px;
    height: 32px;
    background: var(--gold-gradient);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 11px;
    color: var(--navy);
}

.chat-header-title { font-weight: 600; font-size: 0.85rem; color: var(--white); }
.chat-header-sub { font-size: 0.65rem; color: var(--text-muted); }

.chat-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all var(--transition);
    touch-action: manipulation;
}

.chat-close:hover { color: var(--white); background: rgba(255, 255, 255, 0.08); }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    -webkit-overflow-scrolling: touch;
}

.chat-msg { display: flex; max-width: 90%; }
.chat-msg.user { align-self: flex-end; }
.chat-msg.bot { align-self: flex-start; }

.chat-msg-content {
    padding: 0.65rem 0.9rem;
    border-radius: 14px;
    font-size: 0.82rem;
    line-height: 1.5;
}

.chat-msg.user .chat-msg-content {
    background: var(--gold);
    color: var(--navy);
    border-bottom-right-radius: 4px;
}

.chat-msg.bot .chat-msg-content {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-input-area {
    display: flex;
    gap: 0.5rem;
    padding: 0.65rem 0.75rem;
    padding-bottom: max(0.65rem, env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 25, 47, 0.5);
    flex-shrink: 0;
}

.chat-input-area input { flex: 1; border-radius: 20px; padding: 0.6rem 1rem; }

.chat-input-area .btn {
    border-radius: 50%;
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Typing indicator */
.typing-indicator { display: flex; gap: 4px; padding: 0.8rem 1rem !important; }

.typing-indicator span {
    width: 7px; height: 7px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.2s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 100% { opacity: 0.3; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-3px); }
}

/* === FOOTER === */

.footer {
    border-top: 1px solid rgba(249, 230, 170, 0.08);
    padding: 1.25rem 1rem;
    margin-top: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.72rem;
}

.footer a { color: var(--gold); }

/* === PRE === */

pre {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    max-height: 180px;
    overflow-y: auto;
    font-size: 0.75rem;
    color: var(--text-secondary);
    -webkit-overflow-scrolling: touch;
}

/* === SCROLLBAR === */

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(249, 230, 170, 0.2); border-radius: 2px; }

/* === PLOTLY OVERRIDES === */

.js-plotly-plot .plotly .modebar { background: transparent !important; }
.js-plotly-plot .plotly .modebar-btn path { fill: var(--text-muted) !important; }
.js-plotly-plot .plotly .modebar-btn:hover path { fill: var(--gold-light) !important; }

/* ============================================================
   TABLET (min-width: 600px)
   ============================================================ */

@media (min-width: 600px) {
    .navbar { padding: 0 1.5rem; height: 60px; }
    .page-container { padding: 1.5rem; }
    .page-header h1 { font-size: 1.6rem; }

    .controls-row { flex-direction: row; flex-wrap: wrap; }
    .control-group { flex: 1; min-width: 160px; width: auto; }

    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .insights-grid { grid-template-columns: 1fr 1fr; }
    .grid-2 { grid-template-columns: 1fr 1fr; }

    .card { padding: 1.25rem; margin-bottom: 1.25rem; }
    .chart-container { min-height: 380px; }
    .chart-container-lg { min-height: 550px; }

    .bank-hero {
        flex-direction: row;
        text-align: left;
        align-items: center;
        padding: 1.5rem;
    }

    .bank-hero .bank-meta { justify-content: flex-start; }

    /* Chat as a floating window on tablet */
    .chat-window {
        top: auto;
        left: auto;
        bottom: 1.5rem;
        right: 1.5rem;
        width: 400px;
        height: 540px;
        border-radius: var(--radius-lg);
        border: 1px solid rgba(249, 230, 170, 0.15);
        box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
        transform: scale(0.8) translateY(20px);
        transform-origin: bottom right;
    }

    .chat-window.open { transform: scale(1) translateY(0); }
}

/* ============================================================
   DESKTOP (min-width: 1024px)
   ============================================================ */

@media (min-width: 1024px) {
    .navbar { padding: 0 2rem; height: 64px; }
    .navbar-brand .logo-icon { width: 32px; height: 32px; font-size: 14px; }
    .navbar-brand span { font-size: 1.25rem; }
    .nav-links a { font-size: 0.875rem; padding: 0.5rem 1rem; }

    .page-container { padding: 2rem; }
    .page-header h1 { font-size: 2rem; letter-spacing: -1px; }
    .page-header p { font-size: 0.95rem; }

    .card { padding: 1.5rem; margin-bottom: 1.5rem; }
    .card-header h2 { font-size: 1.1rem; }

    select, input[type="text"], input[type="number"] { font-size: 0.875rem; }

    .stat-card .stat-value { font-size: 1.75rem; }
    .stat-card .stat-label { font-size: 0.75rem; }

    .chart-container { min-height: 400px; }
    .chart-container-lg { min-height: 600px; }

    .insights-grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

    .bank-hero { padding: 2rem; gap: 1.5rem; }
    .bank-hero .bank-avatar { width: 64px; height: 64px; font-size: 1.5rem; }
    .bank-hero h1 { font-size: 1.5rem; }

    .chat-window { width: 420px; height: 580px; }
    .chat-fab { width: 56px; height: 56px; bottom: 2rem; right: 2rem; }
}
