@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* ══════════════════════════════════════════════════════════════════
   DESIGN TOKENS (Aligned with Backoffice)
   ══════════════════════════════════════════════════════════════════ */

:root {
    /* Brand Palette — Melanzana */
    --primary-color: #3B1046;
    --primary-hover: #2D0C35;
    --primary-light: #F0E4F5;

    --secondary-color: #3B1046;
    --secondary-hover: #2D0C35;
    --secondary-text: #6b7280;

    /* Surfaces */
    --background-color: #f5f5f9;
    --card-bg: #ffffff;

    /* Text */
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --text-dark: #1a1e21;

    /* Borders */
    --border-color: #e2e8f0;
    --border-light: #f3f4f6;
    --border-card-edge: #e5e7eb;

    /* Semantic Colors */
    --color-danger: #dc3545;
    --color-danger-hover: #bb2d3b;
    --color-warning: #ffc107;
    --color-success: #22c55e;

    /* Bootstrap Overrides */
    --bs-primary: #3B1046;
    --bs-dark: #3B1046;
    --bs-body-bg: #f5f5f9;
    --bs-body-color: #1f2937;
    --bs-body-font-family: 'Poppins', sans-serif;

    /* Spacing & Radius */
    --radius-lg: 32px;
    --radius-md: 20px;
    --radius-pill: 999px;

    /* Shadows — flat & subtle (Backoffice Style) */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-btn: 0 2px 4px rgba(59, 16, 70, 0.15);
    --shadow-btn-hover: 0 4px 8px rgba(59, 16, 70, 0.25);

    /* Animation */
    --transition-fast: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-micro: 0.2s ease;
}


/* ══════════════════════════════════════════════════════════════════
   BASE TYPOGRAPHY
   ══════════════════════════════════════════════════════════════════ */

body {
    background-color: var(--background-color) !important;
    color: var(--text-main);
    font-family: 'Poppins', sans-serif;
    line-height: 1.6;
    overflow-x: hidden;
    overflow-y: scroll;
}

h1,
h2,
h3,
h4,
h5 {
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-main);
}

/* ══════════════════════════════════════════════════════════════════
   BOOTSTRAP OVERRIDES
   ══════════════════════════════════════════════════════════════════ */

.text-primary {
    color: var(--primary-color) !important;
}

.bg-primary {
    background-color: var(--primary-color) !important;
}

.text-white,
.text-white-50 {
    color: var(--text-main) !important;
}

.bg-primary .text-white,
.badge.bg-primary {
    color: #ffffff !important;
}

/* --- Buttons --- */

.btn {
    border-radius: 8px;
    /* Matched Backoffice */
    padding: 8px 20px;
    font-weight: 500;
    font-size: 0.875rem;
    transition: var(--transition-fast);
    box-shadow: none;
}

.btn-sm {
    padding: 5px 14px;
    font-size: 0.8rem;
}

.btn-primary,
.btn-next {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #ffffff !important;
    box-shadow: var(--shadow-btn) !important;
}

.btn-primary:hover,
.btn-next:hover {
    background-color: var(--primary-hover) !important;
    color: #ffffff !important;
    transform: translateY(-1px);
    box-shadow: var(--shadow-btn-hover) !important;
}

.btn-outline-primary {
    color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    background: transparent !important;
}

.btn-outline-primary:hover {
    background-color: var(--primary-color) !important;
    color: #ffffff !important;
    transform: translateY(-1px);
    box-shadow: var(--shadow-btn-hover) !important;
}

.btn-dark {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #ffffff !important;
}

.btn-dark:hover {
    background-color: var(--primary-hover) !important;
    transform: translateY(-1px);
    box-shadow: var(--shadow-btn-hover) !important;
}

.btn-danger {
    background-color: var(--color-danger) !important;
    color: white !important;
    border-color: var(--color-danger) !important;
    border: none !important;
    box-shadow: var(--shadow-btn) !important;
}

.btn-danger:hover {
    background-color: var(--color-danger-hover) !important;
    color: white !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3) !important;
}

.btn-outline-light {
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.5) !important;
    background: transparent !important;
}

.btn-outline-light:hover {
    background-color: rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
    border-color: #ffffff !important;
    transform: translateY(-1px);
    box-shadow: var(--shadow-btn-hover) !important;
}

/* --- Navbar (If used) --- */

.navbar-dark.bg-primary {
    background-color: var(--secondary-color) !important;
    backdrop-filter: none;
    border-bottom: none;
}

/* Header fisso in top */
#header-container {
    position: sticky;
    top: 0;
    z-index: 1030;
}

#header-container .navbar {
    margin-bottom: 0 !important;
}

/* ══════════════════════════════════════════════════════════════════
   CARDS — Flat Clean Design (Backoffice Style)
   ══════════════════════════════════════════════════════════════════ */

.card {
    border: 1px solid var(--border-color) !important;
    border-radius: 12px !important;
    background: var(--card-bg) !important;
    box-shadow: var(--shadow-sm);
    transform: none !important;
    will-change: transform, box-shadow;
    transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    z-index: 1;
}

.card:hover {
    transform: translateY(-2px) !important;
    z-index: 20;
    box-shadow: var(--shadow-md);
}

.card-premium-dark {
    background: var(--card-bg) !important;
    color: var(--text-main) !important;
    border-radius: 12px !important;
    box-shadow: var(--shadow-sm);
    transform: none !important;
    will-change: transform;
    transition: transform var(--transition-micro), box-shadow var(--transition-micro);
    border: 1px solid var(--border-color);
}

.card-premium-dark:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px) !important;
}

.card-premium-dark .card-text {
    color: var(--text-muted) !important;
    opacity: 1;
}

/* ══════════════════════════════════════════════════════════════════
   AUTH CONTAINER (Login/Register)
   ══════════════════════════════════════════════════════════════════ */

.auth-container {
    max-width: 450px;
    margin: 80px auto;
    padding: 3.5rem;
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-md);
    transform: translateY(0);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    z-index: 1;
}

.auth-container:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    z-index: 100;
}

.auth-container h3,
.auth-container label {
    color: var(--text-main) !important;
}

.auth-container .btn-primary {
    background-color: var(--primary-color) !important;
    color: #ffffff !important;
    font-weight: 600;
    border-radius: 8px;
}

.auth-container a {
    color: var(--primary-color) !important;
}

.auth-container a:hover {
    color: var(--primary-hover) !important;
    text-decoration: underline !important;
}

/* ══════════════════════════════════════════════════════════════════
   WIZARD COMPONENTS (Questionnaire Compile)
   ══════════════════════════════════════════════════════════════════ */

.wizard-container {
    position: relative;
    min-height: 420px;
}

.wizard-card {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    padding: 3.5rem;
    width: 100%;
    display: none;
    animation-duration: 0.5s;
    animation-fill-mode: backwards;
    border: 1px solid var(--border-color);
    will-change: transform, box-shadow;
    transition: transform 0.3s ease-out, box-shadow 0.3s ease-out !important;
    cursor: default;
}

.wizard-card.active {
    display: block;
}

.wizard-card:hover {
    transform: translateY(-4px) !important;
    box-shadow: var(--shadow-lg) !important;
}

.wizard-card h1,
.wizard-card h2,
.wizard-card h3,
.wizard-card h4,
.wizard-card h5,
.wizard-card p,
.wizard-card label {
    color: var(--text-main) !important;
}

.animate-in {
    animation-name: slideInRight;
}

.animate-out {
    animation-name: slideOutLeft;
}

@keyframes slideInRight {
    from {
        transform: translateX(50px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutLeft {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(-50px);
        opacity: 0;
    }
}

.progress-container {
    position: sticky;
    top: 20px;
    z-index: 100;
    margin-bottom: 3rem;
}

.custom-progress {
    height: 8px;
    background: var(--border-color);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.custom-progress-bar {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.options-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 2rem;
}

/* Wizard Navigation */
.wizard-footer {
    margin-top: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.btn-nav {
    border-radius: 8px;
    /* Changed to match Backoffice */
    padding: 12px 32px;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    transition: var(--transition-fast);
    flex: 1;
    max-width: 200px;
}

.wizard-footer .btn-prev {
    background: white !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-muted) !important;
    box-shadow: var(--shadow-sm) !important;
}

.wizard-footer .btn-prev:hover {
    border-color: var(--primary-color) !important;
    color: var(--primary-color) !important;
    transform: translateX(-4px);
    box-shadow: var(--shadow-md) !important;
}

/* ══════════════════════════════════════════════════════════════════
   FORM INPUTS & OPTIONS
   ══════════════════════════════════════════════════════════════════ */

.minimal-input {
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
    border: 1px solid var(--border-color) !important;
    border-radius: 12px !important;
    background: #f8fafc !important;
    transition: var(--transition-fast);
    outline: none;
    margin-top: 1rem;
    color: var(--text-main) !important;
    font-weight: 500;
    box-shadow: none;
}

.minimal-input:focus {
    border-color: var(--primary-color) !important;
    background: white !important;
    box-shadow: 0 0 0 4px var(--primary-light) !important;
}

/* ── Nota domanda ───────────────────────────────────────────────── */
.question-note {
    font-size: 0.80rem;
    color: #94a3b8;
    margin: -0.5rem 0 1.25rem;
    line-height: 1.5;
    font-style: italic;
}

/* ── Campi Multipli ─────────────────────────────────────────────── */
.multi-fields-wrapper {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 1.5rem;
}

.multi-field-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 14px;
    background: rgba(255,255,255,0.04);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.multi-field-label {
    flex: 1;
    font-size: 0.92rem;
    color: #cbd5e1;
    margin: 0;
    line-height: 1.4;
}

.multi-field-input {
    width: 110px !important;
    flex-shrink: 0;
    text-align: center;
    font-size: 1rem !important;
    padding: 10px 8px !important;
    margin-top: 0 !important;
    pointer-events: auto !important;
}

.option-pill-stacked {
    cursor: pointer;
    padding: 16px 24px;
    background: #f8fafc !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 12px !important;
    font-weight: 500;
    color: var(--text-main) !important;
    transition: all var(--transition-micro);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.option-pill-stacked:hover {
    background: white !important;
    box-shadow: var(--shadow-sm);
    transform: translateX(4px);
    border-color: var(--primary-color) !important;
}

.option-pill-stacked.selected {
    background: var(--primary-color) !important;
    color: #ffffff !important;
    border-color: var(--primary-color) !important;
    box-shadow: var(--shadow-md) !important;
    font-weight: 700;
}

.option-pill-stacked.selected span,
.option-pill-stacked.selected i {
    color: #ffffff !important;
}

/* ══════════════════════════════════════════════════════════════════
   QUESTION MAP SIDEBAR
   ══════════════════════════════════════════════════════════════════ */

.nav-map-container {
    padding-bottom: 2rem;
}

.map-section-title {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    padding-left: 0.5rem;
    border-left: 3px solid var(--primary-color);
}

.map-list-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.map-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-micro);
    color: var(--text-main);
    font-size: 0.9rem;
}

.map-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.map-status-icon {
    font-size: 0.5rem;
    margin-right: 10px;
    color: var(--border-color);
    transition: all var(--transition-micro);
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.map-item-number {
    font-weight: 600;
    margin-right: 8px;
    min-width: 25px;
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.map-item-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
}

.map-item.current {
    font-weight: 700;
    background-color: rgba(16, 185, 129, 0.1);
}

.map-item.current .map-status-icon {
    color: var(--secondary-color);
    transform: scale(1.5);
}

.map-item.answered {
    color: var(--primary-hover) !important;
    font-weight: 700;
}

.map-item.answered .map-status-icon:before {
    content: "\f058";
    font-size: 0.9rem;
}

/* ══════════════════════════════════════════════════════════════════
   NAVIGATION DRAWER & MAP GRID
   ══════════════════════════════════════════════════════════════════ */

.nav-drawer {
    position: fixed;
    top: 0;
    right: -320px;
    width: 320px;
    height: 100vh;
    background: white;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
    z-index: 2000;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 2.5rem;
    overflow-y: auto;
}

/* Report page: drawer starts below navbar */
body.report-page .nav-drawer {
    top: var(--navbar-height, 56px);
    height: calc(100vh - var(--navbar-height, 56px));
}

body.report-page .overlay-backdrop {
    top: var(--navbar-height, 56px);
    height: calc(100vh - var(--navbar-height, 56px));
}

.nav-drawer.open {
    right: 0;
}

.nav-map-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.nav-dot {
    width: 45px;
    height: 45px;
    border-radius: 12px;
    background: #f1f5f9;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-micro);
}

.nav-dot.answered {
    background: var(--primary-light);
    color: var(--primary-hover);
    border: 2px solid var(--primary-color);
}

.nav-dot.current {
    background: var(--primary-color);
    color: var(--text-dark);
    transform: scale(1.1);
    font-weight: 800;
}

.map-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: white;
    color: var(--text-main);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1040;
    transition: transform var(--transition-micro);
}

.overlay-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 1999;
    display: none;
}

.overlay-backdrop.show {
    display: block;
}

/* ══════════════════════════════════════════════════════════════════
   TABLE
   ══════════════════════════════════════════════════════════════════ */

.table {
    background: var(--card-bg) !important;
    border: none !important;
    border-radius: 12px;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
}

.table th,
.table td {
    border-bottom: 3px solid var(--card-bg) !important;
    border-color: var(--card-bg) !important;
    color: var(--text-main) !important;
}

.table th {
    font-weight: 700;
    color: var(--text-main) !important;
    text-transform: uppercase;
    font-size: 0.85rem;
}

/* ══════════════════════════════════════════════════════════════════
   UTILITY CLASSES
   ══════════════════════════════════════════════════════════════════ */

.footer-brand-text {
    font-size: 0.75rem;
}

.footer-brand-logo {
    height: 35px;
    opacity: 1;
}

.container-compact {
    max-width: 700px;
}

.container-report {
    max-width: 860px;
}

/* ══════════════════════════════════════════════════════════════════
   PAGE-SPECIFIC: Report Layout
   ══════════════════════════════════════════════════════════════════ */

.report-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════ */

@media (min-width: 992px) {
    .nav-drawer {
        right: 0 !important;
        box-shadow: none;
        border-left: 1px solid var(--border-color);
        z-index: 900;
    }

    .map-fab {
        display: none !important;
    }

    .overlay-backdrop {
        display: none !important;
    }

    body.has-fixed-sidebar {
        padding-right: 320px;
        transition: padding-right 0.3s;
    }

    .container {
        margin-left: auto;
        margin-right: auto;
    }

    /* Report page: drawer below navbar */
    .report-wrapper {
        margin-right: 0;
        width: 100%;
        min-height: calc(100vh - 76px);
    }

    .report-wrapper .container {
        margin-left: auto;
        margin-right: auto;
    }

    body.report-page .nav-drawer {
        top: var(--navbar-height, 56px) !important;
        height: calc(100vh - var(--navbar-height, 56px)) !important;
        z-index: 900 !important;
    }
}

@media (min-width: 1450px) {
    body.has-fixed-sidebar {
        padding-left: 320px;
    }
}