/* IMPORTANTE: Importiamo la base di Tailwind CSS. */
@import url('https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css');

/* =========================================
   CONFIGURAZIONE COLORI PERSONALIZZATI E ROOT
   ========================================= */
:root {
    --school-blue: #003366;
    --school-light: #0055A4;
    --school-accent: #FFD700;
    --school-gray: #F3F4F6;
    --ios-bg: #F5F5F7;
    --ios-gray: #F2F2F7;
    --ios-card: #FFFFFF;
    --primary-color: #003366;
}

/* =========================================
   TIPOGRAFIA GLOBALE (AGID: Titillium Web)
   ========================================= */
body, p, span, a, li, div, input, button, h1, h2, h3, h4, h5, h6, .font-titillium, label, th, td, section, article, aside, main, nav, header, footer {
    /* Font ufficiale AGID per la Pubblica Amministrazione */
    font-family: 'Titillium Web', sans-serif !important;
}

/* Backgrounds */
.bg-school-blue { background-color: var(--school-blue); }
.bg-school-light { background-color: var(--school-light); }
.bg-school-accent { background-color: var(--school-accent); }
.bg-school-gray { background-color: var(--school-gray); }
.bg-ios-bg { background-color: var(--ios-bg); }
.bg-ios-gray { background-color: var(--ios-gray); }
.bg-ios-card { background-color: var(--ios-card); }

/* Text Colors */
.text-school-blue { color: var(--school-blue); }
.text-school-light { color: var(--school-light); }
.text-school-accent { color: var(--school-accent); }
.text-school-gray { color: var(--school-gray); }

/* Borders */
.border-school-blue { border-color: var(--school-blue); }
.border-school-light { border-color: var(--school-light); }

/* Hover & Focus (Polyfill manuali) */
.hover\:bg-school-blue:hover { background-color: var(--school-blue); }
.hover\:text-school-blue:hover { color: var(--school-blue); }
.hover\:bg-school-light:hover { background-color: var(--school-light); }
.group:hover .group-hover\:text-school-blue { color: var(--school-blue); }
.group:hover .group-hover\:bg-school-blue { background-color: var(--school-blue); }
.group:hover .group-hover\:text-school-light { color: var(--school-light); }
.focus\:border-school-blue:focus { border-color: var(--school-blue); }
.focus\:ring-school-blue:focus { --tw-ring-color: var(--school-blue); }

/* =========================================
   GLOBAL OVERRIDES (ESTRATTI DA HEADER.PHP)
   ========================================= */
.text-primary { color: #003366 !important; }
.bg-primary { background-color: #003366 !important; }
.border-primary { border-color: #003366 !important; }
.btn-primary { background-color: #003366 !important; border-color: #003366 !important; color: #ffffff !important; }
.btn-primary:hover { background-color: #002244 !important; border-color: #002244 !important; box-shadow: 0 4px 12px rgba(0, 51, 102, 0.3) !important; }
.btn-outline-primary { color: #003366 !important; border-color: #003366 !important; }
.btn-outline-primary:hover { background-color: #003366 !important; color: #ffffff !important; }

/* HEADER COMPATTO */
.it-header-slim-wrapper { background: #003366; border-top: none !important; }
.it-header-compact-wrapper { background: #ffffff; box-shadow: 0 4px 20px rgba(0,0,0,0.05); position: relative; z-index: 1030; border-bottom: 1px solid rgba(0,0,0,0.05); }
.it-footer-main { background: #002244; }
.it-header-wrapper { box-shadow: none !important; margin: 0 !important; }
.it-header-center-wrapper { background: transparent; }
.it-header-navbar-wrapper { box-shadow: none !important; margin-bottom: 0 !important; background: transparent; }

/* Link Topbar */
.apple-top-link { color: rgba(255,255,255,0.8) !important; font-size: 0.85rem; font-weight: 500; text-decoration: none !important; transition: all 0.2s ease; display: inline-flex; align-items: center; }
.apple-top-link:hover { color: #ffffff !important; transform: translateY(-1px); }

/* Pulsanti Azione */
.apple-action-btn { background: rgba(0, 51, 102, 0.06); color: #003366 !important; font-weight: 600; font-size: 1rem; text-decoration: none !important; display: inline-flex; align-items: center; justify-content: center; border: 1px solid rgba(0, 51, 102, 0.08); transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); }
.apple-action-btn:hover { background: rgba(0, 51, 102, 0.12); transform: scale(1.05); box-shadow: 0 6px 20px rgba(0, 51, 102, 0.15); }
.apple-action-btn svg { fill: #003366 !important; }
.apple-action-pill { border-radius: 40px; padding: 8px 20px; }
.apple-action-circle { border-radius: 50%; width: 42px; height: 42px; padding: 0; flex-shrink: 0; }
.apple-action-primary { background: #003366 !important; color: #ffffff !important; border-color: #003366 !important; box-shadow: 0 4px 12px rgba(0, 51, 102, 0.2); }
.apple-action-primary:hover { background: #002244 !important; transform: scale(1.05); box-shadow: 0 8px 24px rgba(0, 51, 102, 0.3); }
.apple-action-primary svg { fill: #ffffff !important; }

/* Testi Scuola */
.apple-brand-title { color: #003366; font-size: 1.4rem; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 0; white-space: nowrap; line-height: 1.1; }
.apple-brand-subtitle { color: #6b7280; font-size: 0.8rem; font-weight: 500; margin-bottom: 0; white-space: nowrap; letter-spacing: 0.02em; }

/* NAVIGAZIONE DESKTOP */
@media (min-width: 992px) { .it-header-navbar-wrapper .navbar .navbar-nav { gap: 0.35rem; } }
.it-header-navbar-wrapper .navbar .navbar-nav .nav-item .nav-link { color: #003366 !important; font-weight: 600; text-decoration: none !important; transition: background-color 0.2s ease, color 0.2s ease; }
.it-header-navbar-wrapper .navbar .navbar-nav .nav-item .nav-link.active,
.it-header-navbar-wrapper .navbar .navbar-nav .nav-item .nav-link:hover { background: rgba(0, 51, 102, 0.06) !important; border-radius: 8px; color: #003366 !important; text-decoration: none !important; }
.it-header-navbar-wrapper .navbar .navbar-nav .nav-item .nav-link .icon { fill: #003366 !important; }

/* MEGAMENU APPLE STYLE */
.it-header-navbar-wrapper .navbar .navbar-nav .nav-item .dropdown-menu {
    border-radius: 1.5rem !important; box-shadow: 0 20px 40px -10px rgba(0, 51, 102, 0.15) !important;
    border: 1px solid rgba(0, 51, 102, 0.06) !important; padding: 1.75rem !important;
    margin-top: 1.85rem !important; background-color: #ffffff; position: absolute;
    min-width: 920px !important; min-height: 220px !important;
}
@keyframes appleMenuOpen { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.it-header-navbar-wrapper .navbar .navbar-nav .nav-item .dropdown-menu.show {
    animation: appleMenuOpen 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards; display: block;
}
.it-header-navbar-wrapper .navbar .navbar-nav .nav-item .dropdown-menu::before {
    content: ''; position: absolute; top: -8px; left: 2.5rem; width: 14px; height: 14px; background-color: #ffffff;
    border-top: 1px solid rgba(0, 51, 102, 0.06); border-left: 1px solid rgba(0, 51, 102, 0.06);
    transform: rotate(45deg); border-radius: 2px; z-index: 10;
}
@media (max-width: 991.98px) { .it-header-navbar-wrapper .navbar .navbar-nav .nav-item .dropdown-menu::before { display: none; } }
@media (min-width: 992px) {
    .it-header-navbar-wrapper .navbar .navbar-nav .nav-item .dropdown-menu .row > [class*="col-lg"]:not(:last-child) .link-list-wrapper { padding-right: 1.5rem; border-right: 1px solid rgba(0, 51, 102, 0.06); margin-right: 0; }
    .it-header-navbar-wrapper .navbar .navbar-nav .nav-item .dropdown-menu .row > [class*="col-lg"]:not(:first-child) .link-list-wrapper { padding-left: 1.5rem; }
}
.it-header-navbar-wrapper .navbar .navbar-nav .nav-item .dropdown-menu .link-list-wrapper .link-list li { border-bottom: none !important; }
.it-header-navbar-wrapper .navbar .navbar-nav .nav-item .dropdown-menu .link-list-wrapper .link-list h3 {
    font-size: 0.8rem !important; font-weight: 900 !important; text-transform: uppercase; letter-spacing: 0.12em;
    color: #003366 !important; margin: 0 0 0.625rem 0 !important; padding: 0 0 0.5rem 0 !important;
    background: none; border-radius: 0; border-bottom: 1px solid rgba(0, 51, 102, 0.10); display: block;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.it-header-navbar-wrapper .navbar .navbar-nav .nav-item .dropdown-menu .link-list-wrapper .link-list h3::before { display: none; }
.it-header-navbar-wrapper .navbar .navbar-nav .nav-item .dropdown-menu .link-list-wrapper .link-list li + li > h3 { margin-top: 1.25rem !important; }
.it-header-navbar-wrapper .navbar .navbar-nav .nav-item .dropdown-menu .link-list-wrapper .link-list a.list-item {
    border-radius: 0.625rem !important; padding: 0.45rem 0.875rem !important; font-weight: 500 !important;
    font-size: 0.95rem !important; color: #374151 !important; text-decoration: none !important; box-shadow: none !important;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1) !important; display: block;
}
.it-header-navbar-wrapper .navbar .navbar-nav .nav-item .dropdown-menu .link-list-wrapper .link-list a.list-item::before { display: none; }
.it-header-navbar-wrapper .navbar .navbar-nav .nav-item .dropdown-menu .link-list-wrapper .link-list a.list-item span,
.it-header-navbar-wrapper .navbar .navbar-nav .nav-item .dropdown-menu .link-list-wrapper .link-list a.list-item:hover span { text-decoration: none !important; box-shadow: none !important; background-image: none !important; }
.it-header-navbar-wrapper .navbar .navbar-nav .nav-item .dropdown-menu .link-list-wrapper .link-list a.list-item:hover { background-color: rgba(0, 51, 102, 0.05) !important; color: #003366 !important; transform: translateX(3px); }

/* IMMAGINI MEGA MENU */
.menu-img-col { display: flex; align-items: center; }
.menu-img-link { display: block; border-radius: 1rem; overflow: hidden; text-decoration: none !important; transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.menu-img-link:hover { transform: translateY(-4px); }
.menu-img-link img { width: 100%; height: 150px; object-fit: cover; display: block; }
.menu-img-caption { font-size: 0.75rem; font-weight: 700; color: #003366; margin-top: 0.625rem; padding: 0 0.125rem; display: block; text-decoration: none !important; }

/* MODALE RICERCA SPOTLIGHT */
#appleSearchModal .modal-content { border-radius: 2rem !important; border: 1px solid rgba(255, 255, 255, 0.2) !important; box-shadow: 0 25px 50px -12px rgba(0, 51, 102, 0.25) !important; background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
#appleSearchModal .modal-header { border-bottom: none; padding: 1.5rem 1.5rem 0; }
#appleSearchModal .modal-body { padding: 1rem 2rem 3rem; }
.apple-search-input { width: 100%; border: none; background: transparent; font-size: 1.8rem; font-weight: 700; color: #003366; outline: none; padding: 0.5rem 0; border-bottom: 2px solid rgba(0, 51, 102, 0.1); transition: border-color 0.3s ease; text-align: center; letter-spacing: -0.02em; }
.apple-search-input:focus { border-bottom-color: #003366; }
.apple-search-input::placeholder { color: #cbd5e1; font-weight: 600; }
@media (max-width: 768px) { .apple-search-input { font-size: 1.4rem; } }

/* MODALE LOGIN */
#appleLoginModal .modal-backdrop, .apple-popover-backdrop { background-color: rgba(0, 35, 70, 0.5) !important; backdrop-filter: blur(4px); }
#appleLoginModal .modal-dialog { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - 3.5rem); margin: 1.75rem auto !important; width: 100% !important; max-width: 480px !important; position: relative !important; top: auto !important; right: auto !important; left: auto !important; transform: translateY(-20px) scale(0.97) !important; transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease !important; }
#appleLoginModal.show .modal-dialog { transform: translateY(0) scale(1) !important; }
#appleLoginModal .modal-content { border-radius: 1.5rem !important; border: 1px solid rgba(0, 51, 102, 0.08) !important; box-shadow: 0 32px 64px -12px rgba(0, 51, 102, 0.22) !important; overflow: hidden; background-color: #ffffff; width: 100%; }
#appleLoginModal .modal-content::before { display: none !important; }
#appleLoginModal .modal-header { border-bottom: none; padding: 2rem 2rem 0.75rem 2rem; position: relative; }
#appleLoginModal .modal-body { padding: 0.75rem 2rem 2.25rem 2rem; }
.apple-input-form { background-color: #f9fafb; border: 1px solid #e5e7eb; border-radius: 0.875rem; padding: 0.85rem 1.25rem; font-size: 0.95rem; font-weight: 500; color: #1f2937; transition: all 0.2s ease; width: 100%; margin-bottom: 0.5rem; box-shadow: inset 0 2px 4px rgba(0,0,0,0.02); }
.apple-input-form:focus { outline: none; background-color: #ffffff; border-color: #003366; box-shadow: 0 0 0 4px rgba(0, 51, 102, 0.1); }
.apple-label-form { display: block; font-size: 0.7rem; font-weight: 800; color: #6b7280; margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.05em; margin-left: 0.25rem; }
@media (max-width: 575.98px) {
    #appleLoginModal .modal-dialog { max-width: calc(100% - 2rem) !important; width: calc(100% - 2rem) !important; margin: auto !important; position: fixed !important; top: 50% !important; left: 50% !important; transform: translate(-50%, -50%) !important; min-height: auto; }
    #appleLoginModal.show .modal-dialog { transform: translate(-50%, -50%) !important; }
    #appleLoginModal .modal-content { border-radius: 1.5rem !important; }
}

/* Sticky Nav */
.apple-navbar-sticky { position: fixed !important; top: 0; left: 0; right: 0; z-index: 1030; animation: appleSlideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1); background: rgba(255, 255, 255, 0.98) !important; backdrop-filter: blur(10px); }
@keyframes appleSlideDown { from { transform: translateY(-100%); } to { transform: translateY(0); } }

/* =========================================
   FIX PER CLASSI JIT E UTILITA'
   ========================================= */
.bg-white\/95 { background-color: rgba(255, 255, 255, 0.95); }
.bg-white\/80 { background-color: rgba(255, 255, 255, 0.8); }
.border-white\/10 { border-color: rgba(255, 255, 255, 0.1); }
.bg-black\/5 { background-color: rgba(0, 0, 0, 0.05); }
.hover\:bg-black\/5:hover { background-color: rgba(0, 0, 0, 0.05); }
.bg-black\/40 { background-color: rgba(0, 0, 0, 0.4); }
.text-\[10px\] { font-size: 10px; }
.text-\[0\.95rem\] { font-size: 0.95rem; }
.top-\[2px\] { top: 2px; }
.left-\[2px\] { left: 2px; }
.w-\[1600px\] { width: 1600px; }
.max-w-\[1600px\] { max-width: 1600px; }
.z-\[50\] { z-index: 50; } .z-\[60\] { z-index: 60; } .z-\[70\] { z-index: 70; } .z-\[80\] { z-index: 80; } .z-\[100\] { z-index: 100; } .z-\[150\] { z-index: 150; } .z-\[200\] { z-index: 200; } .z-\[9999\] { z-index: 9999; }
.shadow-blue-500\/30 { box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.3), 0 4px 6px -2px rgba(59, 130, 246, 0.15); }
.shadow-blue-900\/20 { box-shadow: 0 10px 15px -3px rgba(30, 58, 138, 0.2), 0 4px 6px -2px rgba(30, 58, 138, 0.1); }
.shadow-red-500\/30 { box-shadow: 0 10px 15px -3px rgba(239, 68, 68, 0.3); }

/* =========================================
   STILI COMPONENTI UI CONDIVISI (Es. Circolari)
   (Estratti dai Page Controllers per Ottimizzazione WPO)
   ========================================= */
.circ-card {
    background: #ffffff;
    border-radius: 1.5rem;
    border: none;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    transition: all 0.3s cubic-bezier(0.16,1,0.3,1);
    cursor: pointer;
}
.circ-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0,51,102,0.1), 0 10px 10px -5px rgba(0,51,102,0.04);
}
.circ-title { font-size: 1.05rem; font-weight: 700; color: #1f2937; line-height: 1.3; letter-spacing: -0.01em; transition: color 0.2s ease; }
.circ-card:hover .circ-title { color: #003366; }

.circ-modal-file {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem; background: #F8FAFC; border-radius: 1rem; border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02); text-decoration: none; color: inherit; transition: all 0.25s ease;
}
.circ-modal-file:hover {
    transform: translateY(-2px); box-shadow: 0 8px 15px rgba(0,51,102,0.08);
    background: #ffffff; text-decoration: none; color: inherit;
}
.sidebar-search-input { background-image: none !important; border: none !important; }
aside a, aside a:hover { text-decoration: none !important; }

/* FIX SCROLL SIDEBAR IPAD/TABLET */
.ios-sidebar { 
    backdrop-filter: saturate(180%) blur(20px); background-color: rgba(255, 255, 255, 0.7); 
    border-right: 1px solid rgba(0,0,0,0.1); overflow-y: auto !important; -webkit-overflow-scrolling: touch !important; 
    overscroll-behavior: contain !important; height: 100vh !important; height: 100dvh !important;
    max-height: 100dvh !important; padding-bottom: env(safe-area-inset-bottom, 20px) !important;
}
.ios-sidebar::after { content: ""; display: block; height: 120px; width: 100%; }
.ios-sidebar::-webkit-scrollbar { width: 6px; }
.ios-sidebar::-webkit-scrollbar-track { background: transparent; }
.ios-sidebar::-webkit-scrollbar-thumb { background-color: rgba(0, 0, 0, 0.2); border-radius: 10px; }

.ios-card { background-color: #FFF; border-radius: 20px; box-shadow: 0 2px 10px rgba(0,0,0,0.02); border: 1px solid rgba(0,0,0,0.04); transition: all 0.2s ease; }
.ios-card:hover { box-shadow: 0 8px 30px rgba(0,51,102,0.06); }
.ios-btn-primary { background-color: var(--school-blue); color: white; border-radius: 9999px; font-weight: 600; transition: all 0.2s; }
.ios-btn-primary:hover { background-color: #002244; transform: scale(0.98); }
.ios-btn-secondary { background-color: #F3F4F6; color: #4B5563; border-radius: 9999px; font-weight: 600; transition: all 0.2s; }
.ios-btn-secondary:hover { background-color: #E5E7EB; transform: scale(0.98); }
.ios-btn-danger { background-color: #EF4444; color: white; border-radius: 9999px; font-weight: 600; transition: all 0.2s; }
.ios-btn-danger:hover { background-color: #DC2626; transform: scale(0.98); }
.ios-input { background-color: #F2F2F7; border: none; border-radius: 10px; padding: 12px; transition: all 0.2s; }
.ios-input:focus { background-color: #E5E5EA; outline: none; box-shadow: 0 0 0 2px var(--school-blue); }

.animate-fade-in { animation: fadeIn 0.3s ease-in-out forwards; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* Glass Header specifico */
.glass-header { background: rgba(255, 255, 255, 0.9); backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid rgba(0,51,102,0.08); }

/* Select Arrow */
.select-arrow {
    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='M7 7l3-3 3 3m0 6l-3 3-3-3'/%3e%3c/svg%3e");
    background-position: right 0.5rem center; background-repeat: no-repeat; background-size: 1.5em 1.5em; padding-right: 2.5rem;
}

/* Prose (Testo Articoli) */
.prose { font-size: 1rem; line-height: 1.6; color: #1f2937; max-width: none; }
.prose p { margin-bottom: 0.85em; margin-top: 0; }
.prose img { border-radius: 0.5rem; margin: 1.5rem auto; max-width: 100%; height: auto; display: block; }
.prose h2 { font-size: 1.5rem; font-weight: 700; color: #111827; margin-top: 1.5rem; margin-bottom: 0.75rem; line-height: 1.3; }
.prose ul { list-style-type: disc; padding-left: 1.5rem; margin-bottom: 1em; }
.prose a { color: var(--school-light); text-decoration: underline; font-weight: 500; }