/* ============================================
   VentajaQuant Trading Analytics — Styles v2
   Dark theme · Spanish flag accents · Portfolio Live
   ============================================ */

:root {
    --bg-body:       #0a0a0f;
    --bg-card:       #111118;
    --bg-card-hover: #16161f;
    --bg-input:      #0d0d14;
    --border:        rgba(255,255,255,0.06);
    --border-accent: rgba(255,255,255,0.12);
    --accent-red:    #c41e3a;
    --accent-gold:   #facc15;
    --accent-blue:   #3b82f6;
    --text:          #e5e7eb;
    --text-dim:      #9ca3af;
    --text-muted:    #6b7280;
    --positive:      #22c55e;
    --negative:      #ef4444;
    --warning:       #f59e0b;
    --font-body:     'DM Sans', sans-serif;
    --font-mono:     'JetBrains Mono', monospace;
    --font-heading:  'Playfair Display', serif;
    --radius:        12px;
    --radius-sm:     8px;
}

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

body {
    font-family: var(--font-body);
    background: var(--bg-body);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

.bg-pattern {
    position: fixed; inset: 0; z-index: -1;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(196,30,58,0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(250,204,21,0.04) 0%, transparent 50%);
}

/* ── Header ── */
header {
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    backdrop-filter: blur(12px);
    position: sticky; top: 0; z-index: 100;
    background: rgba(10,10,15,0.85);
}
.header-content {
    max-width: 1400px; margin: 0 auto;
    display: flex; justify-content: space-between; align-items: center;
}
.logo {
    font-family: var(--font-heading);
    font-size: 1.4rem; font-weight: 700;
    color: var(--text); text-decoration: none;
}
.logo span { color: var(--accent-gold); }
.logo-subtitle {
    margin-left: 16px; font-size: 0.75rem;
    color: var(--text-muted); font-family: var(--font-mono);
}

/* ── Buttons ── */
.btn {
    padding: 8px 16px; border-radius: var(--radius-sm);
    font-family: var(--font-body); font-size: 0.85rem; font-weight: 500;
    cursor: pointer; border: 1px solid var(--border-accent);
    text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
    transition: all 0.2s;
}
.btn-primary   { background: var(--accent-red); color: #fff; border-color: var(--accent-red); }
.btn-primary:hover { background: #a31830; }
.btn-secondary { background: transparent; color: var(--text-dim); }
.btn-secondary:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.btn-danger    { background: #7f1d1d; color: #fca5a5; border-color: #991b1b; }
.btn-danger:hover { background: #991b1b; }
.btn-success   { background: #14532d; color: #86efac; border-color: #166534; }
.btn-success:hover { background: #166534; }
.btn-sm        { padding: 4px 10px; font-size: 0.75rem; }

/* ── Main ── */
main { max-width: 1400px; margin: 0 auto; padding: 24px; }

/* ── Upload Section ── */
.upload-section { text-align: center; padding: 60px 20px; }
.upload-section h2 { font-family: var(--font-heading); font-size: 2rem; margin-bottom: 12px; }
.upload-section p  { color: var(--text-dim); max-width: 600px; margin: 0 auto 30px; }

.drop-zone {
    border: 2px dashed var(--border-accent);
    border-radius: var(--radius);
    padding: 50px 30px;
    max-width: 500px; margin: 0 auto;
    cursor: pointer; transition: all 0.3s;
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--accent-gold);
    background: rgba(250,204,21,0.03);
}
.drop-zone .icon { font-size: 3rem; margin-bottom: 12px; }
.drop-zone h3 { font-size: 1.1rem; margin-bottom: 6px; }
.drop-zone .hint { font-size: 0.8rem; color: var(--text-muted); }
#csvFile { display: none; }

.hidden { display: none !important; }

/* ── Quick Summary Bar ── */
.quick-summary {
    display: flex; gap: 16px; justify-content: center; flex-wrap: wrap;
    padding: 16px 0; margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.qs-item { text-align: center; min-width: 100px; }
.qs-label { display: block; font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.qs-value { font-family: var(--font-mono); font-size: 1.1rem; font-weight: 600; }
.qs-item.positive .qs-value { color: var(--positive); }
.qs-item.negative .qs-value { color: var(--negative); }

/* ── Tab Navigation ── */
.tab-nav {
    display: flex; gap: 4px; overflow-x: auto;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0; margin-bottom: 24px;
    -webkit-overflow-scrolling: touch;
}
.tab-btn {
    padding: 10px 16px; background: none; border: none;
    color: var(--text-dim); font-family: var(--font-body);
    font-size: 0.85rem; cursor: pointer; white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
    color: var(--accent-gold);
    border-bottom-color: var(--accent-gold);
}

/* ── Stat Cards ── */
.stats-grid-3 {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px; margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
    transition: border-color 0.2s;
}
.stat-card:hover { border-color: var(--border-accent); }
.stat-card h4 { font-size: 0.85rem; margin-bottom: 12px; color: var(--text-dim); }
.stat-card.mini { padding: 14px; }
.stat-card.mini h5 { font-size: 0.8rem; margin-bottom: 8px; }

.stat-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 5px 0; font-size: 0.85rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
.stat-row:last-child { border-bottom: none; }
.stat-row span:first-child { color: var(--text-dim); }
.stat-row span:last-child  { font-family: var(--font-mono); font-weight: 500; }
.stat-row.big span:last-child { font-size: 1.2rem; }
.stat-row.highlight { background: rgba(250,204,21,0.05); border-radius: 4px; padding: 6px 8px; }

.positive { color: var(--positive) !important; }
.negative { color: var(--negative) !important; }

.dir-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }

/* ── Charts ── */
.chart-row {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 16px; margin-bottom: 20px;
}
.chart-wrap {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
    position: relative; height: 300px;
}
.chart-wrap.full { grid-column: 1 / -1; }
.chart-wrap.tall { height: 400px; }
.chart-wrap h5 {
    font-size: 0.8rem; color: var(--text-dim);
    margin-bottom: 8px; font-weight: 500;
}
canvas { max-height: 100%; }

/* ── Tables ── */
.symbols-table { overflow-x: auto; }
table {
    width: 100%; border-collapse: collapse;
    font-size: 0.85rem;
}
th, td { padding: 10px 14px; text-align: left; }
th {
    color: var(--text-dim); font-weight: 500; font-size: 0.75rem;
    text-transform: uppercase; letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}
td {
    border-bottom: 1px solid rgba(255,255,255,0.03);
    font-family: var(--font-mono);
}
tr:hover td { background: rgba(255,255,255,0.02); }

/* ── Trailing Calculator ── */
.trailing-calc {
    margin-top: 24px; padding: 20px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius);
}
.trailing-inputs {
    display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap;
    margin-top: 12px;
}
.trailing-inputs label {
    display: block; font-size: 0.75rem; color: var(--text-dim); margin-bottom: 4px;
}
.trailing-inputs input {
    background: var(--bg-input); border: 1px solid var(--border-accent);
    border-radius: var(--radius-sm); padding: 8px 12px;
    color: var(--text); font-family: var(--font-mono); font-size: 0.9rem;
    width: 140px;
}
.trailing-result-card {
    margin-top: 16px; padding: 16px;
    background: rgba(255,255,255,0.02); border-radius: var(--radius-sm);
}

/* ── Session Tracker ── */
.session-start { text-align: center; padding: 40px 20px; }
.session-start h4 { font-size: 1.2rem; margin-bottom: 8px; }
.session-inputs {
    display: flex; gap: 12px; align-items: flex-end; justify-content: center;
    flex-wrap: wrap; margin-top: 20px;
}
.session-inputs label { display: block; font-size: 0.75rem; color: var(--text-dim); margin-bottom: 4px; }
.session-inputs input {
    background: var(--bg-input); border: 1px solid var(--border-accent);
    border-radius: var(--radius-sm); padding: 8px 12px;
    color: var(--text); font-family: var(--font-mono); width: 120px;
}
.session-live { }
.session-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.session-add {
    display: flex; gap: 8px; margin-top: 16px;
}
.session-add input {
    flex: 1; background: var(--bg-input); border: 1px solid var(--border-accent);
    border-radius: var(--radius-sm); padding: 10px 14px;
    color: var(--text); font-family: var(--font-mono); font-size: 0.95rem;
}
.session-recommendation {
    margin-top: 16px; padding: 14px 18px; border-radius: var(--radius-sm);
    font-size: 0.9rem; font-weight: 500;
}
.rec-stop      { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.rec-excellent { background: rgba(196,30,58,0.1); border: 1px solid rgba(196,30,58,0.3); color: #fecaca; }
.rec-good      { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3); color: #fcd34d; }
.rec-ok        { background: rgba(250,204,21,0.1); border: 1px solid rgba(250,204,21,0.3); color: #facc15; }

/* ── Alerts ── */
.alert {
    padding: 12px 16px; border-radius: var(--radius-sm);
    margin-bottom: 8px; font-size: 0.85rem;
}
.alert-danger  { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.2); color: #fca5a5; }
.alert-warning { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.2); color: #fcd34d; }
.alert-success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.2); color: #86efac; }
.alert-info    { background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.2); color: #93c5fd; }

/* ============================================
   PORTFOLIO LIVE — Specific Styles
   ============================================ */

.portfolio-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px; flex-wrap: wrap; gap: 12px;
}
.portfolio-header h4 { font-size: 1.1rem; }
.portfolio-controls { display: flex; gap: 8px; align-items: center; }
.portfolio-controls select {
    background: var(--bg-input); border: 1px solid var(--border-accent);
    border-radius: var(--radius-sm); padding: 6px 10px;
    color: var(--text); font-family: var(--font-mono); font-size: 0.8rem;
}

.portfolio-status {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.75rem; color: var(--text-muted);
}
.status-dot {
    width: 8px; height: 8px; border-radius: 50%;
    display: inline-block;
}
.status-dot.live    { background: var(--positive); box-shadow: 0 0 6px var(--positive); animation: pulse 2s infinite; }
.status-dot.paused  { background: var(--warning); }
.status-dot.error   { background: var(--negative); }

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

/* Position Cards */
.position-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 12px; margin-bottom: 20px;
}
.position-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
    transition: all 0.2s;
    position: relative; overflow: hidden;
}
.position-card:hover { border-color: var(--border-accent); }
.position-card.profit { border-left: 3px solid var(--positive); }
.position-card.loss   { border-left: 3px solid var(--negative); }
.position-card.no-quote { border-left: 3px solid var(--text-muted); opacity: 0.7; }

.pos-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 10px;
}
.pos-symbol {
    font-family: var(--font-mono); font-size: 1.1rem; font-weight: 700;
}
.pos-side {
    font-size: 0.7rem; padding: 2px 8px; border-radius: 4px;
    font-weight: 600; text-transform: uppercase;
}
.pos-side.long  { background: rgba(34,197,94,0.15); color: var(--positive); }
.pos-side.short { background: rgba(239,68,68,0.15); color: var(--negative); }

.pos-company {
    font-size: 0.72rem; color: var(--text-muted);
    margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.pos-prices {
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
    font-size: 0.8rem; margin-bottom: 10px;
}
.pos-prices span:nth-child(odd) { color: var(--text-muted); }
.pos-prices span:nth-child(even) { font-family: var(--font-mono); text-align: right; }

.pos-pnl {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 10px; border-radius: var(--radius-sm);
    font-family: var(--font-mono); font-weight: 600;
}
.pos-pnl.profit { background: rgba(34,197,94,0.08); }
.pos-pnl.loss   { background: rgba(239,68,68,0.08); }

.pos-pnl-value  { font-size: 1rem; }
.pos-pnl-pct    { font-size: 0.85rem; }

.pos-meta {
    display: flex; gap: 12px; margin-top: 8px;
    font-size: 0.7rem; color: var(--text-muted);
}

.market-badge {
    font-size: 0.65rem; padding: 1px 6px; border-radius: 3px;
    font-weight: 600; text-transform: uppercase;
}
.market-badge.live    { background: rgba(34,197,94,0.2); color: var(--positive); }
.market-badge.delayed { background: rgba(245,158,11,0.2); color: var(--warning); }
.market-badge.closed  { background: rgba(107,114,128,0.2); color: var(--text-muted); }

/* Portfolio Stops Card */
.portfolio-stops-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
    margin-bottom: 20px;
}
.stops-zone-bar {
    display: flex; height: 32px; border-radius: 6px; overflow: hidden;
    margin: 12px 0;
}
.stops-zone-bar .zone {
    display: flex; align-items: center; justify-content: center;
    font-size: 0.65rem; font-weight: 600;
    transition: all 0.3s;
}
.stops-zone-bar .zone.active {
    box-shadow: inset 0 0 0 2px #fff;
}

/* No positions state */
.portfolio-empty {
    text-align: center; padding: 60px 20px;
}
.portfolio-empty .icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.5; }
.portfolio-empty h4 { margin-bottom: 8px; }
.portfolio-empty p { color: var(--text-muted); font-size: 0.9rem; max-width: 400px; margin: 0 auto; }

/* ── Loading Overlay ── */
.loading-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
}
.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border-accent);
    border-top-color: var(--accent-gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text-dim); font-size: 0.9rem; }

/* ── Notifications ── */
#notifications {
    position: fixed; top: 80px; right: 20px; z-index: 300;
    display: flex; flex-direction: column; gap: 8px;
}
.notification {
    padding: 12px 18px; border-radius: var(--radius-sm);
    font-size: 0.85rem; max-width: 360px;
    opacity: 0; transform: translateX(20px);
    transition: all 0.3s;
}
.notification.show { opacity: 1; transform: translateX(0); }
.notification-success { background: rgba(34,197,94,0.15); border: 1px solid rgba(34,197,94,0.3); color: #86efac; }
.notification-error   { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.notification-warning { background: rgba(245,158,11,0.15); border: 1px solid rgba(245,158,11,0.3); color: #fcd34d; }
.notification-info    { background: rgba(59,130,246,0.15); border: 1px solid rgba(59,130,246,0.3); color: #93c5fd; }

/* ── Footer ── */
footer {
    text-align: center; padding: 24px; margin-top: 40px;
    border-top: 1px solid var(--border);
    font-size: 0.75rem; color: var(--text-muted);
}
footer a { color: var(--accent-gold); text-decoration: none; }

/* ── Print ── */
@media print {
    header, footer, .tab-nav, .session-add, .trailing-calc,
    .btn, #notifications, .loading-overlay, .portfolio-controls { display: none !important; }
    body { background: #fff; color: #111; }
    .stat-card, .chart-wrap, .position-card { border-color: #ddd; break-inside: avoid; }
    .tab-content { display: block !important; }
    .hidden { display: block !important; }
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .header-content { flex-direction: column; gap: 8px; }
    .logo-subtitle { display: none; }
    .chart-row { grid-template-columns: 1fr; }
    .stats-grid-3 { grid-template-columns: 1fr; }
    .position-grid { grid-template-columns: 1fr; }
    .tab-nav { gap: 0; }
    .tab-btn { padding: 8px 10px; font-size: 0.75rem; }
    .quick-summary { gap: 10px; }
    .qs-item { min-width: 70px; }
    .qs-value { font-size: 0.95rem; }
}
