/* Reset e Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
}

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #e0f2fe 0%, #bfdbfe 100%);
    color: #1e293b;
    line-height: 1.7;
    font-size: 16px;
    height: 100%;
    margin: 0;
    padding: 0;
}

/* Container principale */
.container {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: horizontal;
    -webkit-box-direction: normal;
    -webkit-flex-direction: row;
    -ms-flex-direction: row;
    flex-direction: row;
    -webkit-flex-wrap: nowrap;
    -ms-flex-wrap: nowrap;
    flex-wrap: nowrap;
    max-width: 1600px;
    margin: 0 auto;
    min-height: 100vh;
    background: white;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    position: relative;
}

/* Pulsante toggle menu - sempre visibile in alto a sinistra */
.menu-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.4);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.menu-toggle:hover {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(30, 64, 175, 0.5);
}

.menu-toggle:active {
    transform: scale(0.95);
}

.menu-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Sidebar con stati espanso/minimizzato */
.sidebar {
    width: 280px;
    min-width: 280px;
    max-width: 280px;
    -webkit-box-flex: 0;
    -webkit-flex: 0 0 280px;
    -ms-flex: 0 0 280px;
    flex: 0 0 280px;
    -webkit-flex-shrink: 0;
    -ms-flex-negative: 0;
    flex-shrink: 0;
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 50%, #334155 100%);
    color: white;
    padding: 0;
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.1);
    z-index: 999;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Stato minimizzato del sidebar */
.sidebar.minimized {
    width: 60px;
    min-width: 60px;
    max-width: 60px;
    -webkit-flex: 0 0 60px;
    -ms-flex: 0 0 60px;
    flex: 0 0 60px;
}

.sidebar.minimized .sidebar-header .tagline,
.sidebar.minimized h2,
.sidebar.minimized nav ul li a span {
    opacity: 0;
    visibility: hidden;
}

.sidebar.minimized .sidebar-header h1 {
    font-size: 0;
}

.sidebar.minimized .sidebar-header h1::before {
    content: 'G';
    font-size: 1.5em;
}

.sidebar.minimized nav ul li a {
    padding: 10px 5px;
    text-align: center;
    font-size: 1.2em;
}

.sidebar.minimized nav ul li a:hover {
    padding-left: 5px;
}

/* Trigger zone per espandere il menu (area invisibile a sinistra) */
.sidebar-trigger {
    position: fixed;
    left: 0;
    top: 0;
    width: 30px;
    height: 100vh;
    z-index: 998;
    background: transparent;
}

/* Scrollbar per sidebar */
.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.sidebar-header {
    padding: 25px 20px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    transition: all 0.3s ease;
}

.sidebar-header h1 {
    font-size: 1.4em;
    margin-bottom: 5px;
    color: #60a5fa;
    font-weight: 600;
    transition: all 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-header .tagline {
    font-size: 0.85em;
    color: #cbd5e1;
    font-style: italic;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar h2 {
    font-size: 0.95em;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 25px 20px 12px 20px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(96, 165, 250, 0.3);
    color: #93c5fd;
    font-weight: 600;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar nav ul {
    list-style: none;
    margin: 0 10px 20px 10px;
}

.sidebar nav ul li {
    margin-bottom: 2px;
}

.sidebar nav ul li a {
    color: #e2e8f0;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-size: 0.92em;
    border-left: 3px solid transparent;
    -webkit-tap-highlight-color: rgba(96, 165, 250, 0.2);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar nav ul li a::before {
    content: '›';
    font-size: 1.4em;
    font-weight: bold;
    color: #60a5fa;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.sidebar nav ul li a:hover::before,
.sidebar nav ul li a:active::before {
    transform: translateX(3px);
}

.sidebar nav ul li a:hover,
.sidebar nav ul li a:active {
    background: rgba(96, 165, 250, 0.15);
    border-left-color: #60a5fa;
    padding-left: 20px;
    color: white;
}

.sidebar nav ul li a span {
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Main Content */
.main-content {
    -webkit-box-flex: 1;
    -webkit-flex: 1 1 auto;
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
    min-width: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #ffffff;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Header elegante */
header {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #60a5fa 100%);
    color: white;
    padding: 50px 60px 50px 90px;
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 120"><path d="M0,0 Q300,60 600,30 T1200,60 L1200,120 L0,120 Z" fill="rgba(255,255,255,0.05)"/></svg>') repeat-x bottom;
    opacity: 0.5;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 12px;
    font-weight: 700;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 1;
}

.motto {
    font-style: italic;
    font-size: 1.1em;
    opacity: 0.95;
    margin-top: 15px;
    position: relative;
    z-index: 1;
}

/* Content Area */
.content-area {
    padding: 50px 60px;
}

section {
    margin-bottom: 45px;
    padding: 35px;
    background: #f8fafc;
    border-radius: 12px;
    border-left: 5px solid #3b82f6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s, box-shadow 0.2s;
}

section:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.1);
}

section:active {
    transform: translateY(-1px);
}

section h2 {
    color: #1e40af;
    font-size: 2em;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 3px solid #3b82f6;
    font-weight: 700;
}

section h3 {
    color: #2563eb;
    font-size: 1.4em;
    margin: 25px 0 15px 0;
    font-weight: 600;
}

section h4 {
    color: #3b82f6;
    font-size: 1.2em;
    margin: 20px 0 10px 0;
    font-weight: 600;
}

section p {
    margin-bottom: 15px;
    color: #334155;
    line-height: 1.8;
}

section ul, section ol {
    margin: 15px 0 15px 30px;
    color: #334155;
}

section li {
    margin-bottom: 10px;
    line-height: 1.7;
}

section a {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
    -webkit-tap-highlight-color: rgba(59, 130, 246, 0.2);
}

section a:hover,
section a:active {
    color: #1e40af;
    text-decoration: underline;
}

/* Updates List */
.updates-list {
    background: white;
    padding: 25px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.updates-list ol {
    padding-left: 25px;
}

.updates-list li {
    margin-bottom: 14px;
    line-height: 1.8;
}

.updates-list strong {
    color: #1e40af;
    font-weight: 600;
}

/* Image Grid */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.image-item {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    border: 1px solid #e2e8f0;
}

.image-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.2);
}

.image-item:active {
    transform: translateY(-3px);
}

.image-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.image-item .caption {
    padding: 15px;
    text-align: center;
    font-size: 0.95em;
    color: #475569;
    background: #f8fafc;
}

/* Footer */
footer {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #cbd5e1;
    text-align: center;
    padding: 30px 60px;
    font-size: 0.92em;
    border-top: 3px solid #3b82f6;
}

footer a {
    color: #93c5fd;
    text-decoration: none;
}

footer a:hover,
footer a:active {
    color: #60a5fa;
    text-decoration: underline;
}

/* Media Queries per iOS e responsive */
@media screen and (max-width: 1024px) {
    .container {
        -webkit-box-orient: horizontal;
        -webkit-box-direction: normal;
        -webkit-flex-direction: row;
        -ms-flex-direction: row;
        flex-direction: row;
    }
    
    .sidebar {
        width: 240px;
        min-width: 240px;
        max-width: 240px;
        -webkit-flex: 0 0 240px;
        -ms-flex: 0 0 240px;
        flex: 0 0 240px;
    }
    
    .sidebar.minimized {
        width: 50px;
        min-width: 50px;
        max-width: 50px;
        -webkit-flex: 0 0 50px;
        -ms-flex: 0 0 50px;
        flex: 0 0 50px;
    }
    
    header {
        padding: 35px 30px 35px 70px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .content-area {
        padding: 30px;
    }
    
    section {
        padding: 25px;
    }
}

@media screen and (max-width: 768px) {
    .menu-toggle {
        top: 15px;
        left: 15px;
        width: 45px;
        height: 45px;
    }
    
    .sidebar {
        width: 200px;
        min-width: 200px;
        max-width: 200px;
        -webkit-flex: 0 0 200px;
        -ms-flex: 0 0 200px;
        flex: 0 0 200px;
        font-size: 0.9em;
    }
    
    .sidebar.minimized {
        width: 45px;
        min-width: 45px;
        max-width: 45px;
        -webkit-flex: 0 0 45px;
        -ms-flex: 0 0 45px;
        flex: 0 0 45px;
    }
    
    .sidebar-header h1 {
        font-size: 1.2em;
    }
    
    .sidebar h2 {
        font-size: 0.85em;
    }
    
    .sidebar nav ul li a {
        padding: 8px 12px;
        font-size: 0.88em;
    }
    
    header {
        padding: 25px 20px 25px 65px;
    }
    
    header h1 {
        font-size: 1.6em;
    }
    
    .motto {
        font-size: 0.95em;
    }
    
    .content-area {
        padding: 20px;
    }
    
    section {
        padding: 20px;
    }
    
    section h2 {
        font-size: 1.6em;
    }
    
    .image-grid {
        grid-template-columns: 1fr;
    }
    
    footer {
        padding: 20px;
    }
}

@media screen and (max-width: 480px) {
    .menu-toggle {
        top: 10px;
        left: 10px;
        width: 40px;
        height: 40px;
    }
    
    .menu-toggle span {
        width: 20px;
        height: 2px;
    }
    
    .sidebar {
        width: 180px;
        min-width: 180px;
        max-width: 180px;
        -webkit-flex: 0 0 180px;
        -ms-flex: 0 0 180px;
        flex: 0 0 180px;
        padding: 0 5px;
        font-size: 0.85em;
    }
    
    .sidebar.minimized {
        width: 40px;
        min-width: 40px;
        max-width: 40px;
        -webkit-flex: 0 0 40px;
        -ms-flex: 0 0 40px;
        flex: 0 0 40px;
    }
    
    .sidebar-header {
        padding: 15px 10px;
    }
    
    .sidebar-header h1 {
        font-size: 1.1em;
    }
    
    .sidebar h2 {
        font-size: 0.8em;
        margin: 15px 10px 10px;
    }
    
    .sidebar nav ul {
        margin: 0 5px 15px;
    }
    
    .sidebar nav ul li a {
        padding: 7px 10px;
        font-size: 0.85em;
    }
    
    header {
        padding: 20px 15px 20px 55px;
    }
    
    header h1 {
        font-size: 1.4em;
    }
    
    .content-area {
        padding: 15px;
    }
    
    section {
        padding: 15px;
        margin-bottom: 25px;
    }
}

/* Utility Classes */
.highlight {
    background: #dbeafe;
    padding: 20px;
    border-left: 4px solid #3b82f6;
    border-radius: 6px;
    margin: 20px 0;
}

.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

/* Fix per Safari iOS */
input, textarea, select {
    font-size: 16px;
}

/* Animazioni smooth */
@keyframes slideIn {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}
