/* ==============================================================
   STYLE.CSS — Portfolio Boursier Vincent Poyo
   Design : sombre, moderne, tons bleu/violet
   ============================================================== */

/* ---------- RESET & BASE ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0f0c29;
    --bg-secondary: #1a1740;
    --bg-card: #1e1b4b;
    --bg-card-hover: #28256b;
    --accent-blue: #00d2ff;
    --accent-purple: #7c3aed;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #302b63 50%, var(--bg-primary) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ---------- CONTAINER ---------- */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ---------- HEADER ---------- */
.header {
    background: rgba(15, 12, 41, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.last-update {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

/* ---------- KPI GRID ---------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin: 2rem 0;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.kpi-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.kpi-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.kpi-total .kpi-value { color: var(--accent-blue); }
.kpi-pl .kpi-value { color: var(--accent-green); }
.kpi-pl.negative .kpi-value { color: var(--accent-red); }
.kpi-perf .kpi-value { color: var(--accent-purple); }
.kpi-perf.positive .kpi-value { color: var(--accent-green); }
.kpi-perf.negative .kpi-value { color: var(--accent-red); }
.kpi-count .kpi-value { color: var(--text-primary); }

/* ---------- CHARTS GRID ---------- */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.chart-card h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-weight: 500;
}

.chart-card canvas {
    max-height: 300px;
}

.chart-full {
    grid-column: 1 / -1;
    margin-bottom: 2rem;
}

.chart-full canvas {
    max-height: 350px;
}

/* ---------- TABLE ---------- */
.table-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.table-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.btn-refresh {
    background: var(--accent-purple);
    color: white;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-refresh:hover {
    background: #6d28d9;
}

.btn-refresh:active {
    transform: scale(0.97);
}

.btn-refresh.loading {
    opacity: 0.6;
    pointer-events: none;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.portfolio-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    white-space: nowrap;
}

.portfolio-table thead {
    background: rgba(124, 58, 237, 0.15);
}

.portfolio-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--accent-blue);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
}

.portfolio-table td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.8rem;
}

.portfolio-table tbody tr:hover {
    background: rgba(124, 58, 237, 0.08);
}

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

.loading-cell {
    text-align: center;
    padding: 3rem !important;
    color: var(--text-muted);
    font-family: inherit !important;
}

/* P&L colors in table */
.pl-positive { color: var(--accent-green); }
.pl-negative { color: var(--accent-red); }
.pl-neutral  { color: var(--text-secondary); }

/* Ticker badge */
.ticker-badge {
    background: rgba(0, 210, 255, 0.12);
    color: var(--accent-blue);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.8rem;
}

/* Type badge */
.type-badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.type-badge.action { background: rgba(0, 210, 255, 0.15); color: var(--accent-blue); }
.type-badge.etf    { background: rgba(124, 58, 237, 0.15); color: var(--accent-purple); }
.type-badge.crypto { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.type-badge.obligation { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.type-badge.fonds  { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }

/* ---------- FOOTER ---------- */
.footer {
    text-align: center;
    padding: 2rem 0;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

.footer p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.footer-small {
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-card-hover);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-purple);
}

/* ---------- ANIMATION ---------- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.kpi-card, .chart-card, .table-section {
    animation: fadeIn 0.4s ease-out;
}

.chart-card:nth-child(2) { animation-delay: 0.1s; }
.table-section          { animation-delay: 0.2s; }
