/**
 * Terminbuchung Widget - Nested CSS
 */

:root {
    --primary: #0078d4;
    --primary-hover: #106ebe;
    --success: #4caf50;
    --danger: #f44336;
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-400: #bdbdbd;
    --gray-600: #757575;
    --gray-800: #424242;
    --gray-900: #212121;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.terminbuchung {
    font-family: system-ui, -apple-system, sans-serif;
    color: var(--gray-900);
    line-height: 1.5;

    * {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
    }

    button {
        font-family: inherit;
        cursor: pointer;
        border: none;
        background: none;
    }

    input, textarea {
        font-family: inherit;
        font-size: 14px;
    }
}

/* Popup Overlay */
.terminbuchung-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;

    .terminbuchung-modal {
        background: white;
        border-radius: 12px;
        max-width: 900px;
        width: 100%;
        max-height: 90vh;
        overflow: auto;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    }
}

/* Widget Container */
.terminbuchung-widget {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);

    .widget-header {
        padding: 20px;
        border-bottom: 1px solid var(--gray-200);
        display: flex;
        justify-content: space-between;
        align-items: center;

        h2 {
            font-size: 20px;
            font-weight: 600;
        }

        .close-btn {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.2s;

            &:hover {
                background: var(--gray-100);
            }
        }
    }

    .widget-body {
        padding: 20px;
    }

    .widget-footer {
        padding: 20px;
        border-top: 1px solid var(--gray-200);
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
}

/* Kalenderansicht */
.calendar-view .year-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--gray-200);
}

.calendar-view .year-nav button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    font-size: 18px;
    font-weight: bold;
    border: none;
    background: transparent;
    cursor: pointer;
}

.calendar-view .year-nav button:hover:not(:disabled) {
    background: var(--gray-100);
}

.calendar-view .year-nav button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.calendar-view .year-nav .year-label {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-800);
    min-width: 60px;
    text-align: center;
}

.calendar-view {

    .month-nav {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;

        button {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.2s;

            &:hover {
                background: var(--gray-100);
            }

            &:disabled {
                opacity: 0.3;
                cursor: not-allowed;
            }
        }

        .month-label {
            font-size: 18px;
            font-weight: 600;
        }
    }

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

        .weekday {
            text-align: center;
            font-size: 12px;
            font-weight: 600;
            color: var(--gray-600);
            padding: 8px 0;
        }
    }

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

        .day {
            aspect-ratio: 1;
            border: 1px solid var(--gray-200);
            border-radius: var(--radius);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.2s;
            background: white;

            .day-number {
                font-size: 14px;
                font-weight: 500;
            }

            .slot-count {
                font-size: 10px;
                color: var(--gray-600);
                margin-top: 2px;
            }

            &:hover:not(.disabled):not(.empty) {
                border-color: var(--primary);
                background: var(--gray-50);
            }

            &.selected {
                background: var(--primary);
                border-color: var(--primary);
                color: white;

                .slot-count {
                    color: rgba(255, 255, 255, 0.9);
                }
            }

            &.disabled {
                background: var(--gray-100);
                color: var(--gray-400);
                cursor: not-allowed;

                .slot-count {
                    display: none;
                }
            }

            &.empty {
                border: none;
                cursor: default;
            }

            &.today {
                border-color: var(--primary);
                border-width: 2px;
            }
        }
    }
}

/* Slot-Auswahl */
.slots-view {
    .back-btn {
        margin-bottom: 20px;
        color: var(--primary);
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-radius: var(--radius);
        transition: background 0.2s;

        &:hover {
            background: var(--gray-100);
        }
    }

    .selected-date {
        font-size: 18px;
        font-weight: 600;
        margin-bottom: 20px;
    }

    .slots-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 12px;

        .slot {
            padding: 16px;
            border: 2px solid var(--gray-200);
            border-radius: var(--radius);
            text-align: center;
            cursor: pointer;
            transition: all 0.2s;
            font-weight: 500;

            &:hover {
                border-color: var(--primary);
                background: var(--gray-50);
            }

            &.selected {
                background: var(--primary);
                border-color: var(--primary);
                color: white;
            }
        }
    }

    .no-slots {
        text-align: center;
        padding: 40px 20px;
        color: var(--gray-600);
    }
}

/* Buchungsformular */
.form-view {
    .back-btn {
        margin-bottom: 20px;
        color: var(--primary);
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-radius: var(--radius);
        transition: background 0.2s;

        &:hover {
            background: var(--gray-100);
        }
    }

    .booking-summary {
        background: var(--gray-50);
        padding: 16px;
        border-radius: var(--radius);
        margin-bottom: 24px;

        .summary-label {
            font-size: 12px;
            color: var(--gray-600);
            margin-bottom: 4px;
        }

        .summary-value {
            font-size: 16px;
            font-weight: 600;
        }
    }

    .form-group {
        margin-bottom: 20px;

        label {
            display: block;
            font-weight: 500;
            margin-bottom: 8px;
            font-size: 14px;

            .required {
                color: var(--danger);
            }
        }

        input, textarea {
            width: 100%;
            padding: 12px;
            border: 1px solid var(--gray-300);
            border-radius: var(--radius);
            transition: border-color 0.2s;

            &:focus {
                outline: none;
                border-color: var(--primary);
            }

            &::placeholder {
                color: var(--gray-400);
            }
        }

        textarea {
            resize: vertical;
            min-height: 100px;
        }

        .error {
            color: var(--danger);
            font-size: 12px;
            margin-top: 4px;
        }
    }
}

/* Erfolgsansicht */
.success-view {
    text-align: center;
    padding: 40px 20px;

    .success-icon {
        font-size: 64px;
        margin-bottom: 20px;
    }

    h3 {
        font-size: 24px;
        margin-bottom: 12px;
    }

    p {
        color: var(--gray-600);
        margin-bottom: 8px;
    }

    .success-details {
        background: var(--gray-50);
        padding: 20px;
        border-radius: var(--radius);
        margin: 24px 0;
        text-align: left;

        .detail-row {
            display: flex;
            justify-content: space-between;
            padding: 8px 0;
            border-bottom: 1px solid var(--gray-200);

            &:last-child {
                border-bottom: none;
            }

            .label {
                color: var(--gray-600);
            }

            .value {
                font-weight: 500;
            }
        }
    }
}

/* Buttons */
.terminbuchung .btn {
    padding: 12px 24px;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
    display: inline-block;
    border: none;
    cursor: pointer;
}

.terminbuchung .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.terminbuchung .btn-primary {
    background: var(--primary) !important;
    color: white !important;
    border: none;
}

.terminbuchung .btn-primary:hover:not(:disabled) {
    background: var(--primary-hover) !important;
}

.terminbuchung .btn-secondary {
    background: var(--gray-200);
    color: var(--gray-800);
}

.terminbuchung .btn-secondary:hover:not(:disabled) {
    background: var(--gray-300);
}

/* Loading State */
.loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-600);
}

/* Responsive */
@media (max-width: 640px) {
    .terminbuchung-popup .terminbuchung-modal {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .calendar-view .days-grid .day {
        .day-number {
            font-size: 12px;
        }

        .slot-count {
            font-size: 9px;
        }
    }

    .slots-view .slots-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 8px;

        .slot {
            padding: 12px 8px;
            font-size: 13px;
        }
    }
}
