/* ============================================================
   TAC Viewer — Design System
   Dark mode primario. Variables → modo claro como excepción.
   ============================================================ */

/* Inter variable font — self-hosted, no CDN, funciona offline */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('fonts/inter-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
                   U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
                   U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
                   U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('fonts/inter-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
                   U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F,
                   U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
                   U+FEFF, U+FFFD;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select { font-family: inherit; }
svg { display: block; pointer-events: none; }

/* ── Variables — dark mode (principal) ──────────────────── */
:root {
    /* Marca */
    --brand-primary:       #1e3872;
    --brand-accent:        #78daab;
    --brand-accent-dark:   #5bc492;

    /* Semánticos */
    --success:  #10b981;
    --danger:   #ef4444;
    --warning:  #f59e0b;
    --info:     #3b82f6;

    /* Fondos dark */
    --bg-body:       #060a12;
    --bg-app:        #0b1120;
    --bg-card:       #111827;
    --bg-secondary:  #1e293b;
    --bg-tertiary:   #334155;
    --input-bg:      #1e293b;

    /* Texto dark */
    --text-primary:   #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary:  #64748b;

    /* Bordes dark */
    --border:         #1e293b;
    --border-strong:  #334155;

    /* Sombras dark */
    --shadow-sm:  0 1px 3px rgba(0,0,0,0.5);
    --shadow-md:  0 4px 12px rgba(0,0,0,0.5);
    --shadow-lg:  0 10px 30px rgba(0,0,0,0.6);

    /* Radios */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    /* Transiciones */
    --fast:   150ms cubic-bezier(0.4,0,0.2,1);
    --normal: 250ms cubic-bezier(0.4,0,0.2,1);

    /* CT Viewer específico */
    --viewport-bg:        #000000;
    --overlay-text:       rgba(255,255,255,0.88);
    --overlay-shadow:     1px 1px 3px rgba(0,0,0,0.95);
    --measure-color:      #FFD700;
    --measure-active:     #FF6B35;
    --roi-fill:           rgba(0,180,255,0.12);
    --thumb-active-border:#78daab;
    --toolbar-bg:         #0d1526;
    --toolbar-height:     52px;
    --sidebar-width:      88px;
    --meta-width:         272px;
    --statusbar-height:   26px;
    --tool-btn-size:      34px;
}

/* ── Tipografía base ─────────────────────────────────────── */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-body);
    -webkit-font-smoothing: antialiased;
}

/* ── Utilidades ─────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Animaciones globales ───────────────────────────────── */
@keyframes fadeIn    { from { opacity: 0; }                       to { opacity: 1; } }
@keyframes fadeOut   { from { opacity: 1; }                       to { opacity: 0; } }
@keyframes scaleIn   { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes slideDown { from { transform: translateY(-8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideUp   { from { transform: translateY(8px);  opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes spin      { to { transform: rotate(360deg); } }
@keyframes pulse     { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── Drop zone ──────────────────────────────────────────── */
#dropZone {
    position: fixed; inset: 0; z-index: 9000;
    background: rgba(6,10,18,0.85);
    backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.15s ease;
}
#dropZoneInner {
    border: 2px dashed var(--brand-accent);
    border-radius: var(--radius-lg);
    padding: 60px 80px;
    text-align: center;
    animation: scaleIn 0.2s ease;
}
.drop-icon   { font-size: 48px; margin-bottom: 16px; }
.drop-title  { font-size: 20px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.drop-sub    { font-size: 13px; color: var(--text-secondary); }

/* ── Botones genéricos ──────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600;
    transition: all var(--fast);
}
.btn:active { transform: scale(0.97); }
.btn-primary {
    background: var(--brand-accent); color: #0b1120;
}
.btn-primary:hover { background: var(--brand-accent-dark); }

/* ── Toast ──────────────────────────────────────────────── */
#toastContainer {
    position: fixed; bottom: 36px; right: 16px;
    z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; border-radius: var(--radius-md);
    background: var(--bg-card); border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg); font-size: 13px; font-weight: 500;
    animation: slideUp 0.25s ease;
    max-width: 320px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger);  }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info    { border-left: 3px solid var(--info);    }

/* ── Probe tooltip ──────────────────────────────────────── */
#probeTooltip {
    position: fixed; z-index: 8000; pointer-events: none;
    background: rgba(0,0,0,0.85); border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm); padding: 6px 10px;
    font-size: 12px; font-weight: 600; color: var(--brand-accent);
    backdrop-filter: blur(4px);
    white-space: nowrap;
}

/* ── Welcome screen ─────────────────────────────────────── */
#welcomeScreen {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--viewport-bg);
    z-index: 100;
    animation: fadeIn 0.3s ease;
}
.welcome-inner { text-align: center; max-width: 400px; }
.welcome-icon  { font-size: 56px; margin-bottom: 20px; color: var(--brand-accent); }
.welcome-title {
    font-size: 28px; font-weight: 800; margin-bottom: 6px;
    background: linear-gradient(135deg, var(--brand-accent), #5bc492);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.welcome-sub   { color: var(--text-secondary); margin-bottom: 32px; }
.btn-welcome-open {
    display: inline-flex; align-items: center; gap: 10px;
    background: linear-gradient(135deg, var(--brand-accent-dark), var(--brand-accent));
    color: #0b1120; font-size: 15px; font-weight: 700;
    padding: 14px 28px; border-radius: var(--radius-md);
    border: none; cursor: pointer;
    transition: all var(--normal); margin-bottom: 12px;
    box-shadow: 0 4px 20px rgba(120,218,171,0.3);
}
.btn-welcome-open:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(120,218,171,0.4); }
.welcome-drag { color: var(--text-tertiary); font-size: 12px; margin-bottom: 28px; }
.welcome-info {
    display: flex; gap: 16px; justify-content: center; flex-wrap: wrap;
    color: var(--text-tertiary); font-size: 11px;
}
.welcome-info span {
    background: var(--bg-secondary); padding: 4px 8px;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
}

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ── PWA Update banner ───────────────────────────────────── */
.sw-update-banner {
    position: fixed;
    bottom: calc(var(--statusbar-height) + 8px);
    left: 50%; transform: translateX(-50%);
    z-index: 800;
    display: flex; align-items: center; gap: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--brand-accent);
    border-radius: var(--radius);
    padding: 8px 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    font-size: 12px; color: var(--text-primary);
    white-space: nowrap;
    animation: slideUp 0.25s ease;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateX(-50%) translateY(12px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.sw-update-banner span { color: var(--text-secondary); }
.sw-update-banner svg  { color: var(--brand-accent); flex-shrink: 0; }
#btnSwUpdateNow {
    padding: 4px 12px;
    background: var(--brand-accent);
    color: #0f172a; font-size: 11px; font-weight: 700;
    border-radius: var(--radius-sm);
    transition: opacity var(--fast);
}
#btnSwUpdateNow:hover { opacity: 0.85; }
#btnSwUpdateLater {
    padding: 4px 8px;
    font-size: 11px; color: var(--text-tertiary);
    border-radius: var(--radius-sm);
    transition: color var(--fast);
}
#btnSwUpdateLater:hover { color: var(--text-primary); }

/* ── Mobile / Touch ─────────────────────────────────────── */

/* Evitar que el browser intercepte gestos sobre los canvases */
.gl-canvas, .overlay-canvas {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Banner de modo iOS — fixed para no interferir con el grid del appShell */
.caps-warning {
    position: fixed;
    bottom: 36px;          /* encima del status bar */
    left: 0; right: 0;
    z-index: 600;
    background: rgba(15,23,42,0.88);
    border-top: 1px solid rgba(234,179,8,0.35);
    color: #fbbf24; font-size: 10px;
    padding: 4px 10px; text-align: center;
    pointer-events: none;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Tablet: thumbnails más fáciles de tocar */
.is-touch .thumb-item { min-height: 88px; }
