/**
 * WP Booking System - Frontend Popup Styles
 */

/* Popup Overlay */
.booking-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

/* Popup Content Container */
.booking-popup-content {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: popupSlideIn 0.3s ease-out;
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Popup Header */
.booking-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #e1e1e1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.booking-popup-title {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    flex: 1;
}

.booking-popup-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-left: 15px;
}

.booking-popup-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Popup Body */
.booking-popup-body {
    padding: 25px;
}

.booking-popup-loading {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.booking-popup-loading p {
    margin: 0;
    font-size: 16px;
}

.booking-error {
    text-align: center;
    padding: 20px;
    background: #f8d7da;
    color: #721c24;
    border-radius: 6px;
    margin-bottom: 20px;
}

/* Booking Form Styles */
.booking-popup-form .form-field {
    margin-bottom: 20px;
}

.selected-service {
    padding: 12px 15px;
    background: #f8f9fa;
    border: 2px solid #e1e1e1;
    border-radius: 8px;
    font-size: 16px;
    color: #333;
    font-weight: 500;
}

/* Booking form messages */
#booking-messages {
    margin-bottom: 20px;
}

.wp-booking-message {
    padding: 12px 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-weight: 500;
}

.wp-booking-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.wp-booking-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.booking-popup-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
    font-size: 14px;
}

.booking-popup-form input,
.booking-popup-form select,
.booking-popup-form textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e1e1;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.booking-popup-form input:focus,
.booking-popup-form select:focus,
.booking-popup-form textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.booking-popup-form textarea {
    resize: vertical;
    min-height: 80px;
}

/* Submit Button */
.wp-booking-submit {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s ease;
}

.wp-booking-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
}

.wp-booking-submit:active {
    transform: translateY(0);
}

.wp-booking-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Frontend Button Styles */
.wp-booking-button {
    display: inline-block;
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

.wp-booking-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
    text-decoration: none;
    color: white;
}

.wp-booking-button:active {
    transform: translateY(0);
}

/* Button Style Variants */
.wp-booking-button.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.wp-booking-button.btn-secondary {
    background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
}

.wp-booking-button.btn-success {
    background: linear-gradient(135deg, #00b894 0%, #00a085 100%);
}

.wp-booking-button.btn-warning {
    background: linear-gradient(135deg, #fdcb6e 0%, #e17055 100%);
}

.wp-booking-button.btn-danger {
    background: linear-gradient(135deg, #fd79a8 0%, #e84393 100%);
}

/* Body Lock when Popup is Open */
body.booking-popup-open {
    overflow: hidden;
}

/* Responsive Design */
@media screen and (max-width: 768px) {
    .booking-popup-content {
        width: 95%;
        margin: 10px;
        max-height: 95vh;
    }

    .booking-popup-header {
        padding: 15px 20px;
    }

    .booking-popup-title {
        font-size: 18px;
    }

    .booking-popup-body {
        padding: 20px;
    }

    .booking-popup-form input,
    .booking-popup-form select,
    .booking-popup-form textarea {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

@media screen and (max-width: 480px) {
    .booking-popup-content {
        width: 98%;
        margin: 5px;
        border-radius: 8px;
    }

    .booking-popup-header {
        padding: 12px 15px;
        border-radius: 8px 8px 0 0;
    }

    .booking-popup-body {
        padding: 15px;
    }

    .wp-booking-button {
        padding: 10px 20px;
        font-size: 14px;
    }
}

/* Accessibility */
.booking-popup-close:focus,
.wp-booking-submit:focus,
.wp-booking-button:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Loading Animation */
.booking-popup-loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #ccc;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Booking Calendar Styles */
.wp-booking-calendar {
    max-width: 500px;
    margin: 20px auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.wp-booking-calendar.wp-booking-calendar-small {
    max-width: 300px;
}

.wp-booking-calendar.wp-booking-calendar-large {
    max-width: 700px;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.calendar-title {
    flex: 1;
    text-align: center;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.calendar-nav {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calendar-nav:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.calendar-nav.prev {
    margin-right: 15px;
}

.calendar-nav.next {
    margin-left: 15px;
}

.calendar-grid {
    padding: 20px;
}

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

.weekday {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    padding: 8px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    min-height: 40px;
}

.calendar-day.empty {
    cursor: default;
}

.calendar-day.past {
    color: #ccc;
    cursor: not-allowed;
}

.calendar-day.available {
    color: #333;
    background: #f8f9fa;
}

.calendar-day.available:hover {
    background: #667eea;
    color: white;
    transform: scale(1.1);
}

.calendar-day.today {
    background: #667eea;
    color: white;
    font-weight: 700;
}

.calendar-day.today:hover {
    background: #5a6fd8;
}

.calendar-day.selected {
    background: #28a745;
    color: white;
}

.calendar-day.booked {
    background: #dc3545;
    color: white;
    cursor: not-allowed;
}

.calendar-day.partially-booked {
    background: #ffc107;
    color: #333;
}

.calendar-day.partially-booked::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 6px;
    height: 6px;
    background: #dc3545;
    border-radius: 50%;
}

/* Multi-month calendar */
.wp-booking-calendar[data-months="2"] .calendar-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.wp-booking-calendar[data-months="3"] .calendar-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* Responsive calendar */
@media screen and (max-width: 768px) {
    .wp-booking-calendar {
        margin: 10px;
        max-width: none;
    }

    .calendar-header {
        padding: 12px 15px;
    }

    .calendar-title {
        font-size: 16px;
    }

    .calendar-nav {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    .calendar-grid {
        padding: 15px;
    }

    .calendar-day {
        min-height: 35px;
        font-size: 13px;
    }

    .wp-booking-calendar[data-months="2"] .calendar-grid,
    .wp-booking-calendar[data-months="3"] .calendar-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

@media screen and (max-width: 480px) {
    .calendar-header {
        padding: 10px 12px;
    }

    .calendar-grid {
        padding: 12px;
    }

    .calendar-day {
        min-height: 30px;
        font-size: 12px;
    }

    .weekday {
        font-size: 11px;
        padding: 6px 0;
    }
}

/* Calendar size variants */
.wp-booking-calendar-small .calendar-day {
    min-height: 30px;
    font-size: 12px;
}

.wp-booking-calendar-small .calendar-title {
    font-size: 16px;
}

.wp-booking-calendar-large .calendar-day {
    min-height: 50px;
    font-size: 16px;
}

.wp-booking-calendar-large .calendar-title {
    font-size: 20px;
}

/* Calendar loading state */
.wp-booking-calendar.loading {
    opacity: 0.7;
}

.wp-booking-calendar.loading .calendar-day.available {
    pointer-events: none;
}

/* Enhanced Interactive Calendar States */

/* Calendar is interactive */
.calendar-interactive .calendar-day.available {
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

/* Better hover effects for interactive calendars */
.calendar-interactive .calendar-day.available:hover {
    background: #667eea;
    color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
    z-index: 2;
}

/* Active state for touch devices */
.calendar-interactive .calendar-day.available:active,
.calendar-interactive .calendar-day.available.touch-active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

/* Selected date styling */
.calendar-interactive .calendar-day.selected {
    background: #28a745 !important;
    color: white !important;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
    border: 2px solid #1e7e34;
    animation: selectedPulse 1s ease-in-out;
}

@keyframes selectedPulse {
    0% { transform: scale(1.05); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1.05); }
}

/* Loading state for individual calendar days */
.calendar-day.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.calendar-day.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 3;
}

/* Success animation for booking completion */
.calendar-day.booking-success {
    background: #28a745 !important;
    color: white !important;
    animation: successPulse 0.8s ease-in-out;
}

@keyframes successPulse {
    0% { transform: scale(1); }
    25% { transform: scale(1.2); background: #20c997; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Navigation button enhancements */
.calendar-interactive .calendar-nav {
    transition: all 0.2s ease;
}

.calendar-interactive .calendar-nav:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.calendar-interactive .calendar-nav:active {
    transform: scale(0.95);
}

.calendar-nav.loading {
    pointer-events: none;
    opacity: 0.7;
    position: relative;
}

.calendar-nav.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Display-only calendar (non-interactive) */
.calendar-display-only .calendar-day.available {
    cursor: default;
}

.calendar-display-only .calendar-day.available:hover {
    background: #f8f9fa;
    color: #333;
    transform: none;
    box-shadow: none;
}

/* Mobile touch improvements */
@media (max-width: 768px) {
    .calendar-interactive .calendar-day.available {
        min-height: 44px; /* iOS recommended touch target */
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .calendar-interactive .calendar-day.available:hover {
        transform: none; /* Disable hover scaling on touch devices */
        box-shadow: none;
    }

    .calendar-interactive .calendar-day.available:active,
    .calendar-interactive .calendar-day.available.touch-active {
        background: #667eea;
        color: white;
        transform: scale(0.95);
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .calendar-day.selected {
        border: 3px solid #000 !important;
    }

    .calendar-day.available:hover {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .calendar-day.available,
    .calendar-nav,
    .calendar-day.selected {
        transition: none;
        animation: none;
        transform: none !important;
    }

    .calendar-day.available:hover {
        transform: none;
    }
}

/* Focus states for keyboard navigation */
.calendar-interactive .calendar-day.available:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
    background: #667eea;
    color: white;
}

.calendar-nav:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Enhanced popup integration styles */
.booking-popup-content .calendar-date-message {
    background: linear-gradient(135deg, #e8f5e8, #d4edda);
    color: #2e7d2e;
    padding: 12px;
    margin: 10px 0;
    border-radius: 6px;
    font-size: 14px;
    border-left: 4px solid #28a745;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Calendar with service integration */
.calendar-interactive[data-service]:not([data-service=""]) .calendar-day.available::before {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 6px;
    height: 6px;
    background: #007cba;
    border-radius: 50%;
    opacity: 0.7;
}

.calendar-interactive[data-service]:not([data-service=""]) .calendar-day.selected::before {
    background: white;
    opacity: 1;
}