/* ===========================
 * ⚙️ Variabile CSS GLOBALE
 * =========================== */
:root {
    --primary-color: #003D73;     
    --primary-color-dark: #005f9b; 
    --background-app: #FAFAFA;     
    --text-color: #333;           
    --border-radius: 12px;         
}


/* =========================================================================
 * 🧩 STILURI SUDOKU GRID (Unificate cu sudoku-clasic.css)
 * * Această secțiune conține stilurile pentru tabla de joc Sudoku, 
 * inclusiv grila, celulele individuale, marcajele 3x3, stările (fix, selectat, eroare)
 * și animațiile.
 * ========================================================================= */

/* Containerul principal al zonei de joc */
.game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* Grila Sudoku propriu-zisă */
.sudoku-game-area {
   
    width: 92vw; 
    max-width: 520px; 
    aspect-ratio: 1 / 1; 
    display: grid;
    grid-template-columns: repeat(9, 1fr); 
    grid-auto-rows: 1fr; 

    /* Aspect Vizual */
    border: 4px solid var(--primary-color); 
    border-radius: 8px;
    overflow: hidden; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.12);
    margin: 20px auto;
    background-color: #FFFFFF;
    user-select: none; 
}

/* Stilul fiecărei celule (pătrățel individual) */
.sudoku-game-area .cell {
    
    border: 1px solid #d0d0d0; 
    display:flex;
    justify-content:center;
    align-items:center;
    box-sizing:border-box; 
    position:relative; 
    
   
    font-size: 36px;
    font-weight:500;
    user-select:none;
    background:#fff;
    cursor:pointer;
    transition: background-color 0.1s, box-shadow 0.1s; 
}

/* Granițe de 3x3: Linii orizontale groase */
.sudoku-game-area .cell[data-row="2"],
.sudoku-game-area .cell[data-row="5"] {
    border-bottom-width: 3px;
    border-bottom-color: var(--primary-color);
}
/* Granițe de 3x3: Linii verticale groase */
.sudoku-game-area .cell[data-col="2"],
.sudoku-game-area .cell[data-col="5"] {
    border-right-width: 3px;
    border-right-color: var(--primary-color);
}

/* Stil pentru celulele fixe (predefinite, care nu pot fi modificate de utilizator) */
.sudoku-game-area .cell.fixed {
    
    color:#0b63b8; 
    font-weight:700;
    cursor:default;
}

/* Stil pentru celulele introduse de utilizator */
.sudoku-game-area .cell:not(.fixed) {
    color: var(--text-color); 
    font-weight: 500;
}

/* --- Stiluri de Notițe (Notes) --- */
.sudoku-game-area .notes {
    position:absolute;
    inset:0; 
    display:grid;
    grid-template-columns: repeat(3,1fr); 
    grid-template-rows: repeat(3,1fr);
    font-size:0.38em; 
    color:#555;
    padding:3px;
    box-sizing:border-box;
    pointer-events:none; 
}
.sudoku-game-area .notes-digit {
    display:flex;
    justify-content:center;
    align-items:center;
    line-height:1;
    font-weight: 500;
}

 /* =================================
         * STILURI CORECTATE PENTRU EVIDENȚIERE
         * ================================= */
        
        /* Evidențiere Rând/Coloană/Bloc 3x3 (culoare vizibilă) */
        .sudoku-game-area .cell.highlighted {
            background-color: #BBDEFB  !important; 
        }

        /* Evidențiere Cifre Asemănătoare (culoare vizibilă) */
        .sudoku-game-area .cell.match {
            background-color: #FFF9C4 !important; 
        }

        /* Evidențiere celulă selectată */
        .sudoku-game-area .cell.selected { 
            box-shadow: inset 0 0 0 0px #003D73; 
            background-color: #BBDEFB; 
            z-index: 2; 
        }

       
        .sudoku-game-area .cell.selected.match {
             background-color: #FFEE98 !important; 
        }
        .sudoku-game-area .cell.selected.highlighted {
             background-color: #42A5F5 !important; 
        }

        /* --- Stiluri de Eroare --- */
.sudoku-game-area .cell.error {
    background-color: #FFC0CB !important; 
    color: #C62828 !important; 
    box-shadow: inset 0 0 0 0px #EF5350, 0 0 5px rgba(239, 83, 80, 0.5); 
    animation: errorPulse 0.3s ease-in-out 2; 
}


@keyframes errorPulse {
    0% {
        transform: scale(1.02);
    }
    50% {
        background-color: #FFEBEE !important; 
    }
    100% {
        transform: scale(1);
    }
}

/* --- Stiluri de Finalizare a Unității (Succes) Animatie --- */

.sudoku-game-area .cell.unit-complete {
    background-color: #E0F3FF !important; 
    box-shadow: inset 0 0 0 2px #00BFFF;
    transition: background-color 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
    
   
    animation: unitFlashCompleteNeonShake 1.0s ease-out 1 forwards; /* Durată ușor crescută */
}

@keyframes unitFlashCompleteNeonShake {
    0% {
      
        box-shadow: inset 0 0 0 5px #1E90FF;
        background-color: #FFFFFF !important;
        transform: scale(0.98) translateX(0); 
        opacity: 0.8;
    }

    40% {
       
        transform: scale(1.0) translateX(-1.5px);
    }
    
    50% {
       
        box-shadow: 
            inset 0 0 0 1px #00BFFF, 
            0 0 14px rgba(0, 191, 255, 0.9); 
        opacity: 1;
        
       
        transform: scale(1.0) translateX(2px); 
    }

    60% {
        
        transform: scale(1.0) translateX(-1px);
    }

    70% {
        
        transform: scale(1.0) translateX(1px);
    }
    
    100% {
        
        box-shadow: inset 0 0 0 2px #00BFFF;
        background-color: #E0F3FF !important; 
        transform: scale(1) translateX(0);
        opacity: 1;
    }
}


/* =========================================================================
 * 📊 STILURI DE CONTROL & STATUS (Poziționate conform cerinței)
 * * Această secțiune gestionează stilurile pentru panourile de informații, 
 * butoanele de acțiune (Undo, Notițe, Ștergere) și butoanele numerice.
 * ========================================================================= */

/* Panoul de Informații (Data, Dificultatea, Timpul, Greșelile) - Poziționat deasupra tablei */
.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 820px;
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 1px solid #eee;
    font-weight: 600;
    color: var(--text-color);
    box-sizing: border-box;
}

.game-info-message {
    color: var(--primary-color);
    font-size: 1.1em;
    padding: 0;
}

.nav-menu .nav-item {
    font-weight: bold;
}

/* Panel Status (Timer & Greșeli) - Centrat pe mobile, aliniat la dreapta pe desktop */
.status-panel {
    display: flex;
    justify-content: center; 
    width: 100%;
    max-width: none;
    padding: 0;
    font-size: 1em;
    font-weight: 600;
    gap: 10px;
}

.status-item {
    padding: 4px 8px;
    border-radius: 6px;
}


/* Panel Controale */
.control-panel {
    width: 92vw;
    max-width: 520px; 
    display:flex;
    flex-direction:column;
    gap:12px;
    box-sizing:border-box;
    padding: 10px 0;
}

/* Butoanele de Acțiune (Undo, Erase, etc.) */
.action-buttons-row {
    display:grid;
    grid-template-columns: repeat(4,1fr); 
    gap:8px;
    width:100%;
}
.action-btn {
    padding:10px 8px;
    border-radius:8px;
    border:none;
    font-weight:700;
    cursor:pointer;
    color:#fff;
    background:#607D8B; 
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
    transition: transform 0.1s, background 0.2s;
}
.action-btn:hover { transform: translateY(-2px); }
.action-btn#note-btn.active { 
    background: var(--primary-color-dark); 
    color: white;
    box-shadow: 0 0 0 3px rgba(0,95,155,0.12); 
}

/* --- Butoanele de Cifre 1-9 (Grid pe desktop) --- */
.number-controls {
    display:flex;
    flex-wrap: nowrap;
    overflow-x: auto; 
    gap: 6px;
    width:100%;
    padding: 8px 0;
    -ms-overflow-style: none; 
    scrollbar-width: none; 
}
.number-controls::-webkit-scrollbar {
    display: none; 
}

.digit-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1; 
    padding: 8px 0;
    border-radius:8px;
    border:1px solid var(--primary-color);
    font-size:1.1rem;
    font-weight:800;
    background: var(--primary-color); 
    color:white;
    cursor:pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.12);
    transition: transform 0.1s;
    min-width: 46px; 
    flex-shrink: 0; 
}

.digit-btn:hover {
        background-color: #1e88e5; 
        }

.digit-btn .digit-span {
    font-size: 30px;
    font-weight: 800;
}
.digit-btn .count-span {
    font-size: 0.65rem; 
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7); 
    margin-top: 2px;
}


.digit-btn.completed {
    background: #4CAF50; 
    border-color: #4CAF50;
    color: white;
    cursor: default;
    opacity: 0.8;
}

/* Main action buttons (New Game/etc) */
.main-action-buttons {
    display:flex;
    gap:8px;
    justify-content: center;
    margin-top: 4px;
}
.main-action-btn { 
    flex: 1; 
    padding:12px 20px; 
    background: #28a745; 
    color: white;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    font-size: 20px;
}
.main-action-btn:hover { 
    background: #1e7e34; 
    transform: translateY(-3px);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.2);
    opacity: 0.9;
}


/* =========================================================================
 * 🖥️ MEDIA QUERY PENTRU LAYOUT-UL DE DESKTOP (Side-by-Side)
 * * Aplică stiluri pentru ecranele mai mari de 769px, trecând la o dispunere 
 * a tablei și controalelor una lângă alta.
 * ========================================================================= */

@media (min-width: 769px) {
    .game-area {
        align-items: center; 
    }

    /* Modificăm .game-info pentru a se alinia deasupra layout-ului principal */
    .game-info {
        max-width: 820px; 
        flex-direction: row;
        justify-content: space-between;
        justify-content: center;
        margin-bottom: 12px;
        padding: 0; 
    }
    
    .game-info-message {
        text-align: left;
    }

    .status-panel {
        justify-content: center; 
        width: auto;
    }
    
    /* NOU: Container pentru a poziționa Tabla și Controalele una lângă alta (Side-by-Side) */
    .board-and-controls-wrapper {
        display: flex;
        flex-direction: row; 
        align-items: flex-start;
        justify-content: center;
        gap: 24px;
        width: 100%;
        max-width: 820px; 
    }

    .sudoku-game-area {
        /* Tabla: dimensiune fixă pe stânga */
        width: 520px;
        max-width: 520px;
        margin: 0; 
    }
    
    /* Controalele: aliniate pe dreapta tablei */
    .control-panel { 
        width: 220px; 
        margin-top: 6px; 
        max-width: 220px;
        flex-shrink: 0;
        padding: 0;
    }
    
    /* Controalele de acțiune și principale devin verticale */
    .action-buttons-row { grid-template-columns: 1fr; } 
    .main-action-buttons { flex-direction: column; } 
    
    
    .number-controls { 
        display: grid; 
        grid-template-columns: repeat(3,1fr); 
        grid-auto-rows: 1fr; 
        flex-wrap: wrap;
        overflow-x: hidden; 
        gap: 8px;
        padding: 0;
    }
    .digit-btn { min-width: auto; }

  

}

/* ===========================
 * MEDIA QUERY PENTRU MOBIL 

 * =========================== */
@media (max-width: 769px) {

    /* === MOBIL (implicit): butoane 1–9 pe un singur rând (Override pentru scroll) === */
    .number-controls {
        display: flex;
        justify-content: space-between;
        gap: 4px;
        width: 100%;
        padding: 6px 0;
        overflow-x: hidden; 
    }

    .digit-btn {
        flex: 1;
        min-width: 0; 
        max-width: 55px; 
        height: 60px; 
        
        
        display: flex;
        flex-direction: column; 
        justify-content: center; 
        align-items: center;
        padding: 2px 0; 
    }

    
    .digit-btn > span:not(.count-span) {
        font-size: 30px; 
        line-height: 1; 
    }
    
    
    .digit-btn .count-span {
        font-size: 14px; 
        line-height: 1; 
        margin-top: 2px; 
    }

    .sudoku-game-area .cell {
        font-size: 30px;
    }
}


/* =========================================================================
 * 📅 STILURI SPECIALE PENTRU CALENDAR 
 * * Stiluri specifice pentru componenta de vizualizare a calendarului.
 * ========================================================================= */

#calendar-view {
    max-width: 500px;
    margin: 0 auto;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 0 10px;
    width: 100%;
}

.calendar-header h3 {
    margin: 0;
    font-size: 1.5em;
    color: var(--primary-color);
}

.nav-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 1.2em;
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.nav-btn:hover {
    background-color: #E3F2FD;
}

.calendar-week-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: 600;
    color: #777;
    border-bottom: 1px solid #ddd;
    padding-bottom: 5px;
    margin-bottom: 5px;
    width: 100%;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    width: 100%;
}

.calendar-day {
    aspect-ratio: 1 / 1; 
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.1em;
    font-weight: 500;
    background-color: #F8F8F8;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    user-select: none;
    border: 1px solid #eee;
}

.calendar-day:hover:not(.disabled):not(.active) {
    background-color: #E0E0E0;
    transform: translateY(-1px);
}

.calendar-day.disabled {
    color: #ccc;
    cursor: default;
    background-color: #FAFAFA;
}

.calendar-day.selected { 
    background-color: #005f9b; 
    color: white;
    font-weight: 700;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transform: scale(1.05);
}

.calendar-day.current-month {
    color: var(--text-color);
}

.back-to-calendar-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 15px;
    margin-bottom: 15px; 
    border: 1px solid var(--primary-color);
    border-radius: 8px;
    background-color: #E3F2FD; 
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.back-to-calendar-btn:hover {
    background-color: #BBDEFB;
    transform: translateY(-1px);
}


/* =========================================================================
 * 🎉 STILURI PENTRU MODAL (Fereastra Pop-up de Victorie)
 * * Controlează aspectul și animația ferestrei modale de final de joc.
 * ========================================================================= */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7); 
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.modal-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--background-app, #FAFAFA);
    padding: 30px;
    border-radius: var(--border-radius, 12px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 90%;
    width: 400px;
    transform: translateY(-50px); 
    transition: transform 0.4s ease-out, opacity 0.4s ease-out;
}

.modal-overlay.is-open .modal-content {
    transform: translateY(0); 
}

.modal-content h2 {
    color: var(--primary-color, #003D73);
    font-size: 2em;
    margin-bottom: 10px;
}

.modal-content p {
    font-size: 1.2em;
    line-height: 1.5;
    margin-bottom: 25px;
}

.modal-btn-primary {
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    color: white;
    
    background: linear-gradient(90deg, #00C6FF 0%, #0072FF 100%); 
    box-shadow: 0 4px 15px rgba(0, 114, 255, 0.4);
    transition: transform 0.2s;
}

.modal-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 114, 255, 0.6);
}


/* =======================================
 * 🟢 STILURI SPECIALE ZI COMPLETATĂ
 * ======================================= */
.calendar-day.completed-day {
    background-color: #E8F5E9; 
    color: #388E3C;          
    border: 2px solid #4CAF50; 
    font-weight: 700;
    position: relative;
    
}

/* Evidențiere specifică pentru o zi finalizată care este și ziua curentă */
.calendar-day.completed-day.selected {
    background-color: #66BB6A !important; 
    color: white !important;
    box-shadow: 0 2px 5px rgba(56, 142, 60, 0.4);
}