/**
 * MuscatHeights Booking - UI Enhancements Styles
 * Loading states, form validation, alerts, and error handling
 */

/* ==========================================================================
   Loading States
   ========================================================================== */

.muscatheights-btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

.muscatheights-btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-top: -8px;
    margin-left: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: muscatheights-spin 0.8s linear infinite;
}

.muscatheights-btn-loading .loading-text {
    padding-left: 24px;
}

/* Skeleton Loader */
.muscatheights-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: muscatheights-shimmer 1.5s infinite;
    border-radius: 4px;
}

.muscatheights-skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.muscatheights-skeleton-title {
    height: 1.5em;
    width: 60%;
    margin-bottom: 1em;
}

.muscatheights-skeleton-image {
    height: 200px;
    width: 100%;
}

.muscatheights-skeleton-button {
    height: 44px;
    width: 120px;
}

@keyframes muscatheights-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes muscatheights-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Loading Overlay */
.muscatheights-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: inherit;
}

.muscatheights-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #ff6b35;
    border-radius: 50%;
    animation: muscatheights-spin 1s linear infinite;
}

/* ==========================================================================
   Form Validation
   ========================================================================== */

/* Error State */
.muscatheights-field-error {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.2) !important;
}

.muscatheights-field-error:focus {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.25) !important;
    outline: none;
}

/* Success State */
.muscatheights-field-success {
    border-color: #28a745 !important;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2) !important;
}

.muscatheights-field-success:focus {
    border-color: #28a745 !important;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.25) !important;
}

/* Error Message */
.muscatheights-error-message {
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    animation: muscatheights-fade-in 0.2s ease;
}

.muscatheights-error-message::before {
    content: '⚠';
    font-size: 1em;
}

/* Success Message */
.muscatheights-success-message {
    color: #28a745;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    animation: muscatheights-fade-in 0.2s ease;
}

.muscatheights-success-message::before {
    content: '✓';
    font-size: 1em;
}

@keyframes muscatheights-fade-in {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   Alert Messages
   ========================================================================== */

.muscatheights-alerts-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    max-width: 500px;
    width: 90%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.muscatheights-alert {
    display: flex;
    align-items: flex-start;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: muscatheights-slide-down 0.3s ease;
}

@keyframes muscatheights-slide-down {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.muscatheights-alert-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border-radius: 50%;
    margin-right: 12px;
}

.muscatheights-alert-content {
    flex: 1;
    min-width: 0;
}

.muscatheights-alert-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.muscatheights-alert-message {
    font-size: 0.9375rem;
    line-height: 1.5;
}

.muscatheights-alert-dismiss {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.5;
    padding: 0;
    margin-left: 12px;
    border-radius: 4px;
    transition: opacity 0.2s, background 0.2s;
}

.muscatheights-alert-dismiss:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.1);
}

/* Alert Types */
.muscatheights-alert-error {
    background: #fff5f5;
    border: 1px solid #feb2b2;
    color: #c53030;
}

.muscatheights-alert-error .muscatheights-alert-icon {
    background: #fed7d7;
    color: #c53030;
}

.muscatheights-alert-success {
    background: #f0fff4;
    border: 1px solid #9ae6b4;
    color: #276749;
}

.muscatheights-alert-success .muscatheights-alert-icon {
    background: #c6f6d5;
    color: #276749;
}

.muscatheights-alert-warning {
    background: #fffaf0;
    border: 1px solid #fbd38d;
    color: #c05621;
}

.muscatheights-alert-warning .muscatheights-alert-icon {
    background: #feebc8;
    color: #c05621;
}

.muscatheights-alert-info {
    background: #ebf8ff;
    border: 1px solid #90cdf4;
    color: #2b6cb0;
}

.muscatheights-alert-info .muscatheights-alert-icon {
    background: #bee3f8;
    color: #2b6cb0;
}

/* ==========================================================================
   Accessibility Enhancements
   ========================================================================== */

/* Focus visible states */
.muscatheights-booking-widget button:focus-visible,
.muscatheights-booking-widget a:focus-visible,
.muscatheights-booking-widget input:focus-visible,
.muscatheights-booking-widget select:focus-visible,
.muscatheights-booking-widget textarea:focus-visible {
    outline: 2px solid #ff6b35;
    outline-offset: 2px;
}

/* Skip link */
.muscatheights-skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #ff6b35;
    color: white;
    padding: 8px 16px;
    z-index: 10000;
    transition: top 0.3s;
}

.muscatheights-skip-link:focus {
    top: 0;
}

/* Screen reader only */
.muscatheights-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .muscatheights-field-error {
        border-width: 3px;
    }
    
    .muscatheights-alert {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .muscatheights-btn-loading::after,
    .muscatheights-loading-spinner {
        animation: none;
    }
    
    .muscatheights-skeleton {
        animation: none;
        background: #e0e0e0;
    }
    
    .muscatheights-alert,
    .muscatheights-error-message,
    .muscatheights-success-message {
        animation: none;
    }
}

/* ==========================================================================
   ARIA States
   ========================================================================== */

[aria-busy="true"] {
    cursor: wait;
}

[aria-disabled="true"] {
    opacity: 0.5;
    pointer-events: none;
}

[aria-hidden="true"] {
    display: none !important;
}

/* Live region for announcements */
.muscatheights-live-region {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .muscatheights-alerts-container .muscatheights-alert-error {
        background: #2d0f0f;
        border-color: #7c1d1d;
        color: #feb2b2;
    }
    
    .muscatheights-alerts-container .muscatheights-alert-success {
        background: #0f2d17;
        border-color: #276749;
        color: #9ae6b4;
    }
    
    .muscatheights-alerts-container .muscatheights-alert-warning {
        background: #2d2106;
        border-color: #975a16;
        color: #fbd38d;
    }
    
    .muscatheights-alerts-container .muscatheights-alert-info {
        background: #0f1d2d;
        border-color: #2b6cb0;
        color: #90cdf4;
    }
    
    .muscatheights-skeleton {
        background: linear-gradient(90deg, #2d2d2d 25%, #3d3d3d 50%, #2d2d2d 75%);
        background-size: 200% 100%;
    }
    
    .muscatheights-loading-overlay {
        background: rgba(30, 30, 30, 0.9);
    }
}
