/**
 * Universal CMS - Frontend Stylesheet
 * Fully Responsive, Accessible (WCAG 2.2 AA) & Customizable via CSS Variables
 */

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --accent-color: #ffc107;
    --bg-color: #ffffff;
    --text-color: #212529;
    --text-muted: #64748b;
    --navbar-bg: #1e293b;
    --navbar-text: #ffffff;
    --navbar-hover: rgba(255, 255, 255, 0.12);
    --footer-bg: #0f172a;
    --footer-text: #e2e8f0;
    --footer-link: #94a3b8;
    --footer-link-hover: #ffffff;
    --font-primary: 'Inter', system-ui, -apple-system, sans-serif;
    --font-heading: 'Inter', system-ui, -apple-system, sans-serif;
    --font-size-base: 16px;
    --container-max-width: 1240px;
    --border-radius: 8px;
    --sidebar-width: 320px;
    --transition-speed: 0.25s;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Base Reset & Typography */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: var(--font-size-base);
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.65;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Accessibility Focus Outline */
:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 3px;
}

/* Skip link for keyboard navigation */
.skip-link {
    position: absolute;
    top: -50px;
    left: 10px;
    background: var(--primary-color);
    color: #fff;
    padding: 8px 16px;
    z-index: 9999;
    text-decoration: none;
    font-weight: 600;
    border-radius: var(--border-radius);
    transition: top 0.2s;
}
.skip-link:focus {
    top: 10px;
}

/* Container */
.container {
    width: 100%;
    max-width: var(--container-max-width);
    margin-left: auto;
    margin-right: auto;
    padding-left: 20px;
    padding-right: 20px;
}

/* ==============================================================================
   HEADER & LOGO (Section 7.1)
   ============================================================================== */
.site-header {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 16px 0;
}

.site-header .container {
    display: flex;
    align-items: center;
}

.site-header.logo-left .container {
    justify-content: flex-start;
}
.site-header.logo-center .container {
    justify-content: center;
}
.site-header.logo-right .container {
    justify-content: flex-end;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    color: var(--text-color);
}

.brand-logo {
    max-width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
}

.brand-text {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--primary-color);
}

/* ==============================================================================
   NAVBAR (Section 7.2 & 7.3 & 7.4)
   ============================================================================== */
.site-navbar {
    background-color: var(--navbar-bg);
    color: var(--navbar-text);
    position: relative;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.site-navbar.sticky {
    position: sticky;
    top: 0;
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-item {
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    color: var(--navbar-text);
    text-decoration: none;
    font-weight: 500;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

.nav-link:hover,
.nav-link:focus,
.nav-item.active > .nav-link {
    background-color: var(--navbar-hover);
    color: #fff;
}

.nav-dropdown-icon {
    margin-left: 6px;
    font-size: 0.75rem;
    transition: transform var(--transition-speed);
}

/* Dropdown Submenus */
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--navbar-bg);
    min-width: 220px;
    box-shadow: var(--shadow-lg);
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    list-style: none;
    z-index: 105;
}

.dropdown-menu .nav-link {
    padding: 12px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-item:hover > .dropdown-menu,
.nav-item:focus-within > .dropdown-menu {
    display: block;
}

/* Mobile Hamburger Toggle */
.nav-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--navbar-text);
    padding: 12px;
    cursor: pointer;
    font-size: 1.5rem;
}

/* ==============================================================================
   MAIN CONTENT & SIDEBAR LAYOUT (Section 9)
   ============================================================================== */
.main-wrapper {
    flex: 1 0 auto;
    padding: 40px 0;
}

.layout-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 40px;
}

.layout-grid.with-sidebar-left {
    grid-template-columns: var(--sidebar-width) 1fr;
}

.layout-grid.with-sidebar-right {
    grid-template-columns: 1fr var(--sidebar-width);
}

.content-area {
    min-width: 0; /* prevents flex/grid overflow */
}

/* Editorial Structure (Section 10.1) */
.page-title {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 12px;
    color: var(--text-color);
}

.page-subtitle {
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 16px;
}

.page-lead {
    font-size: 1.15rem;
    color: var(--text-muted);
    margin-bottom: 28px;
    font-weight: 400;
    line-height: 1.6;
}

.page-body {
    font-size: 1.05rem;
    line-height: 1.8;
}

.page-body h2 {
    font-size: 1.85rem;
    margin-top: 36px;
    margin-bottom: 16px;
    color: var(--text-color);
}

.page-body h3 {
    font-size: 1.4rem;
    margin-top: 24px;
    margin-bottom: 12px;
}

.page-body p {
    margin-bottom: 20px;
}

.page-body ul, .page-body ol {
    margin-left: 24px;
    margin-bottom: 20px;
}

.page-body li {
    margin-bottom: 8px;
}

.page-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    margin: 20px 0;
}

.page-body blockquote {
    border-left: 4px solid var(--primary-color);
    padding: 16px 20px;
    background: #f8fafc;
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    font-style: italic;
    margin: 24px 0;
}

/* Sidebar Styles */
.sidebar-area {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.sidebar-widget {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.widget-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-color);
    color: var(--text-color);
}

/* ==============================================================================
   HERO SLIDER CAROUSEL (Section 11.1)
   ============================================================================== */
.hero-slider-section {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: #000;
    margin-bottom: 40px;
}

.hero-slider {
    position: relative;
    height: 480px;
}

.slide-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.8s ease-in-out, visibility 0.8s ease-in-out;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
}

.slide-item.active {
    opacity: 1;
    visibility: visible;
    z-index: 2;
}

.slide-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0.7) 100%);
}

.slide-content {
    position: relative;
    z-index: 5;
    color: #fff;
    max-width: 750px;
}

.slide-title {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 16px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.slide-subtitle {
    font-size: 1.35rem;
    margin-bottom: 24px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* Slider Controls */
.slider-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: background-color var(--transition-speed);
}
.slider-arrow:hover {
    background: rgba(0, 0, 0, 0.8);
}
.slider-prev { left: 24px; }
.slider-next { right: 24px; }

.slider-dots {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10;
}

.dot-btn {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    border: 2px solid transparent;
    cursor: pointer;
    transition: background-color var(--transition-speed), transform var(--transition-speed);
}
.dot-btn.active {
    background: #fff;
    transform: scale(1.2);
}

/* ==============================================================================
   GALLERIES & LIGHTBOX (Section 10.3 & 11.6)
   ============================================================================== */
.gallery-section {
    margin: 36px 0;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    background: #f1f5f9;
    aspect-ratio: 4/3;
    cursor: pointer;
}

.gallery-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease;
}

.gallery-item:hover .gallery-thumb {
    transform: scale(1.06);
}

.gallery-caption-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(0deg, rgba(0,0,0,0.85) 0%, transparent 100%);
    color: #fff;
    padding: 12px 14px;
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity var(--transition-speed);
}

.gallery-item:hover .gallery-caption-overlay {
    opacity: 1;
}

/* Lightbox Modal */
.lightbox-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.lightbox-modal.active {
    display: flex;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lightbox-img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.lightbox-caption {
    color: #fff;
    margin-top: 14px;
    text-align: center;
    font-size: 1rem;
    max-width: 800px;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 25px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 2.5rem;
    cursor: pointer;
    line-height: 1;
    z-index: 1010;
}

.lightbox-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: none;
    font-size: 2rem;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-speed);
    z-index: 1010;
}
.lightbox-arrow:hover {
    background: rgba(255, 255, 255, 0.35);
}
.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }

/* ==============================================================================
   CONTACT FORM & ALERTS (Section 12)
   ============================================================================== */
.contact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}

.contact-info-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--border-radius);
    padding: 30px;
}

.contact-info-item {
    display: flex;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 14px;
}

.contact-icon {
    font-size: 1.35rem;
    color: var(--primary-color);
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.95rem;
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    font-size: 1rem;
    border: 1px solid #cbd5e1;
    border-radius: var(--border-radius);
    background: #fff;
    font-family: inherit;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

textarea.form-control {
    resize: vertical;
    min-height: 140px;
}

.form-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.form-check-input {
    margin-top: 4px;
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--border-radius);
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background-color var(--transition-speed), transform var(--transition-speed), box-shadow var(--transition-speed);
}

.btn-primary {
    background-color: var(--primary-color);
    color: #fff;
}
.btn-primary:hover {
    filter: brightness(0.9);
}

.alert {
    padding: 14px 18px;
    border-radius: var(--border-radius);
    margin-bottom: 24px;
    font-size: 0.95rem;
}
.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}
.alert-danger {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ==============================================================================
   FOOTER (Section 8)
   ============================================================================== */
.site-footer {
    background-color: var(--footer-bg);
    color: var(--footer-text);
    padding: 50px 0 20px;
    margin-top: auto;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(var(--footer-columns, 4), 1fr);
    gap: 30px;
    margin-bottom: 40px;
}

.footer-widget-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 18px;
    color: #fff;
}

.footer-links {
    list-style: none;
}
.footer-links li {
    margin-bottom: 10px;
}
.footer-links a {
    color: var(--footer-link);
    text-decoration: none;
    transition: color var(--transition-speed);
}
.footer-links a:hover {
    color: var(--footer-link-hover);
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 24px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--footer-link);
}

.footer-legal-links {
    display: flex;
    gap: 16px;
    list-style: none;
}
.footer-legal-links a {
    color: var(--footer-link);
    text-decoration: none;
}
.footer-legal-links a:hover {
    color: #fff;
}

/* Social links */
.social-links {
    display: flex;
    gap: 12px;
    margin-top: 14px;
}
.social-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    text-decoration: none;
    transition: background-color var(--transition-speed);
}
.social-icon:hover {
    background: var(--primary-color);
}

/* ==============================================================================
   COOKIE CMP BANNER (Section 18.3 - Garante Privacy 2021)
   ============================================================================== */
.cookie-banner {
    position: fixed;
    bottom: 24px;
    left: 24px;
    right: 24px;
    max-width: 900px;
    margin: 0 auto;
    background: #ffffff;
    color: #1e293b;
    padding: 24px 28px;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid #cbd5e1;
    z-index: 99999;
    display: none;
}

.cookie-banner.show {
    display: block;
    animation: slideUp 0.35s ease;
}

@keyframes slideUp {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.cookie-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.cookie-text {
    font-size: 0.95rem;
    line-height: 1.55;
    margin-bottom: 18px;
    color: #475569;
}

.cookie-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* Equal prominence per Italian Garante Guidelines */
.btn-cookie-accept {
    background-color: var(--primary-color);
    color: #fff;
}
.btn-cookie-reject {
    background-color: #64748b;
    color: #fff;
}
.btn-cookie-prefs {
    background-color: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
}

/* Cookie Floating Trigger */
.cookie-floating-trigger {
    position: fixed;
    bottom: 16px;
    left: 16px;
    background: #1e293b;
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 8px 14px;
    font-size: 0.8rem;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background-color var(--transition-speed);
}
.cookie-floating-trigger:hover {
    background: var(--primary-color);
}

/* Cookie Preferences Modal */
.cookie-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.cookie-modal.active {
    display: flex;
}
.cookie-modal-card {
    background: #fff;
    max-width: 650px;
    width: 100%;
    border-radius: 12px;
    padding: 28px;
    max-height: 90vh;
    overflow-y: auto;
}
.cookie-cat-item {
    border-bottom: 1px solid #e2e8f0;
    padding: 16px 0;
}
.cookie-cat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

/* ==============================================================================
   RESPONSIVE MEDIA QUERIES (Mobile & Tablet)
   ============================================================================== */
@media (max-width: 992px) {
    .layout-grid.with-sidebar-left,
    .layout-grid.with-sidebar-right {
        grid-template-columns: 1fr;
    }

    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .contact-grid {
        grid-template-columns: 1fr;
    }

    .hero-slider {
        height: 380px;
    }

    .slide-title {
        font-size: 2.2rem;
    }
}

@media (max-width: 768px) {
    .nav-toggle {
        display: block;
    }

    .nav-menu {
        display: none;
        flex-direction: column;
        width: 100%;
        position: absolute;
        top: 100%;
        left: 0;
        background-color: var(--navbar-bg);
        box-shadow: var(--shadow-lg);
    }

    .nav-menu.open {
        display: flex;
    }

    .dropdown-menu {
        position: static;
        box-shadow: none;
        padding-left: 20px;
        background-color: rgba(0, 0, 0, 0.15);
    }

    .footer-grid {
        grid-template-columns: 1fr;
    }

    .hero-slider {
        height: 300px;
    }

    .slide-title {
        font-size: 1.75rem;
    }

    .slide-subtitle {
        font-size: 1rem;
    }

    .page-title {
        font-size: 2rem;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
}

/* Accessibility: Respect Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

