/* ═══════════════════════════════════════════════════════════════════════════
   Mobile-first CSS for Gap & Go Dashboard
   RTL layout, dark theme, 44px minimum touch targets
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    --bg: #121212;
    --surface: #1e1e1e;
    --surface-2: #2a2a2a;
    --text: #e0e0e0;
    --text-dim: #999;
    --accent: #ff9800;
    --green: #00e676;
    --red: #ff5252;
    --blue: #42a5f5;
    --yellow: #ffd740;
    --radius: 10px;
    --nav-height: 60px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

/* ── Top bar ─────────────────────────────────────────────────────────────── */

.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    border-bottom: 1px solid var(--surface-2);
}

.top-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent);
}

.logout-btn {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.85rem;
    padding: 8px 12px;
    border-radius: 6px;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.logout-btn:active {
    background: var(--surface-2);
}

/* ── Content area ────────────────────────────────────────────────────────── */

.content {
    padding: 58px 12px calc(var(--nav-height) + 12px);
    max-width: 600px;
    margin: 0 auto;
}

/* ── Bottom navigation ───────────────────────────────────────────────────── */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--surface);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid var(--surface-2);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-dim);
    min-width: 64px;
    min-height: 44px;
    padding: 6px 0;
    transition: color 0.15s;
}

.nav-item.active {
    color: var(--accent);
}

.nav-icon {
    font-size: 1.3rem;
    line-height: 1;
}

.nav-label {
    font-size: 0.7rem;
    margin-top: 2px;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
}

.card-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 8px;
    color: var(--accent);
}

.card a {
    text-decoration: none;
    color: inherit;
}

/* ── Section titles ──────────────────────────────────────────────────────── */

.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin: 16px 0 8px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
    text-decoration: none;
    color: #fff;
}

.btn:active {
    opacity: 0.7;
}

.btn-primary {
    background: var(--accent);
    color: #000;
}

.btn-green {
    background: var(--green);
    color: #000;
}

.btn-red {
    background: var(--red);
    color: #fff;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    min-height: 40px;
    padding: 8px 14px;
    font-size: 0.9rem;
}

/* ── Approve / Reject row ────────────────────────────────────────────────── */

.action-row {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.action-row .btn {
    flex: 1;
}

/* ── Forms ────────────────────────────────────────────────────────────────── */

input[type="text"],
input[type="password"],
input[type="date"],
textarea,
select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--surface-2);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 1rem;
    min-height: 48px;
    -webkit-appearance: none;
}

textarea {
    min-height: 100px;
    resize: vertical;
    font-family: inherit;
}

input[type="file"] {
    padding: 12px;
    min-height: 48px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: var(--text-dim);
}

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

/* ── Badge ────────────────────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-green { background: var(--green); color: #000; }
.badge-red { background: var(--red); color: #fff; }
.badge-orange { background: var(--accent); color: #000; }
.badge-blue { background: var(--blue); color: #000; }
.badge-gray { background: #555; color: #ccc; }

/* ── Status indicator ────────────────────────────────────────────────────── */

.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-inline-end: 6px;
}

.status-success { background: var(--green); }
.status-failed { background: var(--red); }
.status-running { background: var(--accent); animation: pulse 1.2s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── Run list ────────────────────────────────────────────────────────────── */

.run-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--surface);
    border-radius: var(--radius);
    margin-bottom: 6px;
    min-height: 48px;
    text-decoration: none;
    color: var(--text);
}

.run-item:active {
    background: var(--surface-2);
}

.run-date {
    font-weight: 600;
    font-size: 0.95rem;
}

.run-arrow {
    color: var(--text-dim);
    font-size: 1.2rem;
}

/* ── Ticker grid ─────────────────────────────────────────────────────────── */

.ticker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
}

.ticker-card {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 14px 8px;
    text-decoration: none;
    color: var(--accent);
    font-weight: 700;
    font-size: 0.95rem;
    min-height: 48px;
}

.ticker-card:active {
    background: var(--surface-2);
}

/* ── Progress bar ────────────────────────────────────────────────────────── */

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--surface-2);
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* ── Proposal card ───────────────────────────────────────────────────────── */

.proposal-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
    border-right: 4px solid var(--yellow);
}

.proposal-agent {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.proposal-param {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 8px 0;
}

.param-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.param-change {
    direction: ltr;
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 0.85rem;
}

.param-old { color: var(--red); text-decoration: line-through; }
.param-new { color: var(--green); margin-inline-start: 8px; }

.validation-badge {
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 6px;
    margin: 6px 0;
}
.validation-passed {
    background: rgba(52, 199, 89, 0.15);
    color: var(--green);
    border: 1px solid rgba(52, 199, 89, 0.3);
}
.validation-failed {
    background: rgba(255, 204, 0, 0.12);
    color: var(--yellow);
    border: 1px solid rgba(255, 204, 0, 0.3);
}

/* ── Chart container ─────────────────────────────────────────────────────── */

.chart-container {
    width: 100%;
    min-height: 280px;
    max-height: 400px;
    border-radius: var(--radius);
    overflow: hidden;
    margin: 10px 0;
}

.chart-container .js-plotly-plot {
    width: 100% !important;
}

/* ── Stages list ─────────────────────────────────────────────────────────── */

.stage-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--surface);
    border-radius: 8px;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.stage-name {
    font-weight: 500;
}

.stage-time {
    color: var(--text-dim);
    font-size: 0.8rem;
    direction: ltr;
}

/* ── Feedback status list ────────────────────────────────────────────────── */

.feedback-item {
    padding: 12px 14px;
    background: var(--surface);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.feedback-meta {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 4px;
}

/* ── Toast notifications ─────────────────────────────────────────────────── */

.toast {
    position: fixed;
    top: 58px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-2);
    color: var(--text);
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    z-index: 200;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    animation: toast-in 0.3s ease;
}

.toast-success { border: 1px solid var(--green); }
.toast-error { border: 1px solid var(--red); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Empty state ─────────────────────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-dim);
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

/* ── Login page ──────────────────────────────────────────────────────────── */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 20px;
}

.login-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 32px 24px;
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.login-card h1 {
    font-size: 1.5rem;
    margin-bottom: 4px;
    color: var(--accent);
}

.login-subtitle {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.login-card input {
    margin-bottom: 14px;
    text-align: center;
}

.login-card button {
    width: 100%;
    min-height: 48px;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #000;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
}

.login-card button:active {
    opacity: 0.7;
}

.login-error {
    color: var(--red);
    font-size: 0.85rem;
    margin-top: 12px;
}

/* ── SSE status ──────────────────────────────────────────────────────────── */

.sse-status {
    margin-top: 16px;
}

/* ── Notes input for proposals ───────────────────────────────────────────── */

.notes-input {
    min-height: 40px;
    margin-top: 8px;
    font-size: 0.85rem;
}

/* ── Observations ────────────────────────────────────────────────────────── */

.observation {
    background: var(--surface-2);
    border-radius: 6px;
    padding: 8px 10px;
    margin: 4px 0;
    font-size: 0.85rem;
    color: var(--text-dim);
}

/* ── Applied changes ─────────────────────────────────────────────────────── */

.applied-item {
    padding: 10px 14px;
    background: var(--surface);
    border-radius: 8px;
    margin-bottom: 6px;
    border-right: 3px solid var(--green);
}

/* ── Chart tabs ─────────────────────────────────────────────────────────── */

.chart-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.chart-tab {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--surface-2);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text-dim);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    min-height: 44px;
}

.chart-tab.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

/* ── Trade rows ─────────────────────────────────────────────────────────── */

.trade-row {
    background: var(--surface-2);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 6px;
}

/* ── Mobile-specific optimizations ──────────────────────────────────────── */

@media (max-width: 480px) {
    .chart-container {
        min-height: 250px;
        max-height: 350px;
    }

    .chart-tab {
        font-size: 0.8rem;
        padding: 8px;
    }

    .card {
        padding: 12px;
    }
}

/* ── Responsive: larger screens ──────────────────────────────────────────── */

@media (min-width: 768px) {
    .content {
        max-width: 700px;
        padding: 58px 20px calc(var(--nav-height) + 20px);
    }

    .ticker-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }

    .chart-container {
        min-height: 350px;
        max-height: 500px;
    }
}
