/**
 * Silva Customer Portal - Booking Modal Styles
 * Mobile-responsive booking modal with clean, modern design
 */

/* Shared booking button - used by both CRM and Portal systems */
.silva-booking-btn {
    background: #014385;
    color: #ffffff;
    padding: 14px 28px;
    border-radius: 8px;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(1, 67, 133, 0.15);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
}

.silva-booking-btn:hover {
    background: #012d5a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(1, 67, 133, 0.25);
}

.silva-booking-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(1, 67, 133, 0.2);
}

.silva-booking-btn:focus-visible {
    outline: 3px solid rgba(1, 67, 133, 0.4);
    outline-offset: 2px;
}

@media (max-width: 640px) {
    .silva-booking-btn {
        width: 100%;
        justify-content: center;
        padding: 16px 24px;
    }
}

/* Prevent body scroll when modal is open */
body.silva-modal-open {
    overflow: hidden !important;
    position: relative;
}

.silva-booking-modal,
#silva-portal-booking-modal { 
    position: fixed; 
    left: 0; 
    right: 0; 
    top: 0; 
    bottom: 0; 
    background: rgba(0, 0, 0, 0.6);
    align-items: center; 
    justify-content: center; 
    z-index: var(--z-booking);
    padding: 16px;
    display: none; /* Hidden by default */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Show modal when open - fallback without body class for reliability */
.silva-booking-modal.is-open,
#silva-portal-booking-modal.is-open,
body .silva-booking-modal.is-open,
body #silva-portal-booking-modal.is-open,
body.silva-modal-open .silva-booking-modal.is-open,
body.silva-modal-open #silva-portal-booking-modal.is-open {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: var(--z-booking-open);
    transform: translateZ(0);
    backface-visibility: hidden;
    visibility: visible;
    opacity: 1;
}

.silva-booking-modal-inner { 
    background: #fff; 
    padding: 32px; 
    width: 100%; 
    max-width: 520px; 
    border-radius: 12px; 
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    margin: auto;
}

/* Apply will-change only during open animation */
.silva-booking-modal.is-opening .silva-booking-modal-inner {
    will-change: transform, opacity;
}

.silva-booking-modal.is-open .silva-booking-modal-inner {
    will-change: auto; /* Remove after animation */
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 12px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top-color: #1e73be;
    border-radius: 50%;
    animation: spin 0.8s linear infinite; /* Animation defined in base.css */
}

.silva-close { 
    position: absolute; 
    right: 16px; 
    top: 16px; 
    background: transparent; 
    border: none; 
    font-size: 32px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    line-height: 1;
    transition: all 0.2s;
    border-radius: 4px;
    z-index: 11;
}

.silva-close:hover {
    color: #333;
    background: #f5f5f5;
}

.silva-close:focus {
    outline: 2px solid #1e73be;
    outline-offset: 2px;
}

/* Screen reader only text */
.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;
}

/* Field error messages */
.field-error {
    display: none;
    color: #dc2626;
    font-size: 14px;
    margin-top: 4px;
    font-weight: 500;
}

.silva-booking-modal h2 {
    margin: 0 0 24px 0;
    font-size: 24px;
    padding-right: 40px;
    color: #1a1a1a;
    font-weight: 600;
}

.silva-booking-modal label { 
    display: block; 
    margin-bottom: 18px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.silva-booking-modal input[type="text"], 
.silva-booking-modal input[type="email"],
.silva-booking-modal input[type="tel"],
.silva-booking-modal input[type="date"], 
.silva-booking-modal select,
.silva-booking-modal textarea { 
    width: 100%; 
    padding: 12px 14px; 
    box-sizing: border-box;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 16px;
    margin-top: 6px;
    transition: all 0.2s;
    font-family: inherit;
}

.silva-booking-modal textarea {
    min-height: 100px;
    resize: vertical;
    line-height: 1.5;
}

.silva-booking-modal input:focus,
.silva-booking-modal select:focus,
.silva-booking-modal textarea:focus {
    outline: none;
    border-color: #1e73be;
    box-shadow: 0 0 0 3px rgba(30, 115, 190, 0.1);
}

.silva-booking-modal input:invalid:not(:focus),
.silva-booking-modal select:invalid:not(:focus) {
    border-color: #fca5a5;
}

.silva-booking-modal .silva-submit { 
    width: 100%; 
    margin-top: 24px; 
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    background: #1e73be;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    touch-action: manipulation; /* Prevent double-tap zoom */
}

.silva-booking-modal .silva-submit:hover:not(:disabled) {
    background: #155a8a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 115, 190, 0.3);
}

.silva-booking-modal .silva-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Accessibility - Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Field validation errors */
.field-error {
    display: none;
    color: #dc2626;
    font-size: 13px;
    margin-top: 4px;
    font-weight: 500;
}

/* Mobile Responsive - Keep modal overlay for proper UX */
@media (max-width: 768px) {
    /* Keep modal as overlay on mobile for better UX */
    .silva-booking-modal {
        padding: 12px !important;
    }
    
    /* Compact form for mobile */
    .silva-booking-modal-inner { 
        padding: 24px 16px !important; 
        border-radius: 8px;
        margin: auto !important;
        max-width: 100% !important;
        width: 100% !important;
        max-height: 92vh !important;
        position: relative !important;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2) !important;
    }
    
    /* Close button - compact for mobile */
    .silva-close {
        right: 12px !important;
        top: 12px !important;
        width: 32px !important;
        height: 32px !important;
        font-size: 24px !important;
    }
    
    /* Compact heading */
    .silva-booking-modal h2 { 
        font-size: 20px;
        margin-bottom: 16px;
        padding-right: 40px !important;
    }
    
    /* Compact form fields */
    .silva-booking-modal label {
        margin-bottom: 12px;
        font-size: 13px;
    }
    
    .silva-booking-modal input[type="text"], 
    .silva-booking-modal input[type="email"],
    .silva-booking-modal input[type="tel"],
    .silva-booking-modal input[type="date"], 
    .silva-booking-modal select,
    .silva-booking-modal textarea { 
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 14px 12px;
        min-height: 48px;
        touch-action: manipulation; /* Better mobile interaction */
    }
    
    .silva-booking-modal textarea {
        min-height: 100px;
    }
    
    .silva-booking-modal .silva-submit {
        padding: 14px;
    }
}

@media (max-width: 480px) {
    .silva-booking-modal-inner { 
        padding: 20px 16px !important; 
        border-radius: 8px;
    }
    
    .silva-booking-modal h2 { 
        font-size: 20px;
        margin-bottom: 16px;
    }
    
    .silva-booking-modal label {
        margin-bottom: 16px;
    }
}
