@tailwind base;
@tailwind components;
@tailwind utilities;

body { 
    -webkit-font-smoothing: antialiased; 
    -moz-osx-font-smoothing: grayscale; 
}
/* Scrollbar personalizat */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #1f2937; }
::-webkit-scrollbar-thumb { background: #4b5563; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #6b7280; }

.tab-content { display: none; }
.tab-content.active { 
    display: flex; 
    flex-direction: column; /* MODIFICARE: Folosim flex pentru layout consistent */
}
[role="tab"].active { 
    background-color: #374151; 
    color: #ffffff; 
}

/* Stiluri pentru fundalul animat */
#login-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0; /* În spatele formularului de login */
}

#login-screen {
    position: relative;
    z-index: 1;
}

/* ----- ÎMBUNĂTĂȚIRI CALENDAR (Flexbox) & TAB LAYOUT ----- */

/* Grila calendarului va ocupa spațiul rămas */
/* Grila Calendarului (5 Zile) */
/* Grila Calendarului (5 Zile x 5 Săptămâni - Full Height) */
/* Grila Calendarului (5 Zile x 5 Săptămâni - Full Height Flex) */
#calendar-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr) !important; 
    
    /* FIX: Nu mai forțăm rândurile la 1fr. 
       Le lăsăm 'auto' ca să se împartă egal datorită înălțimii containerului */
    grid-auto-rows: 1fr; 
    padding: 2px;
    gap: 1px;
    background-color: #374151;
    border: 1px solid #374151;
    border-radius: 0.5rem;
    
    /* FIX CRITIC: Ocupă tot spațiul rămas */
    flex: 1; 
    height: 100%; /* Se întinde în containerul flex */
    overflow: hidden !important;
}
.calendar-day-header {
    text-align: center;
    font-weight: 600;
    background-color: #1f2937; /* Fundal cap de tabel zile */
    font-size: 0.875rem;
}

/* Celulele zilei se vor extinde și vor avea scroll intern */
.calendar-day-cell {
    position: relative;
    padding: 0.5rem;
    background-color: #1f2937;
    transition: background-color 0.2s;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0; /* Permite micșorarea dacă e nevoie */
}

.calendar-groups-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 coloane egale */
    gap: 2px; /* Spațiu mic între ele */
    margin-top: 2px;
    width: 100%;
}


.calendar-day-cell.not-current-month {
    background-color: #111827; /* Fundal mai întunecat pt zilele din afara lunii */
    opacity: 0.6;
}
.calendar-day-number {
    font-weight: 500;
    color: #d1d5db; /* Gri deschis pt număr */
    flex-shrink: 0; /* Numărul zilei nu se micșorează */
}
.calendar-day-cell.not-current-month .calendar-day-number {
    color: #4b5563; /* Gri închis pt număr */
}
.calendar-group-entry {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem; /* Font mic */
    font-weight: 600;
    color: white;
    padding: 2px 0; /* Padding vertical mic */
    border-radius: 0.25rem;
    cursor: pointer;
    transition: filter 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    
    /* IMPORTANT: Pentru click */
    position: relative; 
    z-index: 10;
}
.calendar-group-entry:hover {
    filter: brightness(1.2);
}

/* ------------------------------------------- */

/* Stiluri Modal (Fereastră pop-up) */
.modal {
    display: none; /* Ascuns implicit */
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7); /* Fundal negru semi-transparent */
    animation: fadeIn 0.3s ease;
    /* NOU: Adăugat flex pentru centrare */
    align-items: center;
    justify-content: center;
}
/* Activare modal (se adaugă/elimină din JS) */
.modal.active {
    display: flex;
    z-index: 50;
}

.modal-content {
    z-index: 51; 
    position: relative;
    width: 90%;
    max-width: 600px; /* Lățimea implicită */
    max-height: 90vh; 
    display: flex; 
    flex-direction: column; 
}

/* NOU: Forțează meniurile <select> să arate ca input-urile Tailwind */
.modal-content select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%239ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}


#student-details-modal .modal-content {
    max-width: 800px; 
    overflow-y: auto; /* <-- ADĂUGAȚI ACEASTĂ LINIE */
}

/* Mini-calendar prezență elev */
/* Mini-calendar prezență elev (5 Zile) */
.presence-calendar {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* FIX: 5 Coloane */
    gap: 4px;
    margin-bottom: 1rem; /* Spațiu între luni */
}

/* Header-ul zilelor (L, M, M, J, V) */
.presence-header-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* FIX: 5 Coloane */
    gap: 4px;
    margin-bottom: 4px;
    border-bottom: 1px solid #374151;
    padding-bottom: 4px;
}
.presence-day {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 500;
}
.presence-day.present {
    background-color: #10B981; /* Verde */
    color: #ffffff;
}
.presence-day.absent {
    background-color: #EF4444; /* Roșu */
    color: #ffffff;
}

.presence-day.recovered {
    background-color: #ea580c !important; /* Orange-600 */
    border: 1px solid #c2410c !important; /* Orange-700 */
    color: white !important;
    cursor: pointer; /* Arată că se poate da click */
    box-shadow: 0 0 10px rgba(234, 88, 12, 0.4);
}

/* Ziua selectată pentru recuperare */
.presence-day.selected-absence {
    border: 2px solid #fbbf24 !important; /* Galben/Portocaliu */
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.5);
    transform: scale(1.05);
    z-index: 10;
}

.presence-day.no-data {
    background-color: #374151; /* Gri */
    color: #9CA3AF;
}
.presence-day.other-month {
    opacity: 0.3;
}
.presence-header {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #9CA3AF;
}

/* Asigură scroll intern pentru modalul de detalii grupă */
#add-grupa-modal .modal-body {
    max-height: calc(85vh - 120px); /* Înălțime maximă, ajustabilă */
    overflow-y: auto;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}
.modal.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

/* Stiluri pentru lista de asignare elevi */
.student-assign-row {
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.2s;
    border: 1px solid #374151; /* Griul meniului */
}
.student-assign-row:hover {
    background-color: #374151; /* Gri la hover */
}
.student-assign-row input[type="checkbox"] {
    margin-right: 0.75rem;
    width: 1.1rem;
    height: 1.1rem;
    accent-color: #2563EB; /* Albastru Tailwind */
}

.student-assign-row {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.2s;
    border: 1px solid #374151; /* Griul meniului */
}
.student-assign-row:hover {
    background-color: #374151; /* Gri la hover */
}
.student-assign-row input[type="checkbox"] {
    margin-right: 0.75rem;
    width: 1.1rem;
    height: 1.1rem;
    accent-color: #2563EB; /* Albastru Tailwind */
    flex-shrink: 0; /* Oprește micșorarea checkbox-ului */
}
/* Container pentru Nume și Vârstă */
.student-assign-details {
    flex-grow: 1; /* Ocupă spațiul rămas */
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}
.student-assign-age {
    font-size: 0.875rem; /* 14px */
    color: #9CA3AF; /* Gri 400 */
    font-weight: 500;
}

/* Indicator Plată */
.payment-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
}
.payment-paid { background-color: #10B981; box-shadow: 0 0 5px #10B981; } /* Verde */
.payment-unpaid { background-color: #EF4444; box-shadow: 0 0 5px #EF4444; } /* Roșu */

/* Facem modalul de prezență mai lat */
#attendance-modal .modal-content {
    max-width: 900px; /* Era 600px implicit */
    width: 95%;
}

/* Stil modern forțat pentru Dropdown-uri */
/* Stil modern forțat pentru Dropdown-uri (Versiunea Corectată) */
select.modern-select {
    /* 1. Resetare totală a stilului browserului */
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    
    /* 2. Săgeata SVG (Albă/Gri deschis pentru contrast) */
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%239ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e") !important;
    background-position: right 0.5rem center !important;
    background-repeat: no-repeat !important;
    background-size: 1.5em 1.5em !important;
    
    /* 3. Dimensiuni */
    padding: 0.5rem !important;
    padding-right: 2.5rem !important;
    
    /* 4. CULORI (Acesta este fixul pentru 'alb șters') */
    background-color: #374151 !important; /* Gri închis (Tailwind gray-700) */
    color: #FFFFFF !important;            /* Text Alb Pur */
    border: 1px solid #4B5563 !important; /* Border gri (gray-600) */
    border-radius: 0.375rem !important;
    
    cursor: pointer !important;
}

/* Hover */
select.modern-select:hover {
    border-color: #60A5FA !important; /* Albastru */
    background-color: #4B5563 !important; /* Gri puțin mai deschis la hover */
}

/* Focus */
select.modern-select:focus {
    outline: none !important;
    border-color: #3B82F6 !important;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5) !important;
}

/* --- FIX CRITIC: Stilizarea listei care se deschide (Options) --- */
/* Acest lucru asigură că meniul desfășurat este tot închis la culoare */
select.modern-select option {
    background-color: #1F2937; /* Foarte închis (gray-800) */
    color: #FFFFFF;            /* Text Alb */
    padding: 10px;
}

/* Stil pentru zilele de vacanță în calendar */
.calendar-day-cell.is-holiday {
    background-color: rgba(6, 95, 70, 0.6) !important; /* Verde închis (emerald-800) cu transparență */
    border: 1px solid #059669; /* Contur verde */
}

/* Eticheta "Vacanță" */
.holiday-label {
    position: absolute;
    bottom: 4px;
    right: 4px;
    font-size: 0.65rem;
    color: #34D399; /* Verde deschis */
    font-weight: bold;
    text-transform: uppercase;
    pointer-events: none;
}

/* --- STIL PENTRU ZIUA CURENTĂ (AZI) --- */
/* --- STIL PENTRU ZIUA CURENTĂ (AZI) - FIXAT --- */
/* Folosim 'div' in fata pentru prioritate maxima */
div.calendar-day-cell.is-today {
    /* 1. Fundal: Un gri mai deschis (gray-700) în loc de transparent */
    background-color: #374151 !important; 
    
    /* 2. Border: Albastru deschis ca să iasă în evidență */
    border: 2px solid #3B82F6 !important; 
    
    /* 3. Umbră */
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3) !important;
    
    /* 4. Z-index ca să fie chenarul peste celulele vecine */
    z-index: 20 !important;
}

/* Facem numărul zilei albastru deschis */
div.calendar-day-cell.is-today .calendar-day-number {
    color: #60A5FA !important; /* blue-400 */
    font-weight: 900 !important;
}

/* Eticheta pentru ziua curentă */
.today-label {
    position: absolute;
    top: 4px;
    right: 4px;
    background-color: #3B82F6; /* Albastru intens */
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 4px;
    z-index: 25; /* Să fie peste orice altceva */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); /* Mică umbră pentru contrast */
    letter-spacing: 0.5px;
}

/* Separator de Oră în Calendar (── 14:00 ──) */
.time-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem; /* Foarte mic */
    font-weight: 700;
    color: #9CA3AF; /* Gri deschis */
    margin-top: 4px;
    margin-bottom: 2px;
    width: 100%;
}

/* Liniile stânga/dreapta */
.time-divider::before,
.time-divider::after {
    content: '';
    flex: 1; /* Ocupă tot spațiul disponibil */
    border-bottom: 1px solid #4B5563; /* Culoarea liniei (gri închis) */
    opacity: 0.5;
}

/* Spațiu în jurul orei */
.time-divider span {
    padding: 0 4px;
}

/* Grila pentru grupele de sub o anumită oră */
.time-slot-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 pe rând */
    gap: 2px;
    width: 100%;
}

/* --- STILURI NOI: Separator Oră --- */
.time-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin: 6px 0 4px 0;
    color: #9CA3AF; /* Gri deschis */
}

/* Linia din stânga și dreapta */
.time-divider::before,
.time-divider::after {
    content: '';
    flex: 1; /* Se întinde cât poate */
    height: 1px;
    background-color: #4B5563; /* Culoarea liniei (gri închis) */
    opacity: 0.5;
}

/* Textul orei (centrat și mic) */
.time-divider span {
    padding: 0 6px; /* Spațiu în jurul textului */
    font-size: 0.65rem; /* Foarte mic */
    font-weight: 700;
    white-space: nowrap;
}
/* --- FIX POZIȚIONARE ZI ȘI ORE (Versiunea 2) --- */

/* 1. Celula: Adăugăm padding mare sus pentru a împinge orele mai jos */
/* --- DESIGN FINAL CALENDAR (Rotunjit & Spațiat) --- */
/* --- DESIGN FINAL CALENDAR (Compact & Rotunjit) --- */

/* 1. Celula: Mai compactă sus */
/* --- DESIGN FINAL CALENDAR (Rafinat) --- */

/* 1. Celula: Compactă */
/* --- DESIGN FINAL CALENDAR (Aliniat la Nivel) --- */

/* 1. Celula: Padding minim sus */
.calendar-day-cell {
    /* FIX: Redus la 2px. Conținutul începe chiar de sus. */
    padding-top: 2px !important; 
    padding-left: 2px !important;
    padding-right: 2px !important;
    padding-bottom: 4px !important;
    
    position: relative;
    
    border-radius: 12px !important; 
    margin: 3px !important; 
    border: 1px solid #374151; 
    overflow: hidden; 
    background-color: #1f2937;
}

/* 2. Numărul zilei: Stânga-Sus */
.calendar-day-number {
    position: absolute !important;
    top: 4px;
    left: 6px;
    
    font-size: 0.85rem !important;
    font-weight: 700 !important;
    color: #9CA3AF; 
    
    /* Fundalul acoperă linia care trece prin spatele lui */
    background-color: #111827; 
    padding: 2px 8px !important; 
    border-radius: 9999px !important; 
    
    z-index: 20; /* Peste separator */
    box-shadow: 0 2px 4px rgba(0,0,0,0.4); 
}

/* Stil AZI */
div.calendar-day-cell.is-today .calendar-day-number {
    background-color: #3B82F6 !important; 
    color: white !important;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.8);
}

/* 3. Separatorul de oră */
.time-divider {
    margin: 8px auto 8px auto !important; 
    position: relative;
    z-index: 2;
    width: 60% !important; 
}

/* --- FIX CRITIC: PRIMA ORĂ --- */
/* O urcăm să fie exact la nivelul numărului zilei */
.time-divider:first-of-type {
    margin-top: 8px !important; /* Aliniat vizual cu numărul (care e la top:4px + padding) */
}

.time-divider span {
    font-size: 0.65rem;
    padding: 0 6px; 
    background-color: #1f2937; 
    color: #9CA3AF;
    border-radius: 10px;
    border: 1px solid #374151;
}

/* 4. Grila de Grupe */
.calendar-day-cell .grid {
    /* Păstrăm indentarea cerută */
    margin-left: 12px !important; 
    width: calc(100% - 14px) !important; 
}

/* 5. Eticheta "AZI" */
.today-label {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: #3B82F6;
    color: white;
    font-size: 0.60rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 9999px; 
    z-index: 25;
    letter-spacing: 0.5px;
}
/* --- FIX: Ascundere săgeți DOAR la suma de plată --- */

/* Pentru Chrome, Safari, Edge, Opera */
#quick-payment-amount::-webkit-outer-spin-button,
#quick-payment-amount::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Pentru Firefox */
#quick-payment-amount {
    -moz-appearance: textfield;
}

.payment-led-bar {
    display: block !important;
    height: 6px !important;
    width: 100% !important;
    border-radius: 3px;
    margin-top: 4px !important;
    background-color: #374151; /* Gri fallback */
}
/* + Clasele led-green, led-red, led-white... */

/* Stările LED-ului */
.led-green {
    background-color: #10B981 !important; /* Verde aprins */
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.8); /* Strălucire */
}
.led-white {
    background-color: #F3F4F6 !important; /* Alb */
    box-shadow: 0 0 10px rgba(243, 244, 246, 0.8);
}
.led-red {
    background-color: #EF4444 !important; /* Roșu aprins */
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.8);
}
/* --- LED ALBASTRU (Plătit curent, dar cu istoric lipsă) --- */
.led-blue {
    background-color: #3B82F6 !important; /* Albastru intens */
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.8);
}

.led-fade-transition {
    transition: background-color 0.8s ease, box-shadow 0.8s ease, opacity 0.8s ease;
    opacity: 0.3; /* Pornim ușor transparent */
    will-change: opacity, background-color, box-shadow; /* PREVINE TREMURATUL */
}
.led-visible {
    opacity: 1 !important;
}

.backface-hidden {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}