/* --- 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;
}

/* --- 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: 12px 22px; 
    border: 3px solid var(--cor-dificil) !important; 
    border-radius: 4px;
    position: absolute;
    white-space: nowrap;
    font-weight: 700;
    font-size: 14px;
    text-align: center;
    min-width: 140px; 
    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;
    text-shadow: 0 0 8px var(--cor-dificil); /* Padrão (vermelho) */
    transition: text-shadow 0.3s ease;
    touch-action: none; /* Add this line */
}

.marker.razoavel .marker-label {
    text-shadow: 0 0 8px var(--cor-razoavel);
}

.marker.facil .marker-label {
    text-shadow: 0 0 8px var(--cor-facil);
}

/* Text-shadow para estados de acerto/erro no Flash Card */
.marker.flash-correct .marker-label {
    text-shadow: 0 0 8px var(--cor-facil); /* Verde */
}
.marker.flash-incorrect .marker-label {
    text-shadow: 0 0 8px var(--cor-dificil); /* Vermelho */
}

.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; }

/* --- FLASHCARD HIGHLIGHT ANIMATION --- */
.flashcard-input.highlight-flashcard {
    animation: pulseBorder 1s infinite alternate;
}

@keyframes pulseBorder {
    from {
        box-shadow: 0 0 0 0px var(--accent-rgb-val, 32, 178, 170), inset 0 0 0 0px var(--accent-rgb-val, 32, 178, 170);
    }
    to {
        box-shadow: 0 0 0 8px rgba(var(--accent-rgb-val, 32, 178, 170), 0.7), inset 0 0 0 8px rgba(var(--accent-rgb-val, 32, 178, 170), 0.7);
    }
}

/* --- 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;
    font-style: italic;
    z-index: 1100;
    transform: translateX(-50%);
    pointer-events: none;
    text-align: center;
    white-space: nowrap;
    text-shadow: 0 2px 5px rgba(0,0,0,1);
}

#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: 768px) {
    main {
        flex-direction: column; /* Stack sections vertically */
        padding: 10px; /* Reduce main padding */
        gap: 15px; /* Adjust gap */
    }

    .controls-section {
        width: 100%; /* Take full width */
        padding: 20px; /* Adjust padding for mobile */
    }

    .image-viewer {
        padding: 20px; /* Reduce padding for mobile */
    }

    /* Adjust header for mobile if necessary */
    header {
        flex-direction: column; /* Stack header items */
        gap: 10px; /* Adjust gap */
        padding: 1rem; /* Adjust padding */
    }
    .header-left {
        flex-direction: column; /* Stack items within header-left */
        gap: 5px;
        width: 100%; /* Take full width */
    }
    header h1 {
        font-size: 1.2rem; /* Reduce heading size */
        text-align: center;
    }
    .back-btn {
        position: absolute; /* Position back button */
        top: 10px;
        left: 10px;
        font-size: 1.2rem;
    }

    .marker-label {
        font-size: 12px; /* Smaller font size for mobile */
        padding: 8px 15px; /* Adjust padding */
        min-width: unset; /* Allow width to be determined by content */
        white-space: normal; /* Allow text to wrap */
        --tx: 0; /* Reset transform for mobile, or define new logic */
        --ty: -35px;
        transform: translate3d(var(--tx), var(--ty), 0) translateX(-50%); /* Adjust position to center it */
    }

    .revealed-answer {
        font-size: 14px; /* Adjust font size for revealed answer */
    }
}

/* --- 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;
}