/* ========== Frontend Styles — Scelta Laboratori ========== */
/* Design System: Modern, Playful, Accessible */

:root {
    --primary-color: #6c5ce7;
    --accent-color: #a29bfe;
    --success-color: #2ECC71;
    --warning-color: #F39C12;
    --danger-color: #E74C3C;
    --light-bg: #F5F7FA;
    --dark-text: #2C3E50;
    --border-color: #E0E0E0;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.15);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Page Layout */
body {
    background-color: #fff;
    background-image: linear-gradient(135deg, #F5F7FA 0%, #E8F1F8 100%);
    background-attachment: fixed;
}

.page-title {
    font-family: Montserrat, sans-serif;
    font-weight: 900;
    font-size: 2.5rem;
    letter-spacing: -0.02em;
    color: var(--dark-text);
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-subtitle {
    font-family: 'Poppins', Montserrat, sans-serif;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--dark-text);
    opacity: 0.8;
    margin-bottom: 1.5rem;
}

/* Step Indicator (Redesigned) */
.step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #fff;
    border-radius: 20px;
    border: 2px solid var(--light-bg);
    box-shadow: var(--shadow-md);
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.step-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--dark-text);
    font-family: 'Poppins', Montserrat, sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition);
}

.step-dot .step-num {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--light-bg);
    border: 3px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--dark-text);
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.step-dot.active .step-num {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border-color: var(--primary-color);
    color: #fff;
    box-shadow: 0 0 0 6px rgba(255, 107, 107, 0.15);
    transform: scale(1.1);
}

.step-dot.completed .step-num {
    background: var(--success-color);
    border-color: var(--success-color);
    color: #fff;
    box-shadow: var(--shadow-md);
}

.step-dot.completed .step-num::before {
    content: "✓";
}

.step-dot.completed .step-name {
    color: var(--success-color);
}

.step-dot .step-name {
    text-align: center;
    max-width: 70px;
    line-height: 1.2;
    transition: var(--transition);
}

.step-connector {
    flex: 1;
    height: 3px;
    background: linear-gradient(90deg, var(--border-color), transparent);
    min-width: 20px;
    max-width: 60px;
    margin: 0 0.5rem;
}

/* Categoria Step (Redesigned) */
.categoria-step {
    display: none;
    animation: stepFadeIn 0.4s ease;
}

.categoria-step.active {
    display: block;
}

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

.categoria-header {
    font-family: Montserrat, sans-serif;
    font-weight: 800;
    color: var(--dark-text);
    text-align: center;
    font-size: 1.8rem;
    margin-bottom: 1rem;
    letter-spacing: -0.01em;
}

.categoria-descrizione,
.categoria-info {
    text-align: center;
    color: var(--dark-text);
    font-family: 'Poppins', Montserrat, sans-serif;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    opacity: 0.85;
    line-height: 1.6;
}

.categoria-info strong {
    color: var(--primary-color);
    font-weight: 700;
}

.laboratorio.busy {
    pointer-events: none;
    opacity: 0.7;
}

/* Selection Counter (Redesigned) */
.selection-counter {
    text-align: center;
    padding: 1rem 2rem;
    margin-bottom: 2rem;
    background: #fff;
    border-radius: 16px;
    display: inline-block;
    width: auto;
    margin-left: auto;
    margin-right: auto;
    font-family: 'Poppins', Montserrat, sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--dark-text);
    border: 2px solid var(--light-bg);
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.selection-counter.complete {
    background: linear-gradient(135deg, rgba(46, 204, 113, 0.1), rgba(78, 205, 196, 0.1));
    border-color: var(--success-color);
}

.selection-counter.complete::after {
    content: " ✨";
}

/* ============ Lab Card (Completely Redesigned) ============ */
.projects {
    justify-content: center;
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.item {
    flex: 0 1 calc(50% - 0.75rem);
    display: flex;
}

@media (max-width: 768px) {
    .item {
        flex: 0 1 calc(100% - 0.75rem);
    }
}

.laboratorio {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    border: 3px solid var(--light-bg);
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-md);
}

.laboratorio:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-color);
}

.laboratorio.selected {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.05), rgba(78, 205, 196, 0.05));
    box-shadow: var(--shadow-lg);
}

.laboratorio.selected::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.08), transparent);
    pointer-events: none;
}

.laboratorio.choosen {
    opacity: 0.6;
    cursor: default;
    filter: grayscale(0.3);
}

.laboratorio.completo {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(0.6);
    background: linear-gradient(135deg, #f0f0f0, #e8e8e8);
}

/* Preference Badge (Redesigned) */
.lab-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: #fff;
    font-family: Montserrat, sans-serif;
    font-weight: 900;
    font-size: 1.1rem;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
    box-shadow: 0 4px 16px rgba(255, 107, 107, 0.4);
    animation: badgePop 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.laboratorio.selected .lab-badge {
    display: flex;
}

@keyframes badgePop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.3);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Image area */
.lab-image-wrap {
    padding: 0;
    overflow: hidden;
    width: 100%;
    height: 200px;
}

.lab-image-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.laboratorio:hover .lab-image-wrap img {
    transform: scale(1.05);
}

/* Text area */
.lab-info {
    padding: 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.lab-info .name {
    font-family: Montserrat, sans-serif;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--dark-text);
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.lab-info .description {
    font-family: 'Poppins', Montserrat, sans-serif;
    font-size: 0.9rem;
    color: #666;
    line-height: 1.5;
    flex: 1;
    margin-bottom: 0;
}

/* Esaurito label */
.esaurito-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, var(--danger-color), #C0392B);
    color: #fff;
    padding: 0.75rem 2rem;
    border-radius: 12px;
    font-family: Montserrat, sans-serif;
    font-weight: 900;
    font-size: 1.1rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    z-index: 5;
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

.choosenMessage {
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.1), rgba(78, 205, 196, 0.1));
    color: var(--primary-color);
    text-align: center;
    padding: 0.75rem;
    font-family: 'Poppins', Montserrat, sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
}

/* ============ Sticky Bottom Bar ============ */
.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 1rem;
    z-index: 40;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -8px 32px rgba(0,0,0,0.08);
}

.btn-conferma {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 0.85rem 2.5rem;
    font-family: Montserrat, sans-serif;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.03em;
    transition: var(--transition);
    box-shadow: 0 4px 16px rgba(255, 107, 107, 0.3);
    cursor: pointer;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
}

.btn-conferma::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.2);
    transition: left 0.3s ease;
}

.btn-conferma:hover::before {
    left: 100%;
}

.btn-conferma:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(255, 107, 107, 0.4);
}

.btn-conferma:active {
    transform: translateY(-1px);
    box-shadow: 0 2px 12px rgba(255, 107, 107, 0.3);
}

.btn-conferma:disabled,
.btn-conferma.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.btn-conferma:disabled:hover,
.btn-conferma.disabled:hover {
    transform: none;
    box-shadow: 0 4px 16px rgba(255, 107, 107, 0.3);
}

.btn-indietro {
    background: transparent;
    color: var(--dark-text);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 0.75rem 2rem;
    font-family: Montserrat, sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.03em;
    transition: var(--transition);
    cursor: pointer;
    text-transform: uppercase;
}

.btn-indietro:hover {
    background: var(--light-bg);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
}

.btn-indietro:active {
    transform: translateY(0);
}

/* Code Input (Redesigned) */
.codice-input {
    max-width: 500px;
    margin: 0 auto 2rem auto;
    border-radius: 12px;
    padding: 1rem 1.5rem;
    font-family: 'Courier New', monospace;
    font-size: 1.05rem;
    text-align: center;
    letter-spacing: 0.15em;
    border: 2px solid var(--border-color);
    background: #fff;
    color: var(--dark-text);
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.codice-input::placeholder {
    color: rgba(44, 62, 80, 0.4);
}

.codice-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.15);
    background: #fff;
    color: var(--dark-text);
    outline: none;
}

.codice-input.error {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.15);
}

/* Done Recap (Redesigned) */
.done-recap {
    background: linear-gradient(135deg, rgba(46, 204, 113, 0.08), rgba(78, 205, 196, 0.08));
    border-radius: 20px;
    padding: 2.5rem;
    font-family: 'Poppins', Montserrat, sans-serif;
    color: var(--dark-text);
    border: 2px solid var(--success-color);
    box-shadow: var(--shadow-md);
    max-width: 600px;
    margin: 2rem auto;
}

.done-recap::before {
    content: "✨ ";
    font-size: 1.8rem;
}

.done-recap h3 {
    font-weight: 800;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: var(--success-color);
    margin-top: 0;
}

.done-list {
    padding-left: 1.5rem;
    font-size: 1.05rem;
    line-height: 1.8;
}

.done-list li {
    margin-bottom: 0.75rem;
    color: var(--dark-text);
}

.done-recap small {
    color: #999;
    display: block;
    margin-top: 1.5rem;
    font-size: 0.9rem;
}

.done-recap a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.done-recap a:hover {
    color: var(--accent-color);
}

/* ============ Toast Notifications ============ */
.toast-container {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: 12px;
    font-family: 'Poppins', Montserrat, sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    animation: toastSlideIn 0.3s ease forwards;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 280px;
    max-width: 400px;
}

.toast.success {
    background: var(--success-color);
    color: #fff;
}

.toast.error {
    background: var(--danger-color);
    color: #fff;
}

.toast.warning {
    background: var(--warning-color);
    color: #fff;
}

.toast.info {
    background: var(--accent-color);
    color: #fff;
}

.toast::before {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.toast.success::before {
    content: "✓";
}

.toast.error::before {
    content: "✕";
}

.toast.warning::before {
    content: "⚠";
}

.toast.info::before {
    content: "ℹ";
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.toast.remove {
    animation: toastSlideOut 0.3s ease forwards;
}

@keyframes toastSlideOut {
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(30px);
    }
}

/* ============ Loading Spinner ============ */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============ Responsive Design ============ */
@media (max-width: 768px) {
    .page-title {
        font-size: 1.8rem;
    }

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

    .step-indicator {
        gap: 0.25rem;
        padding: 1rem;
        margin-bottom: 1.5rem;
    }

    .step-dot {
        gap: 0.25rem;
        font-size: 0.75rem;
    }

    .step-dot .step-num {
        width: 40px;
        height: 40px;
        font-size: 0.95rem;
    }

    .step-dot.active .step-num {
        box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.15);
    }

    .step-dot .step-name {
        display: none;
    }

    .step-connector {
        max-width: 40px;
        min-width: 15px;
    }

    .item {
        flex: 0 1 100%;
    }

    .selection-counter {
        font-size: 0.9rem;
        padding: 0.85rem 1.5rem;
        margin-bottom: 1.5rem;
    }

    .categoria-header {
        font-size: 1.4rem;
        margin-bottom: 0.75rem;
    }

    .categoria-descrizione,
    .categoria-info {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
    }

    .lab-info {
        padding: 1rem;
    }

    .lab-info .name {
        font-size: 1rem;
    }

    .lab-info .description {
        font-size: 0.85rem;
    }

    .lab-badge {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .bottom-bar {
        padding: 0.75rem;
    }

    .btn-conferma {
        padding: 0.75rem 2rem;
        font-size: 1rem;
    }

    .btn-indietro {
        padding: 0.65rem 1.5rem;
        font-size: 0.9rem;
    }

    .codice-input {
        font-size: 1rem;
        padding: 0.9rem 1.25rem;
        margin-bottom: 1.5rem;
    }

    .done-recap {
        padding: 1.5rem;
        margin: 1rem auto;
    }

    .done-recap h3 {
        font-size: 1.25rem;
    }

    .done-list {
        font-size: 0.95rem;
    }

    .toast-container {
        bottom: 80px;
    }

    .toast {
        min-width: 260px;
        max-width: 90vw;
    }
}

@media (max-width: 480px) {
    .page-title {
        font-size: 1.5rem;
    }

    .page-subtitle {
        font-size: 0.95rem;
    }

    .step-indicator {
        padding: 0.75rem;
        margin-bottom: 1rem;
    }

    .step-dot {
        gap: 0.15rem;
    }

    .step-dot .step-num {
        width: 36px;
        height: 36px;
        font-size: 0.85rem;
    }

    .selection-counter {
        font-size: 0.85rem;
        padding: 0.75rem 1.25rem;
    }

    .categoria-header {
        font-size: 1.2rem;
    }

    .categoria-descrizione,
    .categoria-info {
        font-size: 0.85rem;
    }

    .lab-image-wrap {
        height: 160px;
    }

    .lab-info {
        padding: 0.9rem;
    }

    .lab-info .name {
        font-size: 0.95rem;
        margin-bottom: 0.35rem;
    }

    .lab-info .description {
        font-size: 0.8rem;
    }

    .bottom-bar {
        padding: 0.6rem;
    }

    .btn-conferma,
    .btn-indietro {
        width: 100%;
    }

    .codice-input {
        max-width: 90vw;
        font-size: 0.95rem;
        padding: 0.85rem 1rem;
    }

    .done-recap {
        padding: 1.25rem;
        margin: 0.75rem;
    }

    .done-recap h3 {
        font-size: 1.1rem;
    }

    .done-list {
        font-size: 0.9rem;
        padding-left: 1.25rem;
    }

    .toast {
        min-width: 240px;
    }
}
