/* Calendar Container */
.calendar-wrapper {
    max-width: 100%;
    margin: 20px 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.calendar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
}

.calendar-controls button {
    background: white;
    border: 1px solid #ddd;
    padding: 12px 20px;
    /* Larger touch target */
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--primary-blue, #0d6efd);
    position: relative;
    /* For z-index to work */
    z-index: 10;
    touch-action: manipulation;
    /* Improves touch response */
}

.calendar-controls button:hover {
    background: var(--primary-blue, #0d6efd);
    color: white;
    border-color: var(--primary-blue, #0d6efd);
}

.current-month-label {
    font-weight: bold;
    font-size: 1.1em;
    color: var(--dark, #333);
}

/* Calendar Grid */
.calendar-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

/* Tablet: 2 Columns */
@media (min-width: 768px) {
    .calendar-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop: 3 Columns (as requested) */
@media (min-width: 1200px) {
    .calendar-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.month-container {
    background: white;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.month-name {
    text-align: center;
    font-weight: bold;
    margin-bottom: 10px;
    color: var(--primary-blue, #0d6efd);
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 10px;
}

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

.day-name {
    font-size: 0.85em;
    color: #888;
    padding: 5px 0;
    font-weight: 500;
}

.day-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
    border-radius: 4px;
    cursor: default;
    position: relative;
}

/* Status Colors */
.day-cell.available {
    background-color: #d1e7dd;
    color: #0f5132;
    border: 1px solid #badbcc;
}

/* Booked (Full Day) */
.day-cell.booked {
    background-color: #f8d7da;
    color: #842029;
    border: 1px solid #f5c2c7;
    opacity: 0.8;
}

/* Arrival: Morning Free (White), Afternoon Booked (Red) */
/* Gradient to bottom right: White top-left, Red bottom-right */
.day-cell.arrival {
    background: linear-gradient(to bottom right, white 50%, #f8d7da 50%);
    color: #0f5132;
    /* Use available text color as half is free, or neutral */
    border: 1px solid #badbcc;
    /* Green border usually implies available, maybe neutral? */
    border-color: #ddd;
    /* Neutral border */
}

/* Departure: Morning Booked (Red), Afternoon Free (White) */
/* Gradient to bottom right: Red top-left, White bottom-right */
.day-cell.departure {
    background: linear-gradient(to bottom right, #f8d7da 50%, white 50%);
    color: #842029;
    border: 1px solid #ddd;
}

/* Changeover: Departure + Arrival (Morning Red, Afternoon Red -> Full Red) */
/* Or visually distinct if requested, but logically it's full. 
   To meet specific request "sehen ... an- und abreise", maybe a slight visible split line? */
.day-cell.changeover {
    background: linear-gradient(to bottom right, #f8d7da 48%, white 48%, white 52%, #f8d7da 52%);
    color: #842029;
    border: 1px solid #f5c2c7;
}

.day-cell.empty {
    background: transparent;
}

.day-cell.today {
    font-weight: bold;
    border: 2px solid var(--primary-blue, #0d6efd);
    z-index: 2;
    /* Ensure border is on top */
}

/* Legend */
.calendar-legend {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 20px;
    font-size: 0.9em;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.legend-color.available {
    background-color: #d1e7dd;
    border: 1px solid #badbcc;
}

.legend-color.booked {
    background-color: #f8d7da;
    border: 1px solid #f5c2c7;
}

.legend-color.arrival {
    background: linear-gradient(to bottom right, white 50%, #f8d7da 50%);
    border: 1px solid #ddd;
}

.legend-color.departure {
    background: linear-gradient(to bottom right, #f8d7da 50%, white 50%);
    border: 1px solid #ddd;
}

/* Loading State */
.calendar-loading {
    text-align: center;
    padding: 40px;
    color: #666;
    font-style: italic;
}

.calendar-error {
    text-align: center;
    padding: 20px;
    color: #dc3545;
    background: #fff8f8;
    border-radius: 8px;
    border: 1px solid #f5c2c7;
}

/* Tooltip for dates (optional) */
.day-cell:hover::after {
    content: attr(data-status);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75em;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.day-cell:hover::after {
    opacity: 1;
}