/* ============================================================================
   NUOVA OTTICA.vision - Frontend Prenotazioni
   ============================================================================ */

* { box-sizing: border-box; }

:root {
    --primary: #f97316;
    --primary-dark: #ea580c;
    --primary-light: #fed7aa;
    --text: #1f2937;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --bg: #ffffff;
    --bg-alt: #f9fafb;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.05);
    --radius: 8px;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Oxygen, Ubuntu, sans-serif;
    color: var(--text);
    background: var(--bg-alt);
    line-height: 1.5;
    font-size: 15px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ====== TOPBAR ====== */
.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
}
.topbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}
.logo {
    font-weight: 700;
    font-size: 18px;
    color: var(--text);
}

/* Steps progress */
.steps {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: center;
    max-width: 500px;
}
.step {
    width: 32px; height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    background: #fff;
    font-weight: 600;
    color: var(--text-light);
    font-size: 14px;
}
.step.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.step.done {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.step-line {
    flex: 1;
    max-width: 60px;
    height: 2px;
    background: var(--border);
}

/* ====== MAIN ====== */
.main-content {
    padding: 30px 20px;
    min-height: calc(100vh - 200px);
}

/* ====== SERVICE LIST ====== */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
}
.page-head h1 {
    font-size: 32px;
    margin: 0;
}
.search input {
    padding: 12px 16px 12px 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" stroke="%23999" stroke-width="2" viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="M21 21l-4.35-4.35"/></svg>') no-repeat 12px center;
    width: 280px;
    font-size: 14px;
}

.services-list {
    list-style: none;
    padding: 0;
    margin: 0;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.service-row {
    display: flex;
    align-items: center;
    padding: 16px;
    gap: 20px;
    border-bottom: 1px solid var(--border);
}
.service-row:last-child { border-bottom: none; }

.service-img {
    width: 80px; height: 80px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-alt);
}
.service-img img {
    width: 100%; height: 100%;
    object-fit: cover;
}
.img-placeholder {
    width: 100%; height: 100%;
    opacity: 0.4;
}
.service-info {
    flex: 1;
    min-width: 0;
}
.service-info h2 {
    margin: 0 0 4px;
    font-size: 17px;
}
.service-desc {
    color: var(--text-light);
    margin: 0 0 6px;
    font-size: 14px;
}
.link-details {
    font-size: 13px;
    text-decoration: underline;
    color: var(--text);
}

/* ====== BUTTONS ====== */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: none;
    font-family: inherit;
}
.btn:hover { text-decoration: none; }
.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-dark);
}
.btn-outline {
    border-color: var(--primary);
    color: var(--primary);
    background: #fff;
}
.btn-outline:hover {
    background: var(--primary-light);
}
.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-block {
    display: block;
    width: 100%;
    margin-top: 12px;
}

/* ====== DETAIL PAGE ====== */
.breadcrumb {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 20px;
}
.breadcrumb a { color: var(--text-light); }
.breadcrumb span { color: var(--text); font-weight: 500; }

.detail-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 32px;
    margin-bottom: 32px;
}
.detail-image {
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 4/3;
}
.detail-image img {
    width: 100%; height: 100%;
    object-fit: cover;
}
.detail-info h1 {
    margin: 0 0 16px;
    font-size: 28px;
}
.detail-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.detail-card h3 {
    margin: 0 0 12px;
    font-size: 16px;
}
.next-slot {
    color: var(--success);
    margin: 0 0 16px;
    font-size: 14px;
}
.next-slot.warning { color: var(--warning); }
.detail-description {
    background: #fff;
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.detail-description h2 {
    margin: 0 0 12px;
    font-size: 18px;
}

/* ====== BOOKING FLOW ====== */
.step-section { display: none; }
.step-section.active { display: block; }
.step-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 32px;
    align-items: start;
}
.back-link {
    display: inline-block;
    margin-bottom: 16px;
    color: var(--text);
    font-size: 14px;
}
.step-main h1 {
    margin: 0 0 20px;
    font-size: 26px;
}
.recap {
    background: var(--bg-alt);
    border-radius: var(--radius);
    padding: 20px;
    position: sticky;
    top: 20px;
}
.recap h2 {
    margin: 0 0 16px;
    font-size: 18px;
}
.recap-service {
    background: #fff;
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    gap: 12px;
    align-items: center;
    box-shadow: var(--shadow);
}
.recap-service img {
    width: 48px; height: 48px;
    border-radius: 50%;
    object-fit: cover;
}
.recap-service div { flex: 1; min-width: 0; }
.recap-service strong { display: block; font-size: 15px; }
.recap-service small {
    display: block;
    color: var(--text-light);
    font-size: 13px;
    margin-top: 2px;
}

/* ====== CALENDAR ====== */
.datetime-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}
.datetime-card h3 {
    margin: 0 0 16px;
    font-size: 16px;
}
.datetime-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 32px;
}
.cal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-weight: 600;
    text-transform: capitalize;
}
.cal-header button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: var(--text);
    padding: 4px 8px;
}
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    text-align: center;
}
.cal-grid .day-header {
    font-size: 12px;
    color: var(--text-light);
    padding: 8px 0;
    font-weight: 600;
    text-transform: uppercase;
}
.cal-grid .day {
    padding: 10px 0;
    cursor: pointer;
    border-radius: 50%;
    font-size: 14px;
    aspect-ratio: 1/1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cal-grid .day:hover:not(.disabled):not(.empty) {
    background: var(--bg-alt);
}
.cal-grid .day.available {
    color: var(--text);
    font-weight: 500;
}
.cal-grid .day.disabled {
    color: var(--border);
    cursor: not-allowed;
}
.cal-grid .day.empty {
    cursor: default;
}
.cal-grid .day.selected {
    background: var(--primary);
    color: #fff;
}

.slots-wrap h4 {
    margin: 0 0 12px;
    font-size: 14px;
    color: var(--text-light);
}
.slots-list {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.slots-list .slot {
    padding: 10px 4px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
}
.slots-list .slot:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.slots-list .slot.selected {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.slots-list .hint {
    grid-column: 1 / -1;
    color: var(--text-light);
    text-align: center;
    margin: 0;
    padding: 20px;
}

/* ====== FORM ====== */
.card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}
.card h3 {
    margin: 0 0 16px;
    font-size: 16px;
}
.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.field {
    margin-bottom: 16px;
}
.field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 6px;
}
.field input,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 15px;
    font-family: inherit;
    background: #fff;
}
.field input:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249,115,22,0.1);
}
.field input.error,
.field textarea.error {
    border-color: var(--danger);
}

.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 14px;
    cursor: pointer;
}
.checkbox input { margin-top: 3px; flex-shrink: 0; }

.error-box {
    background: #fee;
    border-left: 4px solid var(--danger);
    color: #991b1b;
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: 4px;
    font-size: 14px;
}
.success-card {
    background: #ecfdf5;
    border-color: var(--success);
}
.error-card {
    background: #fef2f2;
    border-color: var(--danger);
    text-align: center;
    padding: 40px;
}

/* ====== CONFIRMATION ====== */
.confirm-content {
    text-align: center;
}
.check-circle {
    width: 80px; height: 80px;
    background: #d1fae5;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--success);
    font-size: 40px;
    margin-bottom: 20px;
}
.actions-row {
    display: flex;
    gap: 12px;
    margin: 20px 0;
    justify-content: center;
    flex-wrap: wrap;
}
.actions-row .btn { flex: 1; min-width: 200px; }

/* ====== MANAGE ====== */
.manage-booking { max-width: 600px; margin: 0 auto; }
.booking-details {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px 20px;
    margin: 0;
}
.booking-details dt { font-weight: 600; color: var(--text-light); }
.booking-details dd { margin: 0; }
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    background: var(--bg-alt);
}
.stato-confermata { background: #d1fae5; color: #065f46; }
.stato-in_attesa { background: #fef3c7; color: #92400e; }
.stato-cancellata { background: #fee2e2; color: #991b1b; }

/* ====== PRIVACY ====== */
.privacy-page {
    background: #fff;
    padding: 30px;
    border-radius: var(--radius);
    max-width: 800px;
    margin: 0 auto;
    box-shadow: var(--shadow);
}
.privacy-content {
    white-space: pre-wrap;
    line-height: 1.7;
}
.privacy-meta {
    margin-top: 30px;
    color: var(--text-light);
    font-size: 13px;
}

/* ====== ERROR PAGE ====== */
.error-page {
    text-align: center;
    padding: 60px 20px;
}
.error-page h1 {
    font-size: 80px;
    color: var(--primary);
    margin: 0;
}
.error-page h2 { margin: 0 0 12px; }

/* ====== FOOTER ====== */
.footer {
    background: #fff;
    padding: 24px 0;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
    margin-top: 40px;
}
.footer p { margin: 4px 0; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
    .step-grid,
    .detail-grid,
    .datetime-grid {
        grid-template-columns: 1fr;
    }
    .row {
        grid-template-columns: 1fr;
    }
    .slots-list {
        grid-template-columns: repeat(3, 1fr);
    }
    .page-head {
        flex-direction: column;
        align-items: stretch;
    }
    .search input { width: 100%; }
    .service-row {
        flex-wrap: wrap;
    }
    .step-line { max-width: 30px; }
    .recap { position: static; }
}
