/* ==========================================================
   VARIABILI E DESIGN SYSTEM
   ========================================================== */

:root {
    /* Palette Colori */
    --bg-main: #f5f7f8;
    --bg-card: #ffffff;
    --primary: #5b7c87;
    --primary-light: #7a9aa5;
    --primary-soft: #e6eff2;
    --text-main: #2f3a40;
    --text-muted: #6f7f87;
    --text-light: #8a98a0;
    --border-soft: #d9e1e5;
    --border-light: #e5e7eb;
    
    /* Stati */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --accent-bg: #f1f3f5;
    
    /* Spaziature */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    
    /* Design Tokens */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;
    --shadow-soft: 0 2px 8px rgba(47, 58, 64, 0.04);
    --shadow-md: 0 4px 12px rgba(47, 58, 64, 0.06);
    --shadow-lg: 0 8px 24px rgba(47, 58, 64, 0.08);
    --transition-fast: 0.2s ease;
    --transition-smooth: 0.3s ease;
}

/* ==========================================================
   BASE & RESET
   ========================================================== */

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    /*padding-top: 70px;*/
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Layout Container Responsivo */
.container {
    width: 100%;
    margin-right: auto;
    margin-left: auto;
    padding-right: var(--space-md);
    padding-left: var(--space-md);
    max-width: 560px; /* Default Mobile */
}

@media (min-width: 640px)  { .container { max-width: 720px; } }
@media (min-width: 768px)  { .container { max-width: 960px; } }
@media (min-width: 1024px) { .container { max-width: 1140px; } }
@media (min-width: 1280px) { .container { max-width: 1280px; } }

/* ==========================================================
   HEADER & NAVIGAZIONE
   ========================================================== */

.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    z-index: 1000;
    box-shadow: var(--shadow-soft);
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px var(--space-md);
    gap: 12px;
}

/* Sidebar & Overlays */
.sidebar {
    position: fixed;
    top: 70px;
    left: -280px;
    width: 280px;
    height: calc(100vh - 70px);
    background: var(--bg-card);
    border-right: 1px solid var(--border-light);
    transition: left var(--transition-smooth);
    z-index: 999;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.sidebar.show { left: 0; }

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(47, 58, 64, 0.4);
    backdrop-filter: blur(2px);
    display: none;
    z-index: 998;
    animation: fadeIn 0.2s ease;
}

.overlay.show { display: block; }

/* ==========================================================
   COMPONENTI UI (Cards, Form, Buttons)
   ========================================================== */

.card, .box, section, form {
    background-color: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    box-shadow: var(--shadow-soft);
    margin-bottom: var(--space-md);
    animation: slideUp 0.3s ease;
}

/* Form Elements */
input:not([type="checkbox"]):not([type="radio"]), 
textarea, 
select {
    width: 100%;
    padding: 12px 14px;
    font-size: 1rem;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    background-color: #ffffff;
    transition: all var(--transition-fast);
    appearance: none;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Pulsanti */
.btn, button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    background-color: var(--primary);
    color: #ffffff;
    transition: all var(--transition-fast);
    min-height: 44px;
    text-decoration: none;
}

.btn:hover:not(:disabled) {
    background-color: var(--primary-light);
    box-shadow: var(--shadow-md);
}

.btn:active { transform: scale(0.98); }

/* ==========================================================
   COMPONENTI SPECIFICI
   ========================================================== */

/* Role Switcher */
.role-switch {
    display: flex;
    position: relative;
    background: var(--accent-bg);
    border-radius: var(--radius-full);
    padding: 4px;
    width: 100%;
    max-width: 400px;
    margin: var(--space-md) auto;
}

.role-switch input { display: none; }

.role-switch label {
    flex: 1;
    text-align: center;
    padding: 10px;
    cursor: pointer;
    z-index: 2;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: color 0.3s;
}

.role-slider {
    position: absolute;
    width: calc(50% - 4px);
    height: calc(100% - 8px);
    background: var(--bg-card);
    box-shadow: var(--shadow-soft);
    border-radius: var(--radius-full);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#role-user:checked ~ .role-slider { transform: translateX(0); }
#role-professional:checked ~ .role-slider { transform: translateX(100%); }
#role-user:checked + label, #role-professional:checked + label { color: var(--primary); }

/* Search Wrapper */
.search-wrapper {
    position: relative;
    margin-bottom: var(--space-md);
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    pointer-events: none;
}

#articleSearch {
    padding-left: 44px;
    background: #fafafa;
}

/* Contenuto Articolo Statico */
.article-content-static {
    max-width: 750px;
    margin: 0 auto;
    font-size: 1.125rem;
    line-height: 1.8;
}

.article-content-static img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-lg);
    margin: var(--space-xl) 0;
}

/* ==========================================================
   ANIMAZIONI & MEDIA QUERIES
   ========================================================= */

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (max-width: 480px) {
    html { font-size: 15px; }
    .app-subtitle, .lang-btn span { display: none; }
    .header-container { padding: 10px; }
    .page-title-mobile { display: block; }
}
/* ==========================================================
   CORREZIONE ICONE E IMMAGINI
   ========================================================== */

/* Impedisce alle icone SVG di esplodere se non hanno classi */
svg {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0; /* Impedisce lo schiacciamento nei flexbox */
}

/* Dimensioni standard per le icone nei bottoni e menu */
.nav-item-main svg, 
.menu-trigger-btn svg,
.search-icon {
    width: 20px !important;
    height: 20px !important;
}

/* FIX IMMAGINI SBORDANTI */
img {
    max-width: 100%;
    height: auto; /* Mantiene le proporzioni */
    display: block;
}

/* ==========================================================
   LAYOUT ARTICOLO (Miglioramento logica)
   ========================================================== */

.article-view {
    max-width: 800px !important; /* Forza una larghezza leggibile */
    margin: 0 auto;
    padding: var(--space-xl) var(--space-md);
}

.article-content-static {
    width: 100%;
    overflow-wrap: break-word; /* Impedisce al testo lungo di rompere il layout */
}

/* Forza le immagini dentro l'articolo a stare nei bordi */
.article-content-static img {
    width: 100%;
    object-fit: cover;
    border-radius: var(--radius-lg);
    margin: var(--space-lg) 0;
    box-shadow: var(--shadow-md);
}

/* Griglia Correlati (per evitare che le foto sbordino qui) */
.articles-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-lg);
    width: 100%;
}

/* ==========================================================
   RIPRISTINO HEADER BRAND (Logo + Titolo)
   ========================================================== */

.header-brand .logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    gap: 10px; /* Spazio preciso tra logo e testo */
    min-width: max-content;
}

/* Proteggiamo il mini-logo dalle regole generali delle immagini */
.header-brand .app-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0; /* Impedisce che il logo si rimpicciolisca */
}

.header-brand .app-logo img {
    width: 16px !important;
    height: 16px !important;
    display: block;
    margin: 0 !important; /* Rimuove eventuali margini delle immagini articoli */
    box-shadow: none !important; /* Rimuove ombre se applicate globalmente */
}

/* Ripristino Titolo */
.header-brand .app-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 !important; /* Fondamentale: azzera i margini degli H1 globali */
    padding: 0;
    line-height: 1;
    white-space: nowrap; /* Impedisce al nome di andare a capo */
}

/* Correzione per l'header container */
.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px; /* Forza l'altezza corretta */
}