/**
 * Calendar Widget Styles for Terminscheduler
 * Extends base fron.terminscheduler-calendar .fc-toolbar {
    margin-bottom: 1.5rem;
    position: relative;
    z-index: 3;
}

.terminscheduler-calendar .fc-toolbar-title {
    font-size: 1.5rem;
    font-weight: 600;
}

/* Ensure "Heute" button on right side is properly styled */
.terminscheduler-calendar .fc-toolbar-chunk:last-child {
    display: flex;
    justify-content: flex-end;
}

.terminscheduler-calendar .fc-today-button {
    background-color: #28a745;
    border-color: #28a745;
    color: white;
    padding: 0.375rem 0.75rem;
    border-radius: 0.25rem;
    font-weight: 500;
}

.terminscheduler-calendar .fc-today-button:hover,
.terminscheduler-calendar .fc-today-button:focus {
    background-color: #218838;
    border-color: #1e7e34;
}

.terminscheduler-calendar .fc-button-primary {
    background-color: #0073aa;
    border-color: #0073aa;
    color: white;
    padding: 0.375rem 0.75rem;
    border-radius: 0.25rem;
}ndar-specific styling
 */

/* Calendar Container */
.terminscheduler-calendar-form {
    position: relative;
    overflow: hidden; /* Prevent overflow issues */
}

.terminscheduler-calendar-container {
    margin-bottom: 2rem;
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 100%;
    overflow: hidden; /* Prevent any content overflow */
}

.terminscheduler-step {
    margin-bottom: 1.5rem;
    clear: both; /* Ensure proper flow */
}

.terminscheduler-step-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #333;
    display: flex;
    align-items: center;
}

.terminscheduler-step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    background: #0073aa;
    color: white;
    border-radius: 50%;
    font-size: 0.9rem;
    font-weight: bold;
    margin-right: 0.75rem;
}

/* FullCalendar Overrides */
.terminscheduler-calendar {
    position: relative;
    z-index: 1;
    margin-bottom: 1rem; /* Add space below calendar */
    overflow: visible; /* Ensure proper display */
}

.terminscheduler-calendar .fc {
    font-family: inherit;
    position: relative;
    overflow: visible;
}

.terminscheduler-calendar .fc-view-harness {
    position: relative;
    overflow: visible;
}

.terminscheduler-calendar .fc-daygrid {
    position: relative;
    overflow: visible;
}

.terminscheduler-calendar .fc-toolbar {
    margin-bottom: 1rem;
    position: relative;
    z-index: 3;
}

.terminscheduler-calendar .fc-toolbar-title {
    font-size: 1.5rem;
    font-weight: 600;
}

.terminscheduler-calendar .fc-button-primary {
    background-color: #0073aa;
    border-color: #0073aa;
    color: white;
    padding: 0.375rem 0.75rem;
    border-radius: 0.25rem;
}

.terminscheduler-calendar .fc-button-primary:hover,
.terminscheduler-calendar .fc-button-primary:focus {
    background-color: #005a87;
    border-color: #005a87;
}

.terminscheduler-calendar .fc-button-primary:disabled {
    background-color: #6c757d;
    border-color: #6c757d;
}

.terminscheduler-calendar .fc-daygrid-day {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.terminscheduler-calendar .fc-daygrid-day:hover {
    background-color: #f8f9fa;
}

.terminscheduler-calendar .fc-daygrid-day.fc-day-today {
    background-color: #e8f4fd;
}

.terminscheduler-calendar .fc-daygrid-day.fc-day-selected {
    background-color: #d4edda;
    border-color: #28a745;
}

/* Past and blocked dates */
.terminscheduler-calendar .fc-day-past,
.terminscheduler-calendar .fc-day-blocked {
    position: relative;
    pointer-events: none;
}

.terminscheduler-calendar .fc-day-past::after,
.terminscheduler-calendar .fc-day-blocked::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    pointer-events: none;
}

.terminscheduler-calendar .fc-day-blocked::before {
    content: '✕';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #d32f2f;
    font-weight: bold;
    z-index: 2;
    font-size: 1.2rem;
}

/* Blocked events styling */
.terminscheduler-calendar .fc-event.blocked-date {
    background-color: #ffcdd2 !important;
    border-color: #f44336 !important;
    opacity: 0.7;
}

/* Selected Date Display */
.terminscheduler-selected-date {
    display: none;
    background: #e8f4fd;
    border: 1px solid #0073aa;
    border-radius: 0.5rem;
    padding: 1rem;
    margin: 1rem 0 1.5rem 0; /* Clear margins */
    position: relative;
    z-index: 2;
    clear: both; /* Ensure it doesn't overlap */
}

.selected-date-display {
    font-size: 1.1rem;
    font-weight: 600;
    color: #0073aa;
    margin-bottom: 0.5rem;
}

.selected-date-info {
    font-size: 0.9rem;
    color: #666;
}

/* Time Selection Section */
.terminscheduler-time-section {
    display: none;
    position: relative;
    z-index: 2;
    margin-top: 1rem;
    clear: both;
}

.terminscheduler-time-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.5rem;
    margin-top: 1rem;
}

.terminscheduler-time-button {
    background: white;
    border: 2px solid #ddd;
    border-radius: 0.375rem;
    padding: 0.75rem 0.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.terminscheduler-time-button:hover {
    border-color: #0073aa;
    background-color: #f8f9fa;
}

.terminscheduler-time-button.selected {
    background-color: #0073aa;
    border-color: #0073aa;
    color: white;
}

/* Alternative time select dropdown */
.terminscheduler-time-select {
    width: 100%;
    max-width: 200px;
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: 0.375rem;
    font-size: 1rem;
    background-color: white;
    transition: border-color 0.2s ease;
}

.terminscheduler-time-select:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 0.2rem rgba(0, 115, 170, 0.25);
}

/* Contact Section */
.terminscheduler-contact-section {
    display: none;
    background: #f9f9f9;
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-top: 1.5rem;
    position: relative;
    z-index: 2;
    clear: both;
}

.terminscheduler-contact-section input[type=date], .terminscheduler-contact-section input[type=email], .terminscheduler-contact-section input[type=number], .terminscheduler-contact-section input[type=password], .terminscheduler-contact-section input[type=search], .terminscheduler-contact-section input[type=tel], .terminscheduler-contact-section input[type=text], .terminscheduler-contact-section input[type=url], .terminscheduler-contact-section select, .terminscheduler-contact-section textarea {
    border: 1px solid #e6e6e6;
}

/* Enhanced focus styles for auto-focused inputs */
.terminscheduler-contact-section .terminscheduler-input:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 0.2rem rgba(0, 115, 170, 0.25);
    outline: none;
    animation: focusGlow 0.3s ease;
}

.terminscheduler-contact-section input[name="name"]:focus {
    border-color: #dedede;
    box-shadow: 0 0 0 0.2rem rgb(193 193 193 / 25%);
    animation: nameInputFocus 0.5s ease;
}

/* Focus animations */
@keyframes focusGlow {
    from {
        box-shadow: 0 0 0 0 rgba(0, 115, 170, 0.5);
    }
    to {
        box-shadow: 0 0 0 0.2rem rgba(0, 115, 170, 0.25);
    }
}

@keyframes nameInputFocus {
    0% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.8);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 0.3rem rgba(40, 167, 69, 0.4);
        transform: scale(1.02);
    }
    100% {
        box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
        transform: scale(1);
    }
}

/* Time Selection Popup */
.terminscheduler-time-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

/* Special positioning when inside Elementor popup */
.elementor-popup-modal .terminscheduler-time-popup-overlay {
    position: absolute;
    z-index: 999999; /* Higher than Elementor's z-index */
}

/* Prevent Elementor popup from closing during our time selection */
.elementor-popup-modal[data-terminscheduler-processing="true"] {
    pointer-events: auto !important;
}

.elementor-popup-modal[data-terminscheduler-processing="true"] .elementor-popup-close {
    pointer-events: none !important;
    opacity: 0.5;
}

.terminscheduler-time-popup-overlay.closing {
    animation: fadeOut 0.2s ease forwards;
    pointer-events: none;
}

.terminscheduler-time-popup-overlay.hidden {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

.terminscheduler-time-popup {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    max-width: 90vw;
    max-height: 90vh;
    min-width: 300px;
    overflow: hidden;
    animation: slideIn 0.3s ease;
    position: relative;
}

.terminscheduler-popup-header {
    background: #000;
    color: white;
    padding: 1.5rem;
    position: relative;
}

.terminscheduler-popup-header h3 {
    color: white;
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.terminscheduler-popup-header p {
    margin: 0;
    opacity: 0.9;
    font-size: 0.95rem;
}

.terminscheduler-popup-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.terminscheduler-popup-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.terminscheduler-popup-content {
    padding: 1.5rem;
    max-height: 400px;
    overflow-y: auto;
}

.terminscheduler-time-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.75rem;
}

.terminscheduler-time-option {
    background-color: #e8e8e8 !important;
    color: black !important;
    border: 0;
    border-radius: 0.5rem;
    padding: 0.75rem 0.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    font-weight: 500;
    position: relative;
    z-index: 1;
    pointer-events: auto;
    user-select: none;
}

.terminscheduler-time-option:hover,
.terminscheduler-time-option:focus {
    border-color: #0073aa;
    background-color: #f8f9fa;
    outline: none;
    transform: translateY(-1px);
    /*box-shadow: 0 2px 4px rgba(0, 115, 170, 0.2);*/
}

.terminscheduler-time-option:active {
    transform: translateY(0);
}

.terminscheduler-popup-footer {
    background: #f8f9fa;
    padding: 1rem 1.5rem;
    border-top: 1px solid #dee2e6;
    text-align: right;
}

.terminscheduler-popup-cancel {
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 0.375rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

.terminscheduler-popup-cancel:hover {
    background: #5a6268;
}

/* Selected time event styling in calendar */
.terminscheduler-calendar .fc-event.selected-time-event {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 2px 4px;
    border-radius: 4px;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Progressive Enhancement */
.terminscheduler-calendar-form.js-enhanced .terminscheduler-step {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.terminscheduler-calendar-form.js-enhanced .terminscheduler-step.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .terminscheduler-calendar-form {
        overflow-x: hidden; /* Prevent horizontal overflow */
    }
    
    .terminscheduler-calendar {
        margin-bottom: 2rem; /* More space on mobile */
    }
    
    .terminscheduler-calendar .fc-toolbar {
        flex-direction: column;
        gap: 0.5rem;
        margin-bottom: 1.5rem;
    }
    
    .terminscheduler-calendar .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
    }
    
    /* On mobile, keep "Heute" button centered like other elements */
    .terminscheduler-calendar .fc-toolbar-chunk:last-child {
        justify-content: center;
    }
    
    .terminscheduler-calendar .fc-button-group {
        width: auto;
    }
    
    .terminscheduler-selected-date {
        margin: 1.5rem 0;
        padding: 1rem;
    }
    
    .terminscheduler-time-section {
        margin-top: 1.5rem;
    }
    
    .terminscheduler-time-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 0.375rem;
    }
    
    /* Mobile popup adjustments */
    .terminscheduler-time-popup {
        margin: 1rem;
        min-width: auto;
        width: calc(100% - 2rem);
    }
    
    .terminscheduler-popup-header {
        padding: 1rem;
    }
    
    .terminscheduler-popup-header h3 {
        font-size: 1.1rem;
    }
    
    .terminscheduler-popup-content {
        padding: 1rem;
        max-height: 300px;
    }
    
    .terminscheduler-time-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    
    .terminscheduler-time-option {
        padding: 0.6rem 0.4rem;
        font-size: 0.85rem;
    }
    
    .terminscheduler-time-button {
        padding: 0.5rem 0.25rem;
        font-size: 0.8rem;
    }
    
    .terminscheduler-step-title {
        font-size: 1.1rem;
    }
    
    .terminscheduler-step-number {
        width: 1.75rem;
        height: 1.75rem;
        font-size: 0.8rem;
        margin-right: 0.5rem;
    }
}

@media (max-width: 480px) {
    .terminscheduler-calendar-container {
        margin-bottom: 1rem;
    }
    
    .terminscheduler-selected-date,
    .terminscheduler-contact-section {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .terminscheduler-calendar .fc-daygrid-day-frame {
        min-height: 2rem;
    }
    
    .terminscheduler-calendar .fc-col-header-cell {
        padding: 0.25rem;
    }
    
    .terminscheduler-time-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Loading States */
.terminscheduler-calendar-form.loading .terminscheduler-calendar {
    opacity: 0.6;
    pointer-events: none;
}

.terminscheduler-calendar-form.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2rem;
    height: 2rem;
    margin: -1rem 0 0 -1rem;
    border: 3px solid #ddd;
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1000;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Success Message */
.terminscheduler-success-message {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    padding: 1.5rem;
    border-radius: 0.5rem;
    text-align: center;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    display: none;
}

.terminscheduler-success-message h3 {
    margin: 0 0 0.5rem 0;
    color: #155724;
}

/* Error States */
.terminscheduler-general-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    display: none;
}

/* Calendar Error Styling */
.terminscheduler-calendar.error {
    border: 2px solid #dc3545;
    border-radius: 0.375rem;
}

.terminscheduler-calendar .terminscheduler-error {
    position: absolute;
    bottom: -1.5rem;
    left: 0;
    right: 0;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
}

.terminscheduler-calendar .terminscheduler-error.show {
    opacity: 1;
    transform: translateY(0);
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .terminscheduler-calendar .fc {
        color: #e0e0e0;
    }
    
    .terminscheduler-calendar .fc-toolbar-title {
        color: #a2a2a2;
    }
    
    .terminscheduler-selected-date {
        background: #efefef;
        border: 0;
    }
    
    .selected-date-display {
        color: #4a90c2;
    }
    
    .terminscheduler-contact-section {
        background: #f9f9f9;
        color: #e0e0e0;
    }
    
    .terminscheduler-time-button {
        background: #3d3d3d;
        border-color: #555;
        color: #e0e0e0;
    }
    
    .terminscheduler-time-button:hover {
        background: #4d4d4d;
        border-color: #4a90c2;
    }
    
    .terminscheduler-time-button.selected {
        background: #4a90c2;
        border-color: #4a90c2;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .terminscheduler-calendar .fc-button-primary {
        background-color: #000;
        border-color: #000;
    }
    
    .terminscheduler-calendar .fc-daygrid-day:hover {
        background-color: #000;
        color: #fff;
    }
    
    .terminscheduler-time-button {
        border-width: 3px;
    }
    
    .terminscheduler-time-button.selected {
        background-color: #000;
        border-color: #000;
    }
}

/* Print Styles */
@media print {
    .terminscheduler-calendar,
    .terminscheduler-contact-section {
        display: none !important;
    }
    
    .terminscheduler-success-message {
        display: block !important;
        background: none !important;
        border: 2px solid #000 !important;
        color: #000 !important;
    }
}
