/* --- VARIÁVEIS DE TEMA --- */
:root {
    --bg-body: #F8FAFC;
    --bg-card: #FFFFFF;
    --text-main: #1E293B;
    --text-muted: #64748B;
    --accent: #20B2AA; 
    --accent-gradient: linear-gradient(135deg, #20B2AA, #17a2b8);
    --border: #E2E8F0;
    --radius: 12px;
    
    --cor-dificil: #EF4444;   /* Vermelho */
    --cor-razoavel: #F59E0B;  /* Amarelo */
    --cor-facil: #10B981;     /* Verde */
    --cor-correcao: #FFA500;  /* Laranja Puro */
    
    --bg-label-estudo: rgba(0, 0, 0, 0.85); 
    --bg-input-flash: rgba(0, 0, 0, 0.95);  
    --shadow-premium: 0 12px 24px -6px rgba(0, 0, 0, 0.3);
}

body.dark-mode {
    --bg-body: #0F172A;
    --bg-card: #1E293B;
    --text-main: #F1F5F9;
    --text-muted: #94A3B8;
    --accent: #FF5252;
    --accent-gradient: linear-gradient(135deg, #FF5252, #D32F2F);
    --border: #334155;
}

body.dark-mode #resetBtn {
    background-color: #CC0000 !important; /* Vermelho mais escuro e com !important */
    border-color: #CC0000 !important;    /* Borda vermelha mais escura e com !important */
    color: #FFFFFF;                     /* Texto branco */
}

/* Bloqueia gestos do browser para permitir arraste fluído */
* { box-sizing: border-box; } 

body {
    margin: 0;
    font-family: 'Karla', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--accent-gradient);
    padding: 0.8rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    color: white;
}

.header-left { display: flex; align-items: center; gap: 15px; }
.back-btn { color: white; text-decoration: none; font-size: 1.5rem; transition: 0.2s; }
header h1 { margin: 0; font-size: 1.1rem; font-weight: 700; letter-spacing: -0.5px; }

main {
    display: flex;
    flex: 1;
    padding: 20px;
    gap: 20px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* --- SEÇÃO DA IMAGEM --- */
.image-section {
    flex: 1;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-premium);
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid var(--border);
    overflow: auto; /* Changed from hidden to auto to allow scrolling */
}

.image-viewer {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 100px; 
    background: radial-gradient(circle, var(--bg-body) 0%, var(--bg-card) 100%);
    position: relative;
    overflow: visible;
}

#lines-svg {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 40;
    overflow: visible !important;
}

#interactiveArea {
    position: relative;
    display: inline-block;
    line-height: 0;
    overflow: visible !important;
}

#mainImage {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 850px; 
    display: block;
    border-radius: 4px;
    box-shadow: 0 15px 45px rgba(0,0,0,0.25);
    user-select: none;
    -webkit-user-drag: none;
}

/* --- MARCADORES --- */
.marker { 
    position: absolute; 
    display: none; 
    z-index: 100; 
    pointer-events: none;
}
.marker.active { display: block !important; }

.marker-dot {
    width: 12px; height: 12px; /* Tamanho fixo de 12px */
    background-color: white; /* Cor de fundo branca */
    border: 3px solid white; /* Borda branca para torná-lo estático e visível */
    border-radius: 50%;
    transform: translate3d(-50%, -50%, 0);
    box-shadow: 0 0 10px rgba(0,0,0,0.5); /* Sombra para destaque */
    pointer-events: auto;
}

/* Área de toque expandida de 44px para facilidade no toque por celular */
.marker-dot::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 44px; height: 44px;
    border-radius: 50%;
    cursor: pointer;
}

/* --- EFEITO SOLICITADO: DOT AUMENTA E BRILHA --- */
.marker.highlight .marker-dot {
    transform: translate3d(-50%, -50%, 0) scale(1.6); /* Aumenta o tamanho */
    box-shadow: 0 0 20px 5px var(--cor-dificil);    /* Brilho Vermelho */
    z-index: 150;
}
.marker.highlight.razoavel .marker-dot { box-shadow: 0 0 20px 5px var(--cor-razoavel); } /* Brilho Amarelo */
.marker.highlight.facil .marker-dot { box-shadow: 0 0 20px 5px var(--cor-facil); }       /* Brilho Verde */

.marker-label {
    background: var(--bg-label-estudo) !important;
    backdrop-filter: blur(12px);
    color: #FFFFFF;
    padding: 8px 14px; 
    border: 3px solid var(--cor-dificil) !important; 
    border-radius: 4px;
    position: absolute;
    left: 0;
    top: 0;
    white-space: nowrap;
    font-weight: 700;
    font-size: 12px;
    line-height: 1.4;
    text-align: center;
    min-width: 120px; 
    box-shadow: var(--shadow-premium);
    cursor: grab;
    user-select: none;
    pointer-events: auto;
    --tx: 50px;
    --ty: -45px;
    transform: translate3d(var(--tx), var(--ty), 0);
    will-change: transform;
    z-index: 110;
    touch-action: none; /* Add this line */
}

.marker-label.dragging {
    cursor: grabbing !important;
    opacity: 0.9;
    z-index: 1000 !important;
}

/* Cores Dinâmicas (Estudo) */
.marker.dificil .marker-dot, .marker.dificil .marker-label { border-color: var(--cor-dificil) !important; }
.marker.razoavel .marker-dot, .marker.razoavel .marker-label { border-color: var(--cor-razoavel) !important; }
.marker.facil .marker-dot, .marker.facil .marker-label { border-color: var(--cor-facil) !important; }

/* Estados Flashcard */
.marker.flash-correct .marker-dot, .marker.flash-correct .marker-label { border-color: var(--cor-facil) !important; }
.marker.flash-incorrect .marker-dot, .marker.flash-incorrect .marker-label { border-color: var(--cor-dificil) !important; }


/* --- PAINEL LATERAL (O MENU) --- */
.controls-section {
    width: 380px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-premium);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 28px;
    overflow-y: auto;
    z-index: 500; /* Garante que fique por cima de tudo no layout */
}

.tabs-pills {
    display: flex;
    background: var(--bg-body);
    padding: 5px;
    border-radius: 14px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
}

.tab-pill {
    flex: 1; border: none; background: none;
    padding: 10px; border-radius: 10px;
    cursor: pointer; font-family: inherit;
    font-weight: 700; font-size: 0.8rem;
    color: var(--text-muted); transition: 0.2s;
    text-transform: uppercase;
}
.tab-pill.active { background: var(--bg-card); color: var(--accent); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.4s ease-out; }

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { margin-bottom: 10px; }
.checklist a {
    display: block; padding: 14px 18px;
    background: var(--bg-body); border-radius: 8px;
    text-decoration: none; color: var(--text-main);
    font-weight: 600; font-size: 0.9rem;
    border: 1px solid transparent; transition: 0.2s;
}
.checklist a.active { background: var(--cor-dificil); color: white; }

.btn-action {
    width: 100%; padding: 16px; border: none;
    border-radius: 8px; font-weight: 700;
    cursor: pointer; transition: 0.2s;
    margin-top: 12px; font-family: inherit;
    display: flex; align-items: center; justify-content: center;
}
.btn-primary { background: var(--accent); color: white; box-shadow: 0 4px 15px var(--accent-soft); }

/* FLASHCARD INPUT */
.flashcard-input {
    position: absolute; z-index: 1000;
    background: var(--bg-input-flash) !important; 
    color: #fff;
    border: 2px solid var(--cor-dificil) !important; 
    border-radius: 4px;
    text-align: center; font-family: inherit; font-weight: 700;
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
    font-size: 14px;
    padding: 0 10px;
    outline: none;
}
.flashcard-input.neutral { border-color: #FFFFFF !important; }
.flashcard-input.correct { border-color: var(--cor-facil) !important; }

/* CORREÇÃO EM LARANJA (SEM FUNDO) */
.revealed-answer {
    position: absolute; 
    color: var(--cor-correcao) !important; 
    background: none !important; 
    border: none !important; 
    box-shadow: none !important; 
    font-size: 16px;
    font-weight: 800;
    line-height: 1.4;
    font-style: italic;
    z-index: 1100;
    transform: translateX(-50%);
    pointer-events: none;
    text-align: center;
    white-space: nowrap;
    text-shadow: 
        -1.5px -1.5px 0 #000, 
         1.5px -1.5px 0 #000, 
        -1.5px  1.5px 0 #000, 
         1.5px  1.5px 0 #000, 
         0px    3px 8px rgba(0, 0, 0, 1), 
         0px    0px 15px rgba(0, 0, 0, 0.9);
}

#score-display { text-align: center; margin: 20px 0; font-weight: 800; font-size: 1.3rem; color: var(--accent); }
.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* --- RESPONSIVIDADE (face-diafragmatica.css) --- */
@media (max-width: 1024px) {
    main {
        flex-direction: column;
        padding: 12px;
        gap: 16px;
    }

    .image-section {
        min-height: 320px;
        max-height: 55vh;
        border-radius: 12px;
    }

    .image-viewer {
        padding: 30px 15px;
    }

    .controls-section {
        width: 100%;
        padding: 20px;
    }

    header {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 0.7rem 1.2rem;
        gap: 10px;
    }

    .header-left {
        flex-direction: row;
        width: auto;
        gap: 12px;
    }

    header h1 {
        font-size: 1.15rem;
        text-align: left;
    }

    .marker-label {
        font-size: 12px;
        padding: 8px 14px;
        min-width: 110px;
        white-space: normal;
        line-height: 1.35 !important;
    }

    .revealed-answer {
        font-size: 13px;
        line-height: 1.3 !important;
    }
}

@media (max-width: 600px) {
    main {
        padding: 8px;
        gap: 12px;
    }

    .image-section {
        min-height: 270px;
        max-height: 46vh;
    }

    .image-viewer {
        padding: 15px 8px;
    }

    .controls-section {
        padding: 14px;
    }

    .tabs-pills {
        margin-bottom: 16px;
    }

    .tab-pill {
        padding: 8px 4px;
        font-size: 0.72rem;
    }

    .checklist a {
        padding: 12px 14px;
        font-size: 0.85rem;
    }

    .btn-action {
        padding: 14px;
        font-size: 0.9rem;
    }
}

/* --- WARNING MODAL STYLES --- */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 10000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
    backdrop-filter: blur(5px);
    /* display: flex; REMOVED - will be set by JS when shown */
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--bg-card);
    margin: auto; /* Centered */
    padding: 30px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 80%; /* Could be more responsive */
    max-width: 500px; /* Max width for readability */
    box-shadow: var(--shadow-premium);
    position: relative;
    text-align: center;
    color: var(--text-main);
}

.modal-content h2 {
    color: var(--accent);
    margin-top: 0;
    font-size: 1.8rem;
}

.modal-content p {
    font-size: 1.1rem;
    margin-bottom: 25px;
}

.modal-content .btn-action {
    margin-top: 0; /* Override default btn-action margin-top */
}

.close-button {
    color: var(--text-muted);
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
}

/* --- SISTEMA DE TOUR INTERATIVO PREMIUM --- */
.tour-backdrop {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(15, 23, 42, 0.4); /* Fundo sutil se houver spotlight */
    backdrop-filter: blur(2px);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.tour-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}
.tour-backdrop.dimmed {
    background: rgba(15, 23, 42, 0.75); /* Mais escuro para passos sem spotlight */
    backdrop-filter: blur(4px);
}

.tour-popover {
    position: absolute;
    z-index: 10001;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(16px);
    border: 1.5px solid rgba(32, 178, 170, 0.3);
    border-radius: 16px;
    padding: 22px;
    width: 330px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3), inset 0 1px 1px rgba(255,255,255,0.4);
    opacity: 0;
    transform: translateY(15px);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    color: #1E293B;
}

body.dark-mode .tour-popover {
    background: rgba(30, 41, 59, 0.9);
    border-color: rgba(255, 82, 82, 0.3);
    box-shadow: 0 20px 50px rgba(0,0,0,0.6), inset 0 1px 1px rgba(255,255,255,0.05);
    color: #F1F5F9;
}

.tour-popover.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.tour-popover h4 {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.tour-popover p {
    margin: 0 0 18px;
    font-size: 0.88rem;
    color: #64748B;
    line-height: 1.5;
}
body.dark-mode .tour-popover p {
    color: #94A3B8;
}

.tour-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(0,0,0,0.05);
    padding-top: 14px;
    margin-top: 10px;
}
body.dark-mode .tour-buttons {
    border-top-color: rgba(255,255,255,0.05);
}

.tour-btn {
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}
.tour-btn-next {
    background: var(--accent);
    color: white;
}
.tour-btn-next:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}
.tour-btn-prev {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
}
.tour-btn-prev:hover {
    background: var(--border);
    color: var(--text-main);
}
.tour-btn-skip {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 0;
}
.tour-btn-skip:hover {
    color: #EF4444;
}

/* SPOTLIGHT MASK (Brilho focado com fundo 100% escurecido e bordas neon vazadas) */
.tour-highlight {
    position: relative;
    z-index: 10000 !important;
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.75), 0 0 15px 3px var(--accent), 0 0 0 3px var(--accent) !important;
    border-color: var(--accent) !important;
    pointer-events: none !important; /* Trava cliques no elemento destacado */
}

/* CURSOR VIRTUAL DE ANIMAÇÃO */
.virtual-cursor {
    position: absolute;
    width: 24px; height: 24px;
    border-radius: 50%;
    background: rgba(32, 178, 170, 0.4);
    border: 2px solid #20B2AA;
    box-shadow: 0 0 10px rgba(32, 178, 170, 0.6);
    pointer-events: none;
    z-index: 10002;
    transition: top 0.9s cubic-bezier(0.25, 1, 0.5, 1), left 0.9s cubic-bezier(0.25, 1, 0.5, 1);
    transform: translate(-50%, -50%);
    display: none;
}
body.dark-mode .virtual-cursor {
    background: rgba(255, 82, 82, 0.4);
    border-color: #FF5252;
    box-shadow: 0 0 10px rgba(255, 82, 82, 0.6);
}

.virtual-cursor.clicking {
    animation: virtual-click 0.35s ease-out;
}
@keyframes virtual-click {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    50% { transform: translate(-50%, -50%) scale(0.65); opacity: 0.8; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.virtual-ripple {
    position: absolute;
    border: 2px solid #20B2AA;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 10001;
    animation: ripple-out 0.5s ease-out forwards;
}
body.dark-mode .virtual-ripple {
    border-color: #FF5252;
}

@keyframes ripple-out {
    0% { width: 0px; height: 0px; opacity: 1; }
    100% { width: 50px; height: 50px; opacity: 0; }
}

/* --- DESFOQUE SUAVE PARA A SEÇÃO DA IMAGEM --- */
.image-section {
    transition: filter 0.4s ease;
}
.image-section.tour-blur-image {
    filter: blur(8px) brightness(0.65);
    pointer-events: none;
}

/* --- ESTILOS DA CORRELAÇÃO CLÍNICA DINÂMICA E ANOTAÇÕES --- */
.correlacao-card {
    transition: all 0.3s ease;
}
body.dark-mode .correlacao-card {
    background: rgba(30, 41, 59, 0.4) !important;
    border-color: var(--border) !important;
}

#anotacoes-texto {
    transition: border-color 0.25s, box-shadow 0.25s;
}
#anotacoes-texto:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(32, 178, 170, 0.15);
}
body.dark-mode #anotacoes-texto:focus {
    box-shadow: 0 0 0 3px rgba(255, 82, 82, 0.15);
}
body.dark-mode #anotacoes-texto {
    background: rgba(15, 23, 42, 0.6) !important;
    border-color: var(--border) !important;
}