/* ===== TABLE BOOKING POPUP - COMPACT & CLEAN ===== */

/* Base Popup */
.ab-booking-popup {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Simple Backdrop */
.ab-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Compact Panel */
.ab-panel {
    position: relative;
    max-width: 440px;
    margin: 8vh auto 0;
    padding: 0 16px;
    z-index: 100000;
    animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Card Content - Compact */
.ab-panel > * {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.08);
    position: relative;
}

/* Close Button - Fix z-index */
.ab-close {
    position: absolute;
    box-shadow: none;
    top: 9px;
    right: 24px;
    background: #f1f5f9;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 18px;
    color: #64748b;
    cursor: pointer;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.ab-close:hover {
    background: #fee2e2;
    color: #dc2626;
    transform: scale(1.05);
}

.ab-close:active {
    transform: scale(0.95);
}

/* Compact Header */
.ab-header {
    text-align: center;
    margin-bottom: 20px;
}

.ab-title {
    margin: 0 0 4px 0;
    font-size: 22px;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.01em;
}

.ab-sub {
    margin: 0;
    font-size: 14px;
    color: #64748b;
}

/* Compact Form Layout */
.ab-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.ab-field {
    position: relative;
    flex: 1;
}

.ab-field.full { width: 100%; }

/* Compact Input Styles */
.ab-field input,
.ab-field textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1.5px solid #e2e8f0;
    background: #fafafa;
    font-size: 14px;
    color: #1e293b;
    transition: all 0.2s ease;
    box-sizing: border-box;
    font-family: inherit;
}

/* Datetime field with custom placeholder */
.ab-datetime-wrapper {
    position: relative;
}

.ab-datetime-wrapper input[type="datetime-local"] {
    color: transparent;
}

.ab-datetime-wrapper input[type="datetime-local"]:focus,
.ab-datetime-wrapper input[type="datetime-local"]:valid {
    color: #1e293b;
}

.ab-datetime-placeholder {
    position: absolute;
    left: 14px;
    top: 12px;
    font-size: 14px;
    color: #94a3b8;
    pointer-events: none;
    transition: all 0.2s ease;
    background: transparent;
    z-index: 1;
}

.ab-datetime-wrapper input[type="datetime-local"]:focus + .ab-datetime-placeholder,
.ab-datetime-wrapper input[type="datetime-local"]:valid + .ab-datetime-placeholder {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
}

/* Specialty input specific styles */
.ab-field input[name="specialty"] {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.ab-field input[name="specialty"]:focus {
    background: #ffffff;
    border-color: #10b981;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

.ab-field input[name="specialty"]::placeholder {
    color: #94a3b8;
    font-style: italic;
}

/* Enhanced textarea */
.ab-field textarea {
    min-height: 70px;
    resize: vertical;
    line-height: 1.4;
}

.ab-field input::placeholder,
.ab-field textarea::placeholder {
    color: #94a3b8;
}

/* Focus States */
.ab-field input:focus,
.ab-field textarea:focus {
    outline: none;
    border-color: #3b82f6;
    background: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

/* Valid States */
.ab-field input:valid:not(:placeholder-shown) {
    border-color: #10b981;
    background: #f0fdf4;
}

/* Required field indicator */
.ab-field input:required,
.ab-field textarea:required {
    background-image: linear-gradient(45deg, transparent 0%, transparent 98%, #ef4444 98%, #ef4444 100%);
    background-size: 8px 8px;
    background-repeat: no-repeat;
    background-position: top right;
}

.ab-field input:valid:required,
.ab-field textarea:valid:required {
    background-image: linear-gradient(45deg, transparent 0%, transparent 98%, #10b981 98%, #10b981 100%);
}

/* Honeypot Hidden */
.ab-hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

/* Compact Submit Button */
.ab-submit {
    width: 100%;
    padding: 14px 20px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    position: relative;
    overflow: hidden;
}

.ab-submit::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.ab-submit:hover::before {
    left: 100%;
}

.ab-submit:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.4);
}

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

.ab-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    background: #94a3b8;
    box-shadow: none;
}

.ab-submit:disabled::before {
    display: none;
}

/* Loading State */
.ab-submit.loading {
    background: #94a3b8;
    cursor: not-allowed;
    position: relative;
    color: transparent;
}

.ab-submit.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-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Compact Message */
.ab-msg {
    margin-top: 12px;
    padding: 10px 12px;
    text-align: center;
    font-weight: 500;
    font-size: 13px;
    border-radius: 8px;
    transition: all 0.2s ease;
    line-height: 1.4;
}

.ab-msg:not(:empty) {
    animation: messageSlide 0.2s ease-out;
}

@keyframes messageSlide {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.ab-msg[style*="green"] {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.ab-msg[style*="red"] {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.ab-msg[style*="blue"] {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* Inline Button */
.ab-inline-btn,
.booking-trigger,
.appointment-trigger {
    display: inline-flex;
    align-items: center;
    padding: 10px 16px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.ab-inline-btn:hover,
.booking-trigger:hover,
.appointment-trigger:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    color: white;
    text-decoration: none;
}

/* Form validation styles */
.ab-field.error input,
.ab-field.error textarea {
    border-color: #ef4444;
    background: #fef2f2;
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.ab-field.success input,
.ab-field.success textarea {
    border-color: #10b981;
    background: #f0fdf4;
}

/* Mobile Responsive - More Compact */
@media (max-width: 768px) {
    .ab-panel {
        margin: 4vh auto 0;
        padding: 0 12px;
        max-width: calc(100vw - 24px);
    }
    
    .ab-panel > * {
        padding: 20px;
        border-radius: 14px;
    }
    
    .ab-close {
        border-radius: 50% !important;
        right: 20px;
        width: 28px;
        height: 28px;
        font-size: 16px;
    }
    
    .ab-row {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 10px;
    }
    
    .ab-field.half {
        flex: none;
        width: 100%;
    }
    
    .ab-title { 
        font-size: 20px;
        margin-bottom: 6px;
    }
    .ab-sub { 
        font-size: 13px;
        line-height: 1.4;
    }
    
    .ab-field input,
    .ab-field textarea {
        padding: 12px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .ab-datetime-placeholder {
        left: 12px;
        top: 12px;
        font-size: 16px;
    }
    
    .ab-submit {
        padding: 14px 18px;
        font-size: 16px;
    }
    
    .ab-header { 
        margin-bottom: 18px; 
    }
}

@media (max-width: 480px) {
    .ab-panel {
        margin: 2vh auto 0;
        padding: 0 8px;
    }
    
    .ab-panel > * {
        padding: 16px;
        border-radius: 12px;
    }
    
    .ab-close {
        right: 16px;
        top: 8px;
    }
    
    .ab-header { margin-bottom: 16px; }
    .ab-title { font-size: 18px; }
    
    .ab-row {
        margin-bottom: 8px;
        gap: 8px;
    }
    
    .ab-field input,
    .ab-field textarea {
        padding: 10px 12px;
    }
    
    .ab-datetime-placeholder {
        left: 12px;
        top: 10px;
    }
}

@media (min-width: 1024px) {
    .ab-panel {
        max-width: 480px;
    }
    
    .ab-datetime-placeholder {
        font-size: 14px;
    }
    
    .ab-panel > * {
        padding: 28px;
    }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .ab-field input,
    .ab-field textarea {
        border-width: 1px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .ab-panel > * {
        background: #1e293b;
        border-color: #334155;
    }
    
    .ab-title {
        color: #f1f5f9;
    }
    
    .ab-sub {
        color: #94a3b8;
    }
    
    .ab-field input,
    .ab-field textarea {
        background: #0f172a;
        border-color: #334155;
        color: #f1f5f9;
    }
    
    .ab-field input::placeholder,
    .ab-field textarea::placeholder {
        color: #64748b;
    }
    
    .ab-close {
        background: #334155;
        color: #94a3b8;
    }
    
    .ab-close:hover {
        background: #ef4444;
        color: #ffffff;
    }
}

/* Print Styles */
@media print {
    .ab-booking-popup { 
        display: none !important; 
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
    
    .ab-submit::before {
        display: none;
    }
}