/* =====================================================================
   style.css - Style minimal pour la page d'accueil temporaire.
   Sera enrichi en Bloc 5 avec le dashboard complet.
   ===================================================================== */

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

:root {
    --bg: #0f1115;
    --bg-elev: #161a22;
    --bg-card: #1d2230;
    --border: #2a3142;
    --text: #e6e9ef;
    --text-dim: #8a93a6;
    --accent: #f0b90b;       /* jaune Binance */
    --green: #2ebd85;
    --red: #f6465d;
    --orange: #ff9332;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* === Topbar === */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 28px;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 18px;
}

.brand .logo {
    color: var(--accent);
    font-size: 22px;
}

.env {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 600;
    margin-left: 8px;
}

.env-development {
    background: rgba(255, 147, 50, 0.15);
    color: var(--orange);
    border: 1px solid var(--orange);
}

.env-production {
    background: rgba(246, 70, 93, 0.15);
    color: var(--red);
    border: 1px solid var(--red);
}

.nav {
    display: flex;
    gap: 6px;
}

.nav-link {
    color: var(--text-dim);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.15s;
}

.nav-link:hover:not(.disabled) {
    color: var(--text);
    background: var(--bg-card);
}

.nav-link.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* === Main === */
.main {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
    width: 100%;
}

.hero {
    text-align: center;
    margin-bottom: 36px;
}

.hero h1 {
    font-size: 36px;
    margin-bottom: 12px;
}

.hero .subtitle {
    color: var(--text-dim);
    font-size: 15px;
}

/* === Cards === */
.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 18px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 22px;
}

.card h2 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--accent);
}

/* === Checklist === */
.checklist {
    list-style: none;
}

.checklist li {
    padding: 8px 0;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

.checklist li:last-child {
    border-bottom: none;
}

.checklist li.done::before {
    content: "OK ";
    color: var(--green);
    font-weight: 700;
}

.checklist li.todo::before {
    content: "... ";
    color: var(--text-dim);
}

.checklist li.todo {
    color: var(--text-dim);
}

/* === Status indicator === */
.status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 14px;
    font-size: 14px;
}

.status .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-pending {
    background: rgba(255, 147, 50, 0.1);
    color: var(--orange);
}
.status-pending .dot { background: var(--orange); }

.status-ok {
    background: rgba(46, 189, 133, 0.1);
    color: var(--green);
}
.status-ok .dot { background: var(--green); }

.status-ko {
    background: rgba(246, 70, 93, 0.1);
    color: var(--red);
}
.status-ko .dot { background: var(--red); }

.result {
    font-size: 13px;
    color: var(--text-dim);
    margin-top: 10px;
}

.result strong {
    color: var(--text);
}

/* === Buttons === */
.btn {
    background: var(--accent);
    color: #000;
    border: none;
    padding: 9px 18px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    transition: opacity 0.15s;
}

.btn:hover:not(:disabled) { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* === Tables clé/valeur === */
.kv {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.kv th, .kv td {
    text-align: left;
    padding: 8px 4px;
    border-bottom: 1px solid var(--border);
}

.kv th {
    color: var(--text-dim);
    font-weight: 500;
    width: 45%;
}

.kv tr:last-child th, .kv tr:last-child td {
    border-bottom: none;
}

/* === Footer === */
.footer {
    display: flex;
    justify-content: space-between;
    padding: 14px 28px;
    background: var(--bg-elev);
    border-top: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 12px;
}

/* === Login === */
.login-wrapper {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px 36px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-logo {
    font-size: 40px;
    color: var(--accent);
    margin-bottom: 8px;
}

.login-box h1 {
    font-size: 28px;
    margin-bottom: 6px;
}

.login-box .subtitle {
    color: var(--text-dim);
    font-size: 14px;
    margin-bottom: 24px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 18px;
    text-align: left;
}

.login-form label {
    font-size: 13px;
    color: var(--text-dim);
}

.login-form input {
    padding: 12px 14px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    border-radius: 6px;
    font-size: 14px;
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    margin-top: 8px;
}

.hint {
    margin-top: 22px;
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.6;
}

.hint code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent);
    font-family: Consolas, monospace;
}

/* === Alerts === */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-error {
    background: rgba(246, 70, 93, 0.1);
    border: 1px solid var(--red);
    color: var(--red);
}

.alert-warning {
    background: rgba(255, 147, 50, 0.08);
    border: 1px solid var(--orange);
    color: var(--orange);
    margin-top: 24px;
}

.alert-warning code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: Consolas, monospace;
    color: var(--accent);
}

/* === Dashboard summary cards === */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.metric {
    padding: 18px 20px;
}

.metric-label {
    font-size: 12px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.metric-value {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 4px;
}

.metric-value.mode-testnet { color: var(--orange); }
.metric-value.mode-production { color: var(--red); }

.metric-sub {
    font-size: 12px;
    color: var(--text-dim);
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* === Sections + tables === */
.section {
    margin-bottom: 22px;
    padding: 22px;
}

.section h2 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--accent);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 10px;
}

.section-header h2 { margin: 0; }

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

/* Ascenseur vertical pour les longues listes (ex : 130+ monnaies surveillees).
   L'en-tete reste fige en haut pendant le defilement. */
.table-wrap.scroll-y {
    max-height: 65vh;
    overflow-y: auto;
}
.table-wrap.scroll-y .data-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 11px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--bg-elev);
    color: var(--text-dim);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.data-table .loading,
.data-table .error {
    text-align: center;
    padding: 30px;
    color: var(--text-dim);
}

.data-table .error { color: var(--red); }

.pos { color: var(--green); font-weight: 600; }
.neg { color: var(--red); font-weight: 600; }

.badge {
    display: inline-block;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 6px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.badge-earn {
    background: rgba(46, 189, 133, 0.15);
    color: var(--green);
    border: 1px solid var(--green);
}

/* === Selects === */
select {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 7px 12px;
    font-size: 13px;
}

select:focus { outline: none; border-color: var(--accent); }

.chart-controls { display: flex; gap: 8px; }

/* === Chart === */
.chart-wrap {
    position: relative;
    height: 380px;
    width: 100%;
}

/* === Trades summary === */
.trades-summary {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 12px;
    font-size: 13px;
}

.trades-summary span { color: var(--text-dim); }
.trades-summary strong { color: var(--text); }

/* === Boutons supplementaires === */
.btn-small { padding: 5px 12px; font-size: 12px; }
.btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
    text-decoration: none;
    display: inline-block;
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }

/* === Page header (titres de page) === */
.page-header {
    margin-bottom: 22px;
}
.page-header h1 {
    font-size: 28px;
    margin-bottom: 6px;
}
.page-header .subtitle {
    color: var(--text-dim);
    font-size: 14px;
}

/* === Opportunites grid === */
.opps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.opp-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    border-left-width: 4px;
}
.opp-card.side-buy { border-left-color: var(--green); }
.opp-card.side-sell { border-left-color: var(--red); }

.opp-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}
.opp-symbol {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
}
.opp-tf {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 2px;
}
.opp-side {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.opp-card.side-buy .opp-side {
    background: rgba(46,189,133,0.15);
    color: var(--green);
}
.opp-card.side-sell .opp-side {
    background: rgba(246,70,93,0.15);
    color: var(--red);
}

.opp-signal {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
}
.opp-stars {
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--accent);
}
.opp-stars .stars-empty { color: var(--border); }

.opp-rationale {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 12px;
    line-height: 1.4;
}

.opp-prices {
    width: 100%;
    font-size: 13px;
    margin-bottom: 12px;
}
.opp-prices td {
    padding: 4px 0;
}
.opp-prices td:first-child {
    color: var(--text-dim);
    width: 50%;
}

.opp-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.opp-mini {
    background: var(--bg);
    border-left: 3px solid var(--border);
    padding: 8px 12px;
    margin-bottom: 6px;
    border-radius: 4px;
    font-size: 13px;
}
.opp-mini.side-buy { border-left-color: var(--green); }
.opp-mini.side-sell { border-left-color: var(--red); }

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

.muted { color: var(--text-dim); font-size: 13px; }

/* === Tendance + signal tag === */
.trend {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.trend-haussier { background: rgba(46,189,133,0.15); color: var(--green); }
.trend-baissier { background: rgba(246,70,93,0.15); color: var(--red); }
.trend-neutre { background: rgba(138,147,166,0.15); color: var(--text-dim); }

.signal-tag {
    background: rgba(240,185,11,0.15);
    color: var(--accent);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

/* === Modal === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    max-width: 760px;
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 { color: var(--accent); margin: 0; font-size: 20px; }
.modal-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 28px;
    cursor: pointer;
    padding: 0 8px;
    line-height: 1;
}
.modal-close:hover { color: var(--text); }

#modal-body h3 {
    font-size: 14px;
    color: var(--accent);
    margin-bottom: 8px;
}

/* === Bot page === */
.bot-status-banner {
    padding: 16px 20px;
    border-radius: 10px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
}
.bot-status-banner.status-stopped {
    background: rgba(138,147,166,0.08);
    border-color: var(--text-dim);
}
.bot-status-banner.status-paper {
    background: rgba(255,147,50,0.08);
    border-color: var(--orange);
}
.bot-status-banner.status-live {
    background: rgba(246,70,93,0.08);
    border-color: var(--red);
    box-shadow: 0 0 12px rgba(246,70,93,0.3);
}
.bot-status-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
}
.bot-status-value {
    font-size: 24px;
    font-weight: 700;
    margin-top: 4px;
}
.bot-status-stopped .bot-status-value { color: var(--text-dim); }
.bot-status-paper .bot-status-value { color: var(--orange); }
.bot-status-live .bot-status-value { color: var(--red); }

.danger-zone {
    border: 2px solid var(--red);
    background: rgba(246,70,93,0.05);
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 22px;
}
.danger-zone h3 {
    color: var(--red);
    font-size: 14px;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bot-config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}
.bot-config-grid label {
    display: flex;
    flex-direction: column;
    font-size: 12px;
    color: var(--text-dim);
    gap: 6px;
}
.bot-config-grid input[type="number"],
.bot-config-grid select {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 9px 12px;
    border-radius: 6px;
    font-size: 14px;
}

.btn-danger {
    background: var(--red);
    color: white;
}
.btn-danger:hover:not(:disabled) { opacity: 0.85; }

.btn-success {
    background: var(--green);
    color: white;
}

.kill-switch {
    background: var(--red);
    color: white;
    font-size: 14px;
    font-weight: 700;
    padding: 12px 22px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.kill-switch:hover:not(:disabled) {
    background: #d63853;
}
.kill-switch:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.bot-log {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 14px;
    font-family: Consolas, monospace;
    font-size: 12px;
    max-height: 320px;
    overflow-y: auto;
}
.bot-log-line {
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
.bot-log-line.lvl-INFO { color: var(--text-dim); }
.bot-log-line.lvl-WARN { color: var(--orange); }
.bot-log-line.lvl-ERROR { color: var(--red); }
.bot-log-line.lvl-TRADE { color: var(--green); }

.warning-box {
    background: rgba(255,147,50,0.08);
    border: 1px solid var(--orange);
    color: var(--orange);
    padding: 14px 18px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 18px;
}

/* === Apprentissage === */
.events-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.event-item {
    display: flex;
    gap: 14px;
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-left-width: 3px;
    border-left-color: var(--accent);
    border-radius: 6px;
}
.event-icon {
    font-size: 22px;
    line-height: 1;
}
.event-body { flex: 1; }
.event-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
}
.event-desc {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.5;
    margin-bottom: 4px;
}
.event-impact {
    font-size: 12px;
    color: var(--accent);
    font-style: italic;
}
.event-time {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 6px;
}

.mode-switch.active {
    background: var(--accent);
    color: #000;
}

@keyframes fadein {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Indicateur "live" (point qui pulse a chaque tick reseau) === */
.live-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--text-dim);
    margin-right: 6px;
    transition: background 0.2s, box-shadow 0.2s;
    vertical-align: middle;
}
.live-dot.connected {
    background: var(--green);
    box-shadow: 0 0 0 0 rgba(46,189,133,0.6);
}
.live-dot.connected.pulse {
    animation: livepulse 0.6s ease-out;
}
@keyframes livepulse {
    0%   { box-shadow: 0 0 0 0 rgba(46,189,133,0.7); transform: scale(1); }
    50%  { box-shadow: 0 0 0 8px rgba(46,189,133,0); transform: scale(1.3); }
    100% { box-shadow: 0 0 0 0 rgba(46,189,133,0); transform: scale(1); }
}

/* === Flash sur changement de prix === */
@keyframes flashUp {
    0%   { background: rgba(46,189,133,0.45); }
    100% { background: transparent; }
}
@keyframes flashDown {
    0%   { background: rgba(246,70,93,0.45); }
    100% { background: transparent; }
}
.flash-up   { animation: flashUp 0.6s ease-out; }
.flash-down { animation: flashDown 0.6s ease-out; }

/* === Responsive === */
@media (max-width: 640px) {
    .topbar { flex-direction: column; gap: 10px; padding: 12px; }
    .nav { flex-wrap: wrap; justify-content: center; }
    .main { padding: 18px 14px; }
    .hero h1 { font-size: 26px; }
    .status-grid, .summary-grid { grid-template-columns: 1fr; }
    .footer { flex-direction: column; gap: 6px; text-align: center; }
    .data-table th, .data-table td { padding: 8px 10px; font-size: 13px; }
    .chart-wrap { height: 280px; }
}
