@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    color-scheme: dark;

    /* Core Dracula palette */
    --bg-primary:    #282a36;
    --bg-secondary:  #44475a;
    --bg-selection:  #44475a;
    --fg-primary:    #f8f8f2;
    --fg-secondary:  #6272a4;

    /* Accents */
    --accent-cyan:   #8be9fd;
    --accent-green:  #50fa7b;
    --accent-orange: #ffb86c;
    --accent-pink:   #ff79c6;
    --accent-purple: #bd93f9;
    --accent-red:    #ff5555;
    --accent-yellow: #f1fa8c;

    /* Extended palette */
    --bg-card:   #2d2f3d;
    --bg-input:  #1e1f2b;
    --bg-hover:  rgba(68, 71, 90, 0.4);

    /* Borders & shadows */
    --border-color:   rgba(68, 71, 90, 0.7);
    --border-subtle:  rgba(68, 71, 90, 0.35);
    --shadow-dark:    rgba(0, 0, 0, 0.3);
    --shadow-card:    0 4px 24px rgba(0, 0, 0, 0.3);
    --glow-purple:    0 0 20px rgba(189, 147, 249, 0.25);
    --glow-cyan:      0 0 20px rgba(139, 233, 253, 0.2);
    --glow-green:     0 0 20px rgba(80, 250, 123, 0.2);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #bd93f9, #ff79c6);
    --gradient-accent:  linear-gradient(135deg, #8be9fd, #50fa7b);
    --gradient-fire:    linear-gradient(135deg, #ffb86c, #ff5555);
    --gradient-title:   linear-gradient(135deg, #bd93f9, #8be9fd);

    /* Radii */
    --border-radius:    8px;
    --border-radius-lg: 12px;
    --border-radius-sm: 4px;

    /* Transitions */
    --transition-fast:   0.15s ease;
    --transition-smooth: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    /* Legacy aliases */
    --shadow-light: rgba(255, 255, 255, 0.05);
    --text-color:   #f8f8f2;
    --text-muted:   #6272a4;
    --cyan:    #8be9fd;
    --green:   #50fa7b;
    --orange:  #ffb86c;
    --pink:    #ff79c6;
    --purple:  #bd93f9;
    --red:     #ff5555;
    --yellow:  #f1fa8c;

    /* Aliases Dracula clássico (usados em spkalc.css e styles.css) */
    --background:    #282a36;
    --current-line:  #44475a;
    --foreground:    #f8f8f2;
    --comment:       #6272a4;

    /* Fundo mais profundo e canais RGB para transparências: rgba(var(--rgb-x), a) */
    --bg-deep:           #1e2029;
    --rgb-purple:        189, 147, 249;
    --rgb-cyan:          139, 233, 253;
    --rgb-green:         80, 250, 123;
    --rgb-orange:        255, 184, 108;
    --rgb-pink:          255, 121, 198;
    --rgb-red:           255, 85, 85;
    --rgb-yellow:        241, 250, 140;
    --rgb-fg:            248, 248, 242;
    --rgb-comment:       98, 114, 164;
    --rgb-bg:            40, 42, 54;
    --rgb-bg-secondary:  68, 71, 90;
    --rgb-bg-input:      30, 31, 43;
    --rgb-bg-deep:       30, 32, 41;
    --rgb-overlay:       255, 255, 255;
}

/* Tema claro: mesma estrutura do Dracula, acentos escurecidos para contraste AA. */
:root[data-theme="light"] {
    color-scheme: light;

    --bg-primary:    #f3f4f8;
    --bg-secondary:  #e2e4ee;
    --bg-selection:  #d9dcf0;
    --fg-primary:    #1f2130;
    --fg-secondary:  #555d80;

    --accent-cyan:   #0b6d8c;
    --accent-green:  #1a7f3c;
    --accent-orange: #b0570b;
    --accent-pink:   #b0236f;
    --accent-purple: #6a3fcf;
    --accent-red:    #c62828;
    --accent-yellow: #876a00;

    --bg-card:   #ffffff;
    --bg-input:  #ffffff;
    --bg-hover:  rgba(31, 33, 48, 0.05);
    --bg-deep:   #e9ebf3;

    --border-color:   rgba(31, 33, 48, 0.16);
    --border-subtle:  rgba(31, 33, 48, 0.09);
    --shadow-dark:    rgba(31, 33, 48, 0.12);
    --shadow-card:    0 2px 14px rgba(31, 33, 48, 0.08);
    --glow-purple:    0 0 16px rgba(106, 63, 207, 0.16);
    --glow-cyan:      0 0 16px rgba(11, 109, 140, 0.14);
    --glow-green:     0 0 16px rgba(26, 127, 60, 0.14);

    --gradient-primary: linear-gradient(135deg, #6a3fcf, #b0236f);
    --gradient-accent:  linear-gradient(135deg, #0b6d8c, #1a7f3c);
    --gradient-fire:    linear-gradient(135deg, #d0650f, #c62828);
    --gradient-title:   linear-gradient(135deg, #6a3fcf, #0b6d8c);

    --shadow-light: rgba(31, 33, 48, 0.04);
    --text-color:   #1f2130;
    --text-muted:   #555d80;
    --cyan:    #0b6d8c;
    --green:   #1a7f3c;
    --orange:  #b0570b;
    --pink:    #b0236f;
    --purple:  #6a3fcf;
    --red:     #c62828;
    --yellow:  #876a00;

    --background:    #f3f4f8;
    --current-line:  #e2e4ee;
    --foreground:    #1f2130;
    --comment:       #555d80;

    /* Nomes usados com fallback claro fixo em algumas folhas */
    --text-primary:   #1f2130;
    --text-secondary: #4b5272;
    --fg-muted:       #555d80;
    --dracula-orange: #b0570b;

    --rgb-purple:        106, 63, 207;
    --rgb-cyan:          11, 109, 140;
    --rgb-green:         26, 127, 60;
    --rgb-orange:        176, 87, 11;
    --rgb-pink:          176, 35, 111;
    --rgb-red:           198, 40, 40;
    --rgb-yellow:        135, 106, 0;
    --rgb-fg:            31, 33, 48;
    --rgb-comment:       85, 93, 128;
    --rgb-bg:            255, 255, 255;
    --rgb-bg-secondary:  130, 136, 162;
    --rgb-bg-input:      243, 244, 248;
    --rgb-bg-deep:       233, 235, 243;
    --rgb-overlay:       31, 33, 48;
}

/* ── Base ── */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

/* Cross-fade entre páginas (View Transitions API — progressivo, só Chromium) */
@view-transition {
    navigation: auto;
}
::view-transition-old(root) {
    animation: vt-fade-out 0.16s ease-in both;
}
::view-transition-new(root) {
    animation: vt-fade-in 0.22s ease-out both;
}
@keyframes vt-fade-out {
    to { opacity: 0; }
}
@keyframes vt-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

body {
    background-color: var(--bg-primary);
    color: var(--fg-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--accent-cyan);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover { color: var(--accent-purple); }

h1, h2, h3, h4, h5, h6 {
    color: var(--accent-purple);
    margin-top: 0;
    line-height: 1.3;
}

button {
    background: var(--bg-secondary);
    border: none;
    border-radius: var(--border-radius);
    color: var(--fg-primary);
    cursor: pointer;
    padding: 0.5rem 1rem;
    transition: all var(--transition-smooth);
    font-family: inherit;
}
button:hover:not(.feature-card) { background: var(--accent-purple); }

input, select, textarea {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--fg-primary);
    padding: 0.5rem 0.75rem;
    font-family: inherit;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
input:hover:not(:focus), select:hover:not(:focus), textarea:hover:not(:focus) {
    border-color: rgba(var(--rgb-purple), 0.35);
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent-purple);
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--rgb-purple), 0.15);
}

/* Force dark background on native dropdown options */
select option {
    background: var(--bg-input);
    color: var(--fg-primary);
}

code, pre {
    background: var(--bg-input);
    border-radius: var(--border-radius);
    color: var(--accent-green);
    font-family: 'Fira Code', 'Consolas', monospace;
    padding: 0.2em 0.4em;
}
pre { padding: 1rem; overflow-x: auto; }

table { border-collapse: collapse; width: 100%; }
th, td {
    border: 1px solid var(--border-color);
    padding: 0.625rem 0.875rem;
    text-align: left;
}
th { background: var(--bg-card); color: var(--fg-secondary); font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.4px; }

ul, ol { padding-left: 1.5rem; }
li { margin: 0.375rem 0; }

blockquote {
    border-left: 3px solid var(--accent-purple);
    margin: 1rem 0;
    padding: 0.75rem 1.25rem;
    background: var(--bg-card);
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

::selection {
    background: rgba(var(--rgb-purple), 0.25);
    color: var(--fg-primary);
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(var(--rgb-bg-secondary), 0.7);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--accent-purple); }

/* ── Loading ── */
.loading-spinner {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 3px solid rgba(var(--rgb-purple), 0.14);
    border-top-color: var(--accent-purple);
    border-right-color: var(--accent-cyan);
    animation: spin 0.75s cubic-bezier(0.55, 0.15, 0.45, 0.85) infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(var(--rgb-bg-input), 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}
.loading-overlay.active {
    display: flex;
    animation: overlay-in 0.22s ease-out;
}
.loading-overlay.active .loading-content {
    animation: overlay-content-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes overlay-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes overlay-content-in {
    from { opacity: 0; transform: scale(0.9); }
    to   { opacity: 1; transform: scale(1); }
}

.loading-content {
    text-align: center;
}
.loading-content p {
    color: var(--fg-secondary);
    margin-top: 1rem;
    font-size: 0.875rem;
}

/* ── Skip link (acessibilidade) ── */
.skip-link {
    position: fixed;
    top: 0;
    left: 0;
    margin: 8px;
    padding: 0.6rem 1rem;
    background: var(--accent-purple);
    color: var(--bg-input);
    font-weight: 600;
    border-radius: var(--border-radius);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    transform: translateY(-150%);
    transition: transform var(--transition-fast);
    z-index: 10000;
}
.skip-link:focus {
    transform: translateY(0);
    color: var(--bg-input);
    outline: 2px solid var(--fg-primary);
    outline-offset: 2px;
}

/* ── Foco visível por teclado ── */
a:focus-visible,
button:focus-visible,
.tab-button:focus-visible,
.tab-dd-item:focus-visible,
.feature-card:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--accent-purple);
    outline-offset: 2px;
}
/* Alvo do skip link não exibe contorno ao receber foco programático */
[tabindex="-1"]:focus { outline: none; }

/* ── Respeita preferência por menos movimento ── */
@media (prefers-reduced-motion: reduce) {
    @view-transition {
        navigation: none;
    }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-delay: 0s !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        transition-delay: 0s !important;
        scroll-behavior: auto !important;
    }
}

/* Ícone de sprinkler (Font Awesome Free não possui) */
.fa-fb-sprinkler::before { content: none; }
.fa-fb-sprinkler {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><rect x='9.5' y='1' width='5' height='2.4' rx='.6'/><path d='M6.8 3.9h10.4l-1.1 2.9H7.9z'/><path d='M8.7 6.6 11.1 15M15.3 6.6 12.9 15' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round'/><ellipse cx='12' cy='10.4' rx='1.2' ry='2.6'/><rect x='10.7' y='14.4' width='2.6' height='1.9' rx='.4'/><rect x='4.2' y='16.4' width='15.6' height='1.6' rx='.8'/><path d='M5.6 19.2s1.3 1.4 1.3 2.3a1.3 1.3 0 0 1-2.6 0c0-.9 1.3-2.3 1.3-2.3zM12 19.8s1.3 1.4 1.3 2.3a1.3 1.3 0 0 1-2.6 0c0-.9 1.3-2.3 1.3-2.3zM18.4 19.2s1.3 1.4 1.3 2.3a1.3 1.3 0 0 1-2.6 0c0-.9 1.3-2.3 1.3-2.3z'/></svg>") center / contain no-repeat;
    mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><rect x='9.5' y='1' width='5' height='2.4' rx='.6'/><path d='M6.8 3.9h10.4l-1.1 2.9H7.9z'/><path d='M8.7 6.6 11.1 15M15.3 6.6 12.9 15' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round'/><ellipse cx='12' cy='10.4' rx='1.2' ry='2.6'/><rect x='10.7' y='14.4' width='2.6' height='1.9' rx='.4'/><rect x='4.2' y='16.4' width='15.6' height='1.6' rx='.8'/><path d='M5.6 19.2s1.3 1.4 1.3 2.3a1.3 1.3 0 0 1-2.6 0c0-.9 1.3-2.3 1.3-2.3zM12 19.8s1.3 1.4 1.3 2.3a1.3 1.3 0 0 1-2.6 0c0-.9 1.3-2.3 1.3-2.3zM18.4 19.2s1.3 1.4 1.3 2.3a1.3 1.3 0 0 1-2.6 0c0-.9 1.3-2.3 1.3-2.3z'/></svg>") center / contain no-repeat;
}
