/* Belegungskalender Frontend Styles */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 1rem;
}

@media (min-width: 640px) { .calendar-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .calendar-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1280px) { .calendar-grid { grid-template-columns: repeat(4, 1fr); } }

.cal-month {
    background: white;
    border-radius: 14px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #e5e5ea;
}

.cal-month-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: #1d1d1f;
    margin-bottom: 0.5rem;
    text-align: center;
    letter-spacing: -0.01em;
}

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

.cal-weekday {
    text-align: center;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #86868b;
    padding: 2px 0;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.cal-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.cal-day {
    text-align: center;
    font-size: 0.8125rem;
    padding: 5px 0;
    border-radius: 5px;
    line-height: 1.4;
    min-height: 28px;
    background: #f0fdf4;
    color: #3c3c43;
    position: relative;
}

.cal-day--empty { visibility: hidden; }
.cal-day--today { box-shadow: inset 0 0 0 1.5px #0071e3; }

.cal-feiertag-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #dc2626;
    pointer-events: none;
}

.cal-nav-btn {
    padding: 6px 14px;
    background: #f5f5f7;
    border-radius: 9px;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid #e5e5ea;
    color: #1d1d1f;
    font-weight: 500;
    transition: background 0.15s;
}
.cal-nav-btn:hover:not(:disabled) { background: #ebebf0; }
.cal-nav-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    justify-content: center;
    margin-top: 1.5rem;
    font-size: 0.8125rem;
    color: #3c3c43;
}

.cal-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.cal-legend-swatch {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 5px;
}

/* Admin-mode click affordance on calendar days */
.cal-day--clickable { cursor: pointer; transition: transform 0.1s ease, filter 0.15s ease; }
.cal-day--clickable:hover { filter: brightness(0.95); transform: scale(1.05); }

/* Modal overlay
   V1.7: align-items: flex-start statt center — bei langem Formular auf kleinem
   Screen war sonst der obere Teil des Modals oberhalb des Viewports.
   overflow-y: auto direkt am Backdrop, damit der User innerhalb des Modal-
   Stacks scrollt, nicht die Seite dahinter. */
.cal-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 50;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 1rem;
    overflow-y: auto;
    overscroll-behavior: contain;
}
@media (min-width: 640px) {
    .cal-modal-backdrop {
        align-items: center;
        padding: 1rem;
    }
}

.cal-modal {
    background: white;
    border-radius: 18px;
    padding: 1.75rem;
    width: 100%;
    max-width: 460px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
    font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif;
}
/* V1.7: Auf Desktop max-height + interner Scroll (klassisch).
   Auf Mobile scrollt der Backdrop selbst — Modal darf wachsen. */
@media (min-width: 640px) {
    .cal-modal {
        max-height: 90vh;
        max-height: calc(100dvh - 2rem);
        overflow-y: auto;
    }
}

/* Mobile: weniger Padding, Modal füllt fast die ganze Breite */
@media (max-width: 480px) {
    .cal-modal-backdrop { padding: 0.5rem; }
    .cal-modal {
        padding: 1.25rem 1rem;
        border-radius: 14px;
        max-height: calc(100dvh - 1rem);
    }
    .cal-inquiry-section { padding: 12px 12px 14px; }
}

.cal-modal-close {
    background: transparent;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #86868b;
    cursor: pointer;
    padding: 0 6px;
}
.cal-modal-close:hover { color: #1d1d1f; }

.cal-booking-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #f2f2f7;
    gap: 12px;
}
.cal-booking-row:last-of-type { border-bottom: none; }

.cal-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #3c3c43;
    margin-bottom: 5px;
}

/* V1.7: Mobile-first — font-size:16px verhindert iOS Auto-Zoom beim Fokus,
   min-height:44px = Apple-Touch-Target-Empfehlung. */
.cal-input,
textarea.cal-input,
select.cal-input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid #d2d2d7;
    border-radius: 10px;
    font-size: 16px;
    line-height: 1.4;
    background: white;
    outline: none;
    transition: border-color 0.15s;
    box-sizing: border-box;
    min-height: 44px;
    font-family: inherit;
    color: #1d1d1f;
}
.cal-input:focus { border-color: #0071e3; box-shadow: 0 0 0 3px rgba(0,113,227,0.12); }

.cal-btn {
    padding: 11px 18px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    font-family: inherit;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}
.cal-btn-primary { background: #0071e3; color: white; }
.cal-btn-primary:hover { background: #0077ed; }
.cal-btn-secondary { background: #f5f5f7; color: #1d1d1f; }
.cal-btn-secondary:hover { background: #ebebf0; }
.cal-btn-danger { background: #fee2e2; color: #b91c1c; }
.cal-btn-danger:hover { background: #fecaca; }

/* Info cards: Arbeitsdienste / Umbau — only shown if entries in period */
.cal-info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 1.5rem;
}
@media (min-width: 640px) {
    .cal-info-grid { grid-template-columns: repeat(2, 1fr); }
}

.cal-info-card {
    background: white;
    border-radius: 14px;
    border: 1px solid #e5e5ea;
    padding: 1rem 1.125rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.cal-info-card--arbeitsdienst { border-top: 3px solid #60a5fa; }
.cal-info-card--umbau          { border-top: 3px solid #fbbf24; }

.cal-info-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.9375rem;
    color: #1d1d1f;
    margin-bottom: 0.625rem;
    letter-spacing: -0.01em;
}

.cal-info-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cal-info-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.cal-info-list li {
    padding: 6px 0;
    border-bottom: 1px solid #f5f5f7;
    font-size: 0.8125rem;
    color: #3c3c43;
    line-height: 1.45;
}
.cal-info-list li:last-child { border-bottom: none; }

.cal-info-date {
    font-weight: 500;
    color: #1d1d1f;
}

.cal-info-note {
    color: #86868b;
}

/* Date selection (visitor mode) */
.cal-day--selectable {
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.15s ease;
}
.cal-day--selectable:hover {
    transform: scale(1.08);
    box-shadow: 0 0 0 2px #234010;
    z-index: 2;
    position: relative;
}

/* V1.6.7 Phase-Mode: Tage außerhalb des Fensters ausgrauen, nicht klickbar */
.cal-day--out-of-window {
    opacity: 0.35;
    cursor: not-allowed;
    filter: grayscale(0.6);
}

.cal-day--selected {
    box-shadow: inset 0 0 0 2px #234010 !important;
    z-index: 1;
    position: relative;
}
.cal-day--sel-start {
    box-shadow: inset 0 0 0 2.5px #234010 !important;
    border-radius: 5px 2px 2px 5px;
    z-index: 2;
    position: relative;
}
.cal-day--sel-end {
    box-shadow: inset 0 0 0 2.5px #234010 !important;
    border-radius: 2px 5px 5px 2px;
    z-index: 2;
    position: relative;
}
.cal-day--sel-start.cal-day--sel-end {
    border-radius: 5px;
}

/* Selection indicator bar */
.cal-selection-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    background: #f0fdf4;
    border: 1.5px solid #86efac;
    border-radius: 12px;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.cal-selection-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #166534;
}
.cal-selection-info svg {
    flex-shrink: 0;
    color: #234010;
}
.cal-selection-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Hint text */
.cal-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    color: #86868b;
    margin-bottom: 1rem;
    padding: 8px;
}
.cal-hint svg {
    flex-shrink: 0;
}

/* Inquiry form modal extras */
.cal-inquiry-dates {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    margin-bottom: 18px;
}
.cal-inquiry-date-col {
    flex: 1;
}
.cal-inquiry-date-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #86868b;
    margin-bottom: 2px;
}
.cal-inquiry-date-value {
    font-size: 14px;
    font-weight: 600;
    color: #1d1d1f;
}
.cal-inquiry-date-arrow {
    color: #86868b;
    flex-shrink: 0;
}
.cal-inquiry-separator {
    height: 1px;
    background: #e5e5ea;
    margin: 4px 0;
}

/* V1.5.43: 3-Abschnitte-Layout im Buchungsanfrage-Formular */
.cal-inquiry-section {
    border: 1px solid #e5e5ea;
    border-radius: 12px;
    padding: 14px 14px 16px;
    background: #fff;
}
.cal-inquiry-section__title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 700;
    color: #1d1d1f;
    margin: -4px 0 14px;
    letter-spacing: -0.01em;
}
.cal-inquiry-section__num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #234010;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

/* V1.5.44: Wizard-Fortschrittsanzeige */
.cal-wizard-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0 16px;
    padding: 0 4px;
}
.cal-wizard-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.cal-wizard-step__circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e5e5ea;
    color: #86868b;
    font-size: 14px;
    font-weight: 700;
    transition: background 0.2s, color 0.2s;
}
.cal-wizard-step__label {
    font-size: 11px;
    font-weight: 600;
    color: #86868b;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    transition: color 0.2s;
}
.cal-wizard-step--active .cal-wizard-step__circle {
    background: #234010;
    color: #fff;
    box-shadow: 0 0 0 4px rgba(35, 64, 16, 0.15);
}
.cal-wizard-step--active .cal-wizard-step__label {
    color: #234010;
}
.cal-wizard-step--done .cal-wizard-step__circle {
    background: #16a34a;
    color: #fff;
}
.cal-wizard-step--done .cal-wizard-step__label {
    color: #15803d;
}
.cal-wizard-line {
    flex: 1;
    height: 2px;
    background: #e5e5ea;
    margin-bottom: 18px;
    transition: background 0.2s;
}
.cal-wizard-line--done {
    background: #16a34a;
}

@media (max-width: 480px) {
    .cal-wizard-step__label {
        font-size: 10px;
    }
    .cal-wizard-step__circle {
        width: 28px;
        height: 28px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .cal-selection-bar {
        flex-direction: column;
        align-items: flex-start;
    }
    .cal-inquiry-dates {
        flex-wrap: wrap;
        gap: 8px;
    }
    .cal-inquiry-date-arrow {
        display: none;
    }
}

/* V1.6.10: Assigned-Term-Markierung — der eigene Termin im Phase-Mode */
.cal-day--assigned {
    box-shadow: inset 0 0 0 2px #16a34a !important;
    position: relative;
    z-index: 1;
}
.cal-day--assigned-start {
    box-shadow: inset 0 0 0 2px #16a34a, inset 4px 0 0 #15803d !important;
}
.cal-day--assigned-end {
    box-shadow: inset 0 0 0 2px #16a34a, inset -4px 0 0 #15803d !important;
}
.cal-day--assigned::after {
    content: '';
    position: absolute;
    top: 1px; right: 1px;
    width: 6px; height: 6px;
    background: #16a34a;
    border-radius: 50%;
}

/* V1.6.11: „So buchst du" – kurze Anleitung unter dem Kalender. */
.cal-howto {
    margin: 24px 0 16px;
    padding: 18px 20px;
    background: linear-gradient(135deg, #f0fdf4, #ecfeff);
    border: 1px solid #bbf7d0;
    border-radius: 12px;
}
.cal-howto-title {
    font-size: 15px;
    font-weight: 600;
    color: #166534;
    margin-bottom: 6px;
}
.cal-howto-text {
    font-size: 14px;
    color: #1c1917;
    line-height: 1.55;
    margin: 0 0 12px 0;
}
.cal-howto-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.cal-howto-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s ease, transform 0.1s ease;
}
.cal-howto-btn--primary {
    background: #2d5016;
    color: #fff;
    border: 1px solid #2d5016;
}
.cal-howto-btn--primary:hover {
    background: #264c13;
    transform: translateY(-1px);
}
.cal-howto-btn--secondary {
    background: #fff;
    color: #2d5016;
    border: 1px solid #bbf7d0;
}
.cal-howto-btn--secondary:hover {
    background: #f0fdf4;
}
