:root {
    --bg-color: #fcfdfe;
    --text-main: #2d3748;
    --text-muted: #a0aec0;
    --primary: #ff6b6b;
    --accent: #4ecdc4;
    --card-bg: #ffffff;
    --radius: 16px;
}

/* Reset globale per evitare problemi di overflow su mobile */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
}

/* Header & Navigazione Lingua */
.site-header {
    padding: 1.5rem 1rem;
    text-align: center;
    width: 100%;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 0 1rem;
}

.brand-logo {
    max-width: 180px;
    height: auto;
}

.lang-switcher a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    transition: color 0.2s;
}

.lang-switcher a.active, 
.lang-switcher a:hover {
    color: var(--primary);
}

/* Layout Principale a Griglia (Desktop a 3 colonne) */
.main-content {
    flex: 1;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

.app-container-grid {
    display: grid;
    grid-template-columns: 280px 1fr 280px;
    gap: 20px;
    align-items: start;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Regola Responsive per Tablet e Smartphone (sotto i 1024px) -> Forza colonna singola */
@media (max-width: 1024px) {
    .app-container-grid {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: 1fr !important;
        padding: 0 !important;
        gap: 15px !important;
        width: 100% !important;
    }

    .main-content {
        padding: 10px !important;
    }

    /* Ordine degli elementi su mobile: prima il sondaggio/feed, poi le sidebar */
    .main-feed {
        order: 1;
        width: 100%;
    }
    .sidebar-left {
        order: 2;
        width: 100%;
    }
    .sidebar-right {
        order: 3;
        width: 100%;
    }
}

/* Card e Contenitori */
.poll-card {
    background: var(--card-bg);
    width: 100%;
    max-width: 100%;
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
}

.poll-card h1 {
    font-size: 1.6rem;
    margin-bottom: 0.5rem;
}

.poll-desc {
    color: #718096;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

/* Form Wizard & Opzioni */
.options-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    width: 100%;
}

.option-pill {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-left-width: 6px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    word-break: break-word;
    width: 100%;
    box-sizing: border-box;
}

.option-pill:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.option-pill input {
    margin-right: 1rem;
    flex-shrink: 0;
}

.option-text {
    word-break: break-word;
}

/* Bottoni */
.btn-vote {
    width: 100%;
    background-color: var(--text-main);
    color: white;
    border: none;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s ease;
    box-sizing: border-box;
}

.btn-vote:hover {
    background-color: var(--primary);
}

.wizard-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 25px;
    gap: 15px;
    width: 100%;
}

.btn-next, .btn-prev {
    background: #f1f3f5;
    color: #333;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
    flex: 1;
}

.btn-next:hover, .btn-prev:hover {
    background: #e2e6ea;
}

.btn-next {
    background: var(--accent);
    color: white;
}

.btn-next:hover {
    background: #3dbdb4;
}

/* Step Wizard Controlli */
.hidden-step {
    display: none;
}

.active-step {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
    width: 100%;
}

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

.step-counter {
    font-size: 0.85rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    font-weight: 600;
}

.step-question {
    font-size: 1.25rem;
    color: #222;
    margin-bottom: 20px;
    word-break: break-word;
}

/* Sidebar & Schema Compatto Preferenze */
.personal-summary-box, 
.sidebar-notice,
.sidebar-right {
    background: #fff;
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    width: 100%;
    box-sizing: border-box;
}

.personal-summary-box h3 {
    font-size: 1.1rem;
    margin-bottom: 5px;
    color: #222;
}

.summary-subtitle-small, 
.summary-subtitle {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 15px;
}

.compact-choices-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.compact-choice-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    border-left: 4px solid #ccc;
    font-size: 0.9rem;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.compact-q-num {
    font-weight: bold;
    font-size: 0.75rem;
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 4px;
    color: #555;
    white-space: nowrap;
    flex-shrink: 0;
}

.compact-texts {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    overflow: hidden;
    flex: 1;
}

.compact-q-text {
    font-size: 0.75rem;
    color: #777;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.compact-a-text {
    font-weight: 600;
    color: #333;
    word-break: break-word;
}

/* Altri elementi di servizio */
.alert {
    background: #e6fffa;
    color: #234e52;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
}

.center-dashboard {
    text-align: center;
    padding: 20px;
    color: #555;
    width: 100%;
    box-sizing: border-box;
}

/* Ottimizzazione elementi interni per mobile */
.sidebar-left, .sidebar-right, .poll-card, .center-dashboard {
    width: 100%;
    box-sizing: border-box;
}

input[type="text"], button, .option-pill {
    max-width: 100%;
    box-sizing: border-box;
}

/* Forza la card del sondaggio ad occupare tutto lo spazio disponibile su mobile */
@media (max-width: 768px) {
    .main-content {
        padding: 10px !important;
        width: 100% !important;
    }
    
    .poll-card {
        width: 100% !important;
        max-width: 100% !important;
        padding: 1.25rem !important;
        margin: 0 auto;
    }

    /* Sistema l'header per evitare sovrapposizioni su schermi piccoli */
    .header-container {
        flex-direction: column;
        gap: 12px;
        padding: 0 10px;
    }
}

/* Layout del profilo responsive: di default a una colonna (mobile-first) */
.profile-grid {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Da tablet/desktop in poi torna a griglia a 2 colonne */
@media (min-width: 768px) {
    .profile-grid {
        display: grid;
        grid-template-columns: 1fr 280px;
        align-items: start;
    }
}