/* =============================================
   Tool-specific styles (calculator UI)
   Inherits from style.css base variables
   ============================================= */

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 48px;
    text-align: center;
    background: var(--surface);
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 28px;
    position: relative;
    overflow: hidden;
}
.drop-zone::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 50%, rgba(0,212,255,0.03), transparent 70%);
    pointer-events: none;
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--accent);
    background: var(--surface2);
    box-shadow: 0 0 40px rgba(0,212,255,0.08);
}
.drop-icon { font-size: 48px; margin-bottom: 12px; filter: grayscale(0.5); }
.drop-title { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.drop-sub { font-size: 13px; color: var(--muted); font-family: var(--font-mono); }
.drop-btn {
    display: inline-block;
    margin-top: 16px;
    padding: 10px 24px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #000;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    letter-spacing: 0.5px;
    transition: opacity 0.2s;
}
.drop-btn:hover { opacity: 0.85; }
#fileInput { display: none; }

/* Year Filter */
.controls {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.year-btn {
    padding: 5px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.year-btn.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}
.year-btn:hover:not(.active) { border-color: var(--accent); color: var(--text); }

.export-btn {
    margin-left: auto;
    padding: 5px 12px;
    border-radius: 6px;
    border: 1px solid var(--gain);
    background: transparent;
    color: var(--gain);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.export-btn:hover { background: var(--gain); color: #000; }

/* Summary Cards */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 28px;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
}
.card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
}
.card.total::after { background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.card.gain-card::after { background: var(--gain); }
.card.loss-card::after { background: var(--loss); }
.card.neutral::after { background: var(--warn); }

.card-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 8px; font-family: var(--font-display); }
.card-value { font-size: 20px; font-weight: 800; font-family: var(--font-mono); word-break: break-word; }
.card-value.positive { color: var(--gain); }
.card-value.negative { color: var(--loss); }
.card-value.neutral-val { color: var(--warn); }

/* Auto-shrink large numbers */
.card {
    overflow: hidden;
}

@media (max-width: 1400px) {
    .card-value { font-size: 18px; }
}
@media (max-width: 1200px) {
    .card-value { font-size: 16px; }
}

/* Sections */
.section { margin-bottom: 32px; }
.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.section-title { font-size: 16px; font-weight: 700; }
.section-badge {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 12px;
    color: var(--muted);
    font-family: var(--font-mono);
}

/* Table */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }
.tool-container table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tool-container thead { background: var(--surface); }
.tool-container th {
    padding: 11px 14px;
    text-align: left;
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
th.num, td.num { text-align: right; }
.tool-container td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(30,45,69,0.5);
    font-family: var(--font-mono);
    font-size: 12px;
    white-space: nowrap;
}
.tool-container tr:last-child td { border-bottom: none; }
.tool-container tr:hover td { background: rgba(255,255,255,0.02); }

.asset-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 5px;
    background: var(--surface2);
    border: 1px solid var(--border);
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.5px;
    color: var(--accent);
}

td.gain { color: var(--gain); font-weight: 700; }
td.loss { color: var(--loss); font-weight: 700; }

.asset-table td { font-size: 13px; }
.gain-row td { background: rgba(34,197,94,0.04); }
.loss-row td { background: rgba(239,68,68,0.04); }

.pct-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}
.pct-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.8s ease;
}

/* Status */
.status {
    padding: 12px 18px;
    border-radius: 10px;
    background: var(--surface);
    border-left: 3px solid var(--accent);
    font-family: var(--font-mono);
    font-size: 13px;
    margin-bottom: 20px;
    display: none;
}
.status.show { display: block; }
.status.error { border-color: var(--loss); color: var(--loss); }

.note {
    font-size: 11px;
    color: var(--muted);
    font-family: var(--font-mono);
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--surface);
    border-radius: 6px;
    border-left: 2px solid var(--warn);
}

.hidden { display: none !important; }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; }
.tab {
    padding: 8px 18px;
    border-radius: 8px 8px 0 0;
    border: 1px solid var(--border);
    border-bottom: none;
    background: var(--surface);
    color: var(--muted);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}
.tab.active { background: var(--surface2); color: var(--text); border-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Asset History */
.hist-controls { display:flex; gap:12px; align-items:center; margin-bottom:24px; flex-wrap:wrap; }
.hist-select {
    padding: 8px 16px; background: var(--surface2); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text); font-family: var(--font-display);
    font-weight: 600; font-size: 14px; cursor: pointer; min-width: 160px;
}
.hist-select:focus { outline: none; border-color: var(--accent); }
.hist-year-btn {
    padding: 6px 14px; border-radius: 7px; border: 1px solid var(--border);
    background: var(--surface); color: var(--muted); font-family: var(--font-display);
    font-weight: 600; font-size: 12px; cursor: pointer; transition: all 0.2s;
}
.hist-year-btn.active { background: var(--accent2); color: #fff; border-color: var(--accent2); }
.hist-year-btn:hover:not(.active) { border-color: var(--accent2); color: var(--text); }
.hist-kpi-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:12px; margin-bottom:24px; width:100%; }
.hist-kpi { background:var(--surface); border:1px solid var(--border); border-radius:10px; padding:14px 16px; }
.hist-kpi::after { content:''; display:block; height:2px; margin-top:10px; border-radius:1px; }
.hist-kpi.kpi-invested::after  { background:#60a5fa; }
.hist-kpi.kpi-recovered::after { background:#f97316; }
.hist-kpi.kpi-gain::after      { background:var(--gain); }
.hist-kpi.kpi-loss::after      { background:var(--loss); }
.hist-kpi.kpi-balance::after   { background:var(--accent); }
.hist-kpi.kpi-price::after     { background:var(--warn); }
.hist-kpi-label { font-size:10px; text-transform:uppercase; letter-spacing:1px; color:var(--muted); margin-bottom:6px; font-family:var(--font-mono); }
.hist-kpi-value { font-size:20px; font-weight:800; font-family:var(--font-mono); }
.hist-chart-wrap { background:var(--surface); border:1px solid var(--border); border-radius:12px; padding:16px; margin-bottom:20px; }
.hist-chart-title { font-size:11px; font-weight:700; margin-bottom:10px; color:var(--muted); font-family:var(--font-mono); text-transform:uppercase; letter-spacing:0.5px; }
.timeline { position:relative; padding-left:32px; }
.timeline::before { content:''; position:absolute; left:11px; top:0; bottom:0; width:2px; background:var(--border); }
.tl-item { position:relative; margin-bottom:10px; background:var(--surface); border:1px solid var(--border); border-radius:10px; padding:12px 16px; transition:border-color 0.2s; }
.tl-item:hover { border-color:var(--accent); }
.tl-item.tl-buy    { border-left:3px solid #60a5fa; }
.tl-item.tl-sell   { border-left:3px solid #f97316; }
.tl-item.tl-reward { border-left:3px solid var(--warn); }
.tl-dot { position:absolute; left:-26px; top:14px; width:12px; height:12px; border-radius:50%; border:2px solid var(--bg); }
.tl-buy .tl-dot    { background:#60a5fa; }
.tl-sell .tl-dot   { background:#f97316; }
.tl-reward .tl-dot { background:var(--warn); }
.tl-header { display:flex; align-items:center; gap:10px; margin-bottom:8px; flex-wrap:wrap; }
.tl-date { font-size:11px; color:var(--muted); font-family:var(--font-mono); }
.tl-type-badge { font-size:10px; font-weight:700; padding:2px 8px; border-radius:4px; letter-spacing:0.5px; font-family:var(--font-mono); }
.tl-type-buy    { background:rgba(96,165,250,0.15); color:#60a5fa; }
.tl-type-sell   { background:rgba(249,115,22,0.15); color:#f97316; }
.tl-type-reward { background:rgba(245,158,11,0.15); color:var(--warn); }
.tl-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(110px,1fr)); gap:8px; font-family:var(--font-mono); font-size:12px; }
.tl-field-label { font-size:10px; color:var(--muted); margin-bottom:2px; }
.tl-field-value { font-weight:700; }
.tl-balance { margin-top:10px; padding-top:8px; border-top:1px solid var(--border); display:flex; gap:20px; font-family:var(--font-mono); font-size:11px; color:var(--muted); flex-wrap:wrap; }
.tl-balance b { color:var(--text); }
.hist-empty { padding:60px; text-align:center; color:var(--muted); font-family:var(--font-mono); font-size:13px; }

/* CSV output */
.csv-out {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    font-family: var(--font-mono);
    font-size: 11px;
    white-space: pre;
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
    color: var(--muted);
    line-height: 1.6;
}

/* Print button */
.print-btn {
    padding: 5px 12px;
    border-radius: 6px;
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--accent);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.print-btn:hover { background: var(--accent); color: #000; }

/* Annexe 3 print section */
.annexe3-section { display: none; margin-top: 32px; }
.annexe3-section table { width: 100%; border-collapse: collapse; font-size: 12px; }
.annexe3-section th { background: #dbeafe; color: #1e3a5f; padding: 8px; border: 1px solid #93c5fd; text-align: center; font-size: 11px; }
.annexe3-section td { padding: 7px 10px; border: 1px solid #ccc; text-align: right; }
.annexe3-section td:nth-child(2) { text-align: left; }
.annexe3-section tr:last-child td { font-weight: 700; background: #f8fafc; }

/* Default: landscape for tables */
@page { size: landscape; margin: 10mm; }

/* Print styles */
@media print {
    body { background: #fff !important; color: #000 !important; padding: 5px; }
    body::before { display: none; }
    .site-nav, .drop-zone, .controls, .tabs,
    .no-print, .pct-bar, .license-bar, .disclaimer-banner, .site-footer { display: none !important; }
    #results { display: block !important; }
    .tool-container { max-width: 100%; padding: 5px; }
    .summary-grid { display: none; }

    /* Shrink tables to fit */
    table { font-size: 9px !important; }
    th { padding: 4px 6px !important; font-size: 8px !important; }
    td { padding: 4px 6px !important; font-size: 9px !important; }
    .table-wrap { overflow: visible !important; }

    /* Hide all tabs by default */
    #tab-gains, #tab-ventes, #tab-achats, #tab-history, #tab-balance, #tab-csv { display: none !important; }

    /* Default: print gains tab without tax report */
    body:not([data-print-tab]) #tab-gains { display: block !important; }
    body:not([data-print-tab]) .annexe3-section { display: none !important; }

    /* Print specific tab when data-print-tab is set */
    body[data-print-tab="gains"]   #tab-gains   { display: block !important; }
    body[data-print-tab="gains"]   .annexe3-section { display: none !important; }
    body[data-print-tab="taxreport"] #tab-gains { display: block !important; }
    body[data-print-tab="taxreport"] #tab-gains .section { display: none !important; }
    body[data-print-tab="taxreport"] #tab-gains .annexe3-section { display: block !important; }
    body[data-print-tab="ventes"]  #tab-ventes  { display: block !important; }
    body[data-print-tab="achats"]  #tab-achats  { display: block !important; }
    body[data-print-tab="history"] #tab-history { display: block !important; }
    body[data-print-tab="balance"] #tab-balance { display: block !important; }

    /* Print header with title and date */
    body[data-print-tab]::after {
        content: 'CryptoGains Report — ' attr(data-print-tab);
        display: block;
        font-size: 14px;
        font-weight: 700;
        margin-bottom: 16px;
        padding-bottom: 8px;
        border-bottom: 2px solid #000;
        text-transform: capitalize;
    }

    /* Common print styles */
    .section-header { border-bottom: 1px solid #000; }
    .section-title { color: #000 !important; }
    .section-badge { color: #666 !important; }
    .table-wrap { border: 1px solid #ccc; border-radius: 0; }
    table { font-size: 11px; }
    th { background: #f0f0f0 !important; color: #000 !important; border-bottom: 1px solid #ccc; padding: 6px 8px; }
    td { color: #000 !important; border-bottom: 1px solid #eee; padding: 5px 8px; }
    .asset-badge { background: #eee !important; color: #000 !important; border: 1px solid #ccc !important; }
    td.gain { color: #166534 !important; }
    td.loss { color: #991b1b !important; }
    .gain-row td { background: #f0fdf4 !important; }
    .loss-row td { background: #fef2f2 !important; }
    /* Asset History print styles */
    .hist-controls { margin-bottom: 16px; }
    .hist-select { background: #fff !important; color: #000 !important; border: 1px solid #ccc !important; }
    .hist-year-btn { display: none; }
    .hist-kpi { background: #f8f8f8 !important; border: 1px solid #ccc !important; }
    .hist-kpi-label { color: #666 !important; }
    .hist-kpi-value { color: #000 !important; }
    .hist-kpi.kpi-gain .hist-kpi-value { color: #166534 !important; }
    .hist-kpi.kpi-loss .hist-kpi-value { color: #991b1b !important; }
    .hist-chart-wrap { border: 1px solid #ccc !important; background: #fff !important; }
    .hist-chart-title { color: #000 !important; }
    .timeline::before { background: #ccc; }
    .tl-item { background: #fff !important; border: 1px solid #ddd !important; page-break-inside: avoid; }
    .tl-item.tl-buy    { border-left: 3px solid #3b82f6 !important; }
    .tl-item.tl-sell   { border-left: 3px solid #f97316 !important; }
    .tl-item.tl-reward { border-left: 3px solid #f59e0b !important; }
    .tl-date { color: #666 !important; }
    .tl-field-label { color: #888 !important; }
    .tl-field-value { color: #000 !important; }
    .tl-balance { border-top: 1px solid #ddd !important; color: #666 !important; }
    .tl-balance b { color: #000 !important; }
}
