/* ============================================
   Ristorante del Porto - Design System
   Colori dal DB via CSS variables override
   ============================================ */

/* --- CSS Variables (default, sovrascrivibili dal DB) --- */
:root {
    /* Brand Colors — #919985 base */
    --sage:          #919985;
    --sage-light:    #A8B49D;
    --sage-lighter:  #C5CEBC;
    --sage-dark:     #737F68;
    --sage-darker:   #5B6552;

    /* Neutrali caldi */
    --cream:         #F7F5F0;
    --cream-dark:    #EDE9E1;
    --warm-white:    #FDFCFA;
    --text-dark:     #2C3327;
    --text-medium:   #5A6354;
    --text-light:    #8A9484;
    --border-light:  #E2DFD8;

    /* Accento */
    --accent:        #C4956A;
    --accent-light:  #D4B08E;
    --accent-dark:   #A67B52;

    /* Stato */
    --success:       #5E8B5A;
    --error:         #C0564F;
    --error-light:   #F9EDEC;

    /* Font */
    --font-display:  'Playfair Display', Georgia, 'Times New Roman', serif;
    --font-body:     'Tenor Sans', 'Helvetica Neue', Arial, sans-serif;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Shadows */
    --shadow-sm:  0 1px 3px rgba(44, 51, 39, 0.06);
    --shadow-md:  0 4px 12px rgba(44, 51, 39, 0.08);
    --shadow-lg:  0 8px 30px rgba(44, 51, 39, 0.12);
    --shadow-xl:  0 16px 50px rgba(44, 51, 39, 0.15);

    /* Transition */
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-dark);
    background: var(--cream);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* --- Typography --- */
h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 400;
    line-height: 1.3;
    margin: 0;
}

.step-title {
    font-size: 1.5rem;
    color: var(--sage-dark);
    text-align: center;
    margin-bottom: var(--space-xl);
    letter-spacing: -0.01em;
}

.step-subtitle {
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
    margin-top: calc(var(--space-md) * -1);
    margin-bottom: var(--space-xl);
}

/* --- Header --- */
.app-header {
    background: var(--sage);
    padding: var(--space-lg) 0;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.header-inner {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

.header-logo {
    height: 56px;
    width: auto;
    filter: brightness(1.05);
}

/* --- Main --- */
.app-main {
    flex: 1;
    padding: var(--space-xl) 0 var(--space-2xl);
}

.app-main .container {
    max-width: 520px;
    padding: 0 var(--space-md);
}

/* --- Steps Indicator (5 step) --- */
.steps-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: var(--space-2xl);
    padding: 0 var(--space-xs);
}

.step-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    position: relative;
    cursor: default;
}

.step-dot.completed {
    cursor: pointer;
}

.step-dot.completed:hover .step-number {
    background: var(--sage);
    color: #fff;
    box-shadow: 0 2px 8px rgba(145, 153, 133, 0.4);
    transform: scale(1.1);
}

.step-number {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-body);
    font-size: 0.75rem;
    background: var(--cream-dark);
    color: var(--text-light);
    transition: all var(--transition);
}

.step-label {
    font-size: 0.6rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: color var(--transition);
    white-space: nowrap;
}

.step-dot.active .step-number {
    background: var(--sage);
    color: #fff;
    box-shadow: 0 2px 8px rgba(145, 153, 133, 0.4);
}

.step-dot.active .step-label {
    color: var(--sage-dark);
}

.step-dot.completed .step-number {
    background: var(--sage-light);
    color: #fff;
}

.step-dot.completed .step-label {
    color: var(--sage-light);
}

.step-line {
    flex: 1;
    height: 2px;
    background: var(--cream-dark);
    margin: 0 4px;
    margin-bottom: 18px;
    transition: background var(--transition);
}

.step-line.active {
    background: var(--sage-light);
}

/* --- Booking Step Sections --- */
.booking-step {
    animation: fadeSlideUp 0.4s ease-out;
}

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

/* =============================================
   STEP 1 — Tiles selezione persone (1-8)
   ============================================= */
.pax-tiles {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.pax-tile {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--warm-white);
    cursor: pointer;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
    padding: var(--space-sm);
}

.pax-tile:hover {
    border-color: var(--sage);
    background: rgba(145, 153, 133, 0.06);
}

.pax-tile:active {
    transform: scale(0.95);
}

.pax-tile.selected {
    background: var(--sage);
    border-color: var(--sage);
    color: #fff;
    box-shadow: 0 2px 10px rgba(145, 153, 133, 0.35);
}

.pax-tile .pax-number {
    font-family: var(--font-display);
    font-size: 1.5rem;
    line-height: 1;
}

.pax-tile .pax-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.7;
}

.pax-tile.selected .pax-label {
    opacity: 0.9;
}

/* =============================================
   STEP 2 — Pranzo / Cena selector
   ============================================= */
.servizio-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.servizio-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-xl) var(--space-md);
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-lg);
    background: var(--warm-white);
    cursor: pointer;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
    text-align: center;
}

.servizio-card:hover {
    border-color: var(--sage);
    background: rgba(145, 153, 133, 0.05);
    box-shadow: var(--shadow-sm);
}

.servizio-card:active {
    transform: scale(0.97);
}

.servizio-card.selected {
    background: var(--sage);
    border-color: var(--sage);
    color: #fff;
    box-shadow: 0 4px 16px rgba(145, 153, 133, 0.35);
}

.servizio-card .servizio-icon {
    font-size: 2.2rem;
    line-height: 1;
}

.servizio-card .servizio-nome {
    font-family: var(--font-display);
    font-size: 1.2rem;
}

.servizio-card .servizio-orario {
    font-size: 0.8rem;
    opacity: 0.65;
}

.servizio-card.selected .servizio-orario {
    opacity: 0.85;
}

/* =============================================
   STEP 3 — Calendario
   ============================================= */
.calendario-wrapper {
    background: var(--warm-white);
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.calendario-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}

.calendario-mese {
    font-family: var(--font-display);
    font-size: 1.125rem;
    color: var(--sage-dark);
    text-transform: capitalize;
}

.btn-nav-mese {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--sage);
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.btn-nav-mese:hover {
    background: var(--sage);
    color: #fff;
}

.btn-nav-mese:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}

.calendario-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: var(--space-sm);
}

.calendario-weekdays span {
    text-align: center;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-light);
    padding: var(--space-xs) 0;
}

.calendario-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.cal-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    background: transparent;
    color: var(--text-dark);
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.cal-day:hover:not(.disabled):not(.empty) {
    background: var(--sage-lighter);
    color: var(--sage-darker);
}

.cal-day.today { font-weight: 600; }

.cal-day.today::after {
    content: '';
    position: absolute;
    bottom: 4px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--sage);
}

.cal-day.selected {
    background: var(--sage);
    color: #fff;
    box-shadow: 0 2px 8px rgba(145, 153, 133, 0.35);
}

.cal-day.selected::after { background: #fff; }

.cal-day.disabled {
    color: var(--border-light);
    cursor: not-allowed;
}

.cal-day.empty { cursor: default; }

/* =============================================
   STEP 4 — Orari Grid
   ============================================= */
.orari-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.orario-btn {
    padding: var(--space-md) var(--space-sm);
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--warm-white);
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--text-dark);
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}

.orario-btn:hover {
    border-color: var(--sage);
    background: rgba(145, 153, 133, 0.06);
}

.orario-btn.selected {
    background: var(--sage);
    border-color: var(--sage);
    color: #fff;
    box-shadow: 0 2px 8px rgba(145, 153, 133, 0.3);
}

.orario-btn .disponibili {
    display: block;
    font-size: 0.7rem;
    color: var(--text-light);
    margin-top: 2px;
}

.orario-btn.selected .disponibili {
    color: rgba(255, 255, 255, 0.75);
}

.orari-loading {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-light);
}

.orari-vuoti {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-light);
    font-size: 0.9rem;
}

.field-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-medium);
    margin-bottom: var(--space-sm);
    letter-spacing: 0.02em;
}

.field-label i {
    color: var(--sage);
    margin-right: 4px;
}

/* --- Buttons --- */
.btn-primary-dp {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-md) var(--space-xl);
    border: none;
    border-radius: var(--radius-md);
    background: var(--sage);
    color: #fff;
    font-family: var(--font-body);
    font-size: 1rem;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.btn-primary-dp:hover {
    background: var(--sage-dark);
    box-shadow: var(--shadow-md);
}

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

.btn-primary-dp:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-primary-dp.btn-conferma {
    background: var(--sage-dark);
    padding: var(--space-lg) var(--space-xl);
    font-size: 1.05rem;
}

.btn-primary-dp.btn-conferma:hover { background: var(--sage-darker); }

.btn-secondary-dp {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-xl);
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-medium);
    font-family: var(--font-body);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.btn-secondary-dp:hover {
    border-color: var(--sage);
    color: var(--sage-dark);
}

.step-buttons {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

.step-buttons .btn-secondary-dp { flex: 0 0 auto; }
.step-buttons .btn-primary-dp { flex: 1; }

/* =============================================
   STEP 5 — Form Inputs (Floating Label)
   ============================================= */
.form-floating-dp {
    position: relative;
    margin-bottom: var(--space-lg);
}

.form-input-dp {
    width: 100%;
    padding: 24px var(--space-md) 8px;
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--warm-white);
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--text-dark);
    transition: all var(--transition);
    outline: none;
    appearance: none;
}

.form-textarea {
    min-height: 90px;
    resize: vertical;
}

.form-input-dp:focus {
    border-color: var(--sage);
    box-shadow: 0 0 0 3px rgba(145, 153, 133, 0.15);
}

.form-input-dp.error {
    border-color: var(--error);
    box-shadow: 0 0 0 3px rgba(192, 86, 79, 0.1);
}

.form-floating-dp label {
    position: absolute;
    top: 50%;
    left: var(--space-md);
    transform: translateY(-50%);
    font-size: 0.95rem;
    color: var(--text-light);
    pointer-events: none;
    transition: all var(--transition);
    transform-origin: left top;
}

.form-textarea ~ label { top: 24px; }

.form-input-dp:focus ~ label,
.form-input-dp:not(:placeholder-shown) ~ label {
    top: 12px;
    transform: translateY(0) scale(0.78);
    color: var(--sage);
}

.input-error {
    font-size: 0.8rem;
    color: var(--error);
    margin-top: 4px;
    min-height: 0;
    opacity: 0;
    transition: all var(--transition);
}

.input-error.visible {
    opacity: 1;
    min-height: 20px;
}

.form-hint {
    display: block;
    font-size: 0.78rem;
    color: var(--text-light);
    margin-top: 4px;
}

/* --- Disclaimer CC (Step 1) --- */
.disclaimer-cc {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: var(--space-lg);
    padding: var(--space-sm) var(--space-md);
    line-height: 1.5;
    opacity: 0.75;
}

.disclaimer-cc i {
    color: var(--text-light);
    margin-right: 4px;
    font-size: 0.7rem;
}

/* --- Credit Card Section (Step 5) --- */
.cc-section {
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-light);
}

.cc-section-title {
    font-family: var(--font-display);
    font-size: 1.05rem;
    color: var(--sage-dark);
    margin-bottom: var(--space-xs);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.cc-section-title i {
    font-size: 0.9rem;
    color: var(--sage);
}

.cc-section-hint {
    font-size: 0.78rem;
    color: var(--text-light);
    margin-bottom: var(--space-lg);
}

.cc-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.cc-field-exp,
.cc-field-cvv {
    margin-bottom: var(--space-lg);
}

/* --- Riepilogo Card --- */
.riepilogo-card {
    background: var(--warm-white);
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.riepilogo-row {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-sm) 0;
}

.riepilogo-row + .riepilogo-row {
    border-top: 1px solid var(--cream-dark);
}

.riepilogo-row > i {
    color: var(--sage);
    font-size: 1rem;
    margin-top: 3px;
    width: 20px;
    text-align: center;
}

.riepilogo-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.riepilogo-value {
    display: block;
    font-size: 0.95rem;
    color: var(--text-dark);
}

/* --- Success --- */
.success-container {
    text-align: center;
    padding: var(--space-xl) 0;
}

.success-icon {
    font-size: 3.5rem;
    color: var(--success);
    margin-bottom: var(--space-lg);
    animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
    from { transform: scale(0); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

.success-text {
    color: var(--text-medium);
    margin-bottom: var(--space-sm);
}

.codice-prenotazione {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--sage-dark);
    letter-spacing: 0.05em;
    margin-bottom: var(--space-md);
}

.success-sub {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: var(--space-xl);
}

.riepilogo-mini {
    text-align: left;
    margin-bottom: var(--space-xl);
}

/* --- Toast --- */
.toast-container {
    position: fixed;
    bottom: var(--space-lg);
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: calc(100% - 2rem);
    max-width: 480px;
}

.toast {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    animation: toastSlide 0.35s ease-out;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

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

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

/* --- Footer --- */
.app-footer {
    background: var(--sage-dark);
    color: rgba(255, 255, 255, 0.8);
    padding: var(--space-xl) 0;
    text-align: center;
}

.footer-nome {
    font-family: var(--font-display);
    font-size: 1.125rem;
    color: #fff;
    margin: 0 0 var(--space-xs);
}

.footer-indirizzo {
    font-size: 0.85rem;
    margin: 0 0 var(--space-md);
}

.footer-contatti {
    display: flex;
    justify-content: center;
    gap: var(--space-lg);
    flex-wrap: wrap;
}

.footer-contatti a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color var(--transition);
}

.footer-contatti a:hover { color: #fff; }

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

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

/* --- Desktop --- */
@media (min-width: 768px) {
    .app-header { padding: var(--space-xl) 0; }
    .header-logo { height: 72px; }
    .app-main { padding: var(--space-2xl) 0 4rem; }
    .step-title { font-size: 1.75rem; }
    .orari-grid { grid-template-columns: repeat(4, 1fr); }
    .calendario-wrapper { padding: var(--space-xl); }
    .cal-day { font-size: 0.95rem; }
    .pax-tiles { gap: var(--space-md); }
    .pax-tile .pax-number { font-size: 1.75rem; }
    .step-number { width: 34px; height: 34px; font-size: 0.8rem; }
    .step-label { font-size: 0.65rem; }
    .step-line { margin: 0 6px; }
}

/* --- Accessibility --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

:focus-visible {
    outline: 2px solid var(--sage);
    outline-offset: 2px;
}

@media print {
    .app-header, .app-footer, .steps-indicator, .step-buttons { display: none; }
}
