/**
 * Calendar Modal CSS - Stile Calendly
 * LC Service Di Cascone Lino
 * Versione: 1.13
 */

/* ============================================
   MODAL OVERLAY
   ============================================ */

.calendar-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow-y: auto;
    padding: 20px;
}

.calendar-modal-overlay.active {
    display: flex;
    opacity: 1;
}

/* ============================================
   MODAL CONTAINER
   ============================================ */

.calendar-modal {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.calendar-modal-overlay.active .calendar-modal {
    transform: scale(1);
}

/* ============================================
   HEADER
   ============================================ */

.calendar-modal-header {
    background: linear-gradient(135deg, #17608c 0%, #1a4d6d 100%);
    color: white;
    padding: 25px 30px;
    position: relative;
    border-radius: 16px 16px 0 0;
    display: flex;
    align-items: center;
    gap: 15px;
}

.calendar-back-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s;
    white-space: nowrap;
}

.calendar-back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateX(-2px);
}

.header-content {
    flex: 1;
}

.calendar-modal-header h2 {
    margin: 0 0 5px 0;
    font-size: 24px;
    font-weight: 700;
}

.calendar-modal-header p {
    margin: 0;
    font-size: 14px;
    opacity: 0.95;
}

.calendar-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.calendar-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* ============================================
   URGENZA SELECTOR
   ============================================ */

.urgenza-selector {
    padding: 20px 30px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.urgenza-selector h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.urgenza-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.urgenza-option {
    position: relative;
    cursor: pointer;
}

.urgenza-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.urgenza-option label {
    display: flex;
    flex-direction: column;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    background: white;
}

.urgenza-option label:hover {
    border-color: #17608c;
    box-shadow: 0 4px 12px rgba(23, 96, 140, 0.15);
}

.urgenza-option input[type="radio"]:checked + label {
    border-color: #17608c;
    background: #e5f1ff;
    box-shadow: 0 4px 12px rgba(23, 96, 140, 0.25);
}

.urgenza-option-title {
    font-weight: 600;
    font-size: 15px;
    color: #333;
    margin-bottom: 5px;
}

.urgenza-option-desc {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

.urgenza-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #dc3545;
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-top: 8px;
}

/* ============================================
   BODY CONTENT
   ============================================ */

.calendar-modal-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
}

/* ============================================
   STEP-BY-STEP LAYOUT (Calendly Style)
   ============================================ */

.calendar-step {
    display: block;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    animation: fadeInStep 0.3s ease;
}

.slots-step {
    display: none;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    animation: fadeInStep 0.3s ease;
}

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

/* ============================================
   LAYOUT 2 COLONNE (Calendario + Orari) - DEPRECATO
   ============================================ */

.calendar-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 30px;
    min-height: 400px;
}

/* ============================================
   CALENDARIO (Step 1)
   ============================================ */

.calendar-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
}

.calendar-step .calendar-section {
    background: transparent;
    padding: 0;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.calendar-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.calendar-nav {
    display: flex;
    gap: 10px;
}

.calendar-nav button {
    background: white;
    border: 2px solid #e0e0e0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    color: #17608c;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.calendar-nav button:hover {
    border-color: #17608c;
    background: #e5f1ff;
}

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

.calendar-day-header {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    padding: 10px 0;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    background: white;
    border: 2px solid transparent;
    font-weight: 500;
    min-height: 48px;
}

.calendar-day.disabled {
    color: #bdbdbd;
    cursor: not-allowed;
    background: #f5f5f5;
}

.calendar-day.available {
    color: #17608c;
    background: #e5f1ff;
}

.calendar-day.available:hover {
    background: #d0e7ff;
    border-color: #17608c;
    transform: translateY(-2px);
}

.calendar-day.selected {
    background: #17608c;
    color: white;
    border-color: #17608c;
    box-shadow: 0 4px 12px rgba(23, 96, 140, 0.3);
}

.calendar-day.today {
    border: 2px solid #ffc107;
}

.calendar-day.holiday {
    background: #ffe5e5;
    color: #dc3545;
}

.calendar-timezone {
    margin-top: 15px;
    font-size: 13px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ============================================
   ORARI (Colonna Destra)
   ============================================ */

.slots-section {
    display: flex;
    flex-direction: column;
}

.slots-header {
    margin-bottom: 20px;
}

.slots-header h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.slots-date-selected {
    font-size: 16px;
    color: #17608c;
    font-weight: 500;
}

.slots-info-message {
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 8px;
    padding: 12px 15px;
    margin-bottom: 15px;
    font-size: 14px;
    color: #856404;
    line-height: 1.5;
}

.slots-empty {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.slots-empty-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.slots-empty p {
    margin: 0;
    font-size: 16px;
}

.slots-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 10px;
}

/* Scrollbar personalizzata */
.slots-grid::-webkit-scrollbar {
    width: 8px;
}

.slots-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.slots-grid::-webkit-scrollbar-thumb {
    background: #17608c;
    border-radius: 4px;
}

/* Slot Row - Contenitore slot + pulsante Avanti (stile Calendly) */
.slot-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.slot-button {
    flex: 1;
    padding: 15px 10px;
    background: white;
    border: 2px solid #17608c;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    color: #17608c;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.slot-button:hover {
    background: #e5f1ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(23, 96, 140, 0.2);
}

/* Pulsante "Avanti" - nascosto di default */
.slot-next-button {
    display: none;
    padding: 15px 25px;
    background: #17608c;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.slot-next-button:hover {
    background: #1a4d6d;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(23, 96, 140, 0.4);
}

/* Quando slot selezionato: slot diventa grigio, pulsante Avanti appare */
.slot-row.selected .slot-button {
    background: #5a5a5a;
    border-color: #5a5a5a;
    color: white;
    box-shadow: 0 2px 8px rgba(90, 90, 90, 0.3);
}

.slot-row.selected .slot-next-button {
    display: block;
}

/* ============================================
   APPOINTMENT SUMMARY (quando slot selezionato)
   ============================================ */

.appointment-summary {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border: 2px solid #4caf50;
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
}

.appointment-summary h4 {
    margin: 0 0 15px 0;
    font-size: 16px;
    font-weight: 600;
    color: #2e7d32;
    display: flex;
    align-items: center;
    gap: 8px;
}

.appointment-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.appointment-detail {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #333;
}

.appointment-detail strong {
    color: #2e7d32;
}

/* ============================================
   FOOTER BUTTONS
   ============================================ */

.calendar-modal-footer {
    display: none; /* Nascosto - ora si usa il pulsante Avanti affiancato allo slot */
    padding: 20px 30px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    justify-content: space-between;
    align-items: center;
    border-radius: 0 0 16px 16px;
}

.calendar-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.calendar-btn-secondary {
    background: #6c757d;
    color: white;
}

.calendar-btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.calendar-btn-primary {
    background: linear-gradient(135deg, #17608c 0%, #1a4d6d 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(23, 96, 140, 0.3);
}

.calendar-btn-primary:hover {
    box-shadow: 0 6px 20px rgba(23, 96, 140, 0.4);
    transform: translateY(-2px);
}

.calendar-btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

/* ============================================
   LOADING STATE
   ============================================ */

.calendar-loading {
    text-align: center;
    padding: 40px 20px;
    color: #17608c;
}

.calendar-loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e5f1ff;
    border-top-color: #17608c;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

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

.calendar-loading p {
    margin: 0;
    font-size: 15px;
    font-weight: 500;
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */

@media (max-width: 768px) {
    .calendar-modal-overlay {
        padding: 0;
        align-items: flex-start;
    }

    .calendar-modal {
        border-radius: 0;
        max-height: 100vh;
        height: 100vh;
    }

    .calendar-modal-header {
        border-radius: 0;
        padding: 20px;
        gap: 10px;
    }

    .calendar-back-btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    .calendar-modal-header h2 {
        font-size: 20px;
    }

    .calendar-modal-body {
        padding: 20px;
        overflow-y: auto;
    }

    .calendar-step,
    .slots-step {
        max-width: 100%;
    }

    /* Calendario più grande su mobile */
    .calendar-grid {
        gap: 10px;
    }

    .calendar-day {
        min-height: 52px;
        font-size: 17px;
    }

    .calendar-day-header {
        padding: 12px 0;
        font-size: 14px;
    }

    .calendar-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .urgenza-options {
        grid-template-columns: 1fr;
    }

    /* Lista slot più lunga su mobile */
    .slots-grid {
        max-height: calc(100vh - 420px);
        min-height: 300px;
    }

    /* Box riepilogo compatto ma visibile */
    .appointment-summary {
        padding: 15px;
        margin-top: 15px;
    }

    .appointment-summary h4 {
        font-size: 15px;
        margin-bottom: 12px;
    }

    .appointment-detail {
        font-size: 13px;
        gap: 8px;
    }
}

/* ============================================
   ANIMAZIONI
   ============================================ */

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

.slots-grid .slot-row {
    animation: fadeIn 0.3s ease backwards;
}

.slots-grid .slot-row:nth-child(1) { animation-delay: 0.05s; }
.slots-grid .slot-row:nth-child(2) { animation-delay: 0.1s; }
.slots-grid .slot-row:nth-child(3) { animation-delay: 0.15s; }
.slots-grid .slot-row:nth-child(4) { animation-delay: 0.2s; }
.slots-grid .slot-row:nth-child(5) { animation-delay: 0.25s; }
