@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&family=Alexandria:wght@300;400;500;600;700&display=swap');

:root {
    /* Luxury Palette */
    --lux-pearl: #F8F7F3;
    --lux-ivory: #F2EFE8;
    --lux-sand: #DED3C2;
    --lux-gold: #C5A467;
    --lux-gold-soft: #E3D4B3;
    --lux-navy: #10243E;
    --lux-navy-soft: #223A57;
    --lux-sky: #9CC8D8;
    --lux-sage: #8FAF9D;
    --lux-charcoal: #20252D;
    --lux-muted: #6E7683;
    --lux-border: rgba(255,255,255,0.55);
    --lux-glass: rgba(255,255,255,0.48);
    
    /* Legacy mapping for compatibility */
    --pr-primary: var(--lux-navy);
    --pr-primary-hover: #0a1728;
    --pr-secondary: rgba(255, 255, 255, 0.7);
    --pr-secondary-hover: rgba(255, 255, 255, 0.9);
    --pr-danger: #8A3A3A;
    --pr-success: var(--lux-sage);
    --pr-text: var(--lux-charcoal);
    --pr-muted: var(--lux-muted);
    --pr-body-bg: var(--lux-pearl);
    --pr-glass-border: var(--lux-border);
}

*, *::before, *::after {
    box-sizing: border-box !important;
}

html {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--pr-body-bg);
    color: var(--pr-text);
    font-family: 'Cairo', 'Alexandria', sans-serif !important;
    margin: 0;
    padding: 0;
    direction: rtl;
    text-align: right;
    min-height: 100vh;
    width: 100% !important;
    max-width: 100% !important;
    position: relative;
    overflow-x: hidden !important;
    line-height: 1.6;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Prevent auto zoom on input focus in iOS Safari */
input, select, textarea {
    font-size: 16px !important;
    font-family: 'Cairo', 'Alexandria', sans-serif !important;
}

/* Luxury Animated Background */
body::before, body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.4;
    transition: all 1s ease;
}

body::before {
    top: -10%;
    right: -10%;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, rgba(156,200,216,0.3) 0%, rgba(197,164,103,0.1) 100%);
    animation: luxFloat1 30s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
}

body::after {
    bottom: -15%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, rgba(143,175,157,0.2) 0%, rgba(156,200,216,0.1) 100%);
    animation: luxFloat2 35s infinite alternate-reverse cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes luxFloat1 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(-3%, 4%) scale(1.05); }
}

@keyframes luxFloat2 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(4%, -3%) scale(1.05); }
}

@media (prefers-reduced-motion: reduce) {
    body::before, body::after { animation: none; }
}

/* Luxury Glassmorphism Card */
.pr-card {
    background: linear-gradient(145deg, rgba(255,255,255,0.75), rgba(255,255,255,0.45));
    border: 1px solid var(--lux-border);
    border-radius: 28px;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 24px 60px rgba(20, 36, 62, 0.04), inset 0 1px 0 rgba(255,255,255,0.8);
    padding: 2.5rem;
    margin-bottom: 2rem;
    transition: transform 0.4s ease, box-shadow 0.4s ease;
    transform: translateZ(0);
    will-change: transform;
}

/* Luxury Buttons */
.pr-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem 2rem;
    font-size: 1rem;
    font-weight: 500;
    font-family: 'Alexandria', sans-serif;
    border-radius: 14px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    background-color: var(--lux-navy);
    color: white;
    box-shadow: 0 8px 20px rgba(16, 36, 62, 0.15);
    gap: 0.5rem;
}

.pr-btn:hover:not(:disabled) {
    background-color: var(--lux-navy-soft);
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(16, 36, 62, 0.2);
}

.pr-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 4px 10px rgba(16, 36, 62, 0.1);
}

.pr-btn.secondary {
    background: rgba(255,255,255,0.6);
    border: 1px solid var(--lux-border);
    color: var(--lux-navy);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

.pr-btn.secondary:hover {
    background: rgba(255,255,255,0.9);
}

.pr-btn.gold {
    background: linear-gradient(135deg, var(--lux-gold), #B39255);
    color: white;
    box-shadow: 0 8px 20px rgba(197, 164, 103, 0.3);
}

.pr-btn.gold:hover {
    background: linear-gradient(135deg, #B39255, #9C7D45);
}

.pr-btn.danger {
    background-color: var(--pr-danger);
    box-shadow: 0 8px 20px rgba(138, 58, 58, 0.2);
}

.pr-btn:disabled, .pr-btn.loading {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Forms */
.pr-form-group {
    margin-bottom: 1.5rem;
}

.pr-form-group label {
    display: block;
    margin-bottom: 0.6rem;
    font-weight: 500;
    color: var(--lux-navy);
    font-size: 0.95rem;
}

.pr-input {
    width: 100%;
    padding: 1rem 1.25rem;
    font-size: 1rem;
    font-family: 'Alexandria', sans-serif;
    border: 1px solid rgba(222, 211, 194, 0.5); /* lux-sand */
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.6);
    color: var(--lux-charcoal);
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.pr-input:focus {
    outline: none;
    border-color: var(--lux-gold);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(197, 164, 103, 0.1);
}

select.pr-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23C5A467' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 1rem center;
    background-size: 1.2rem;
    padding-left: 2.5rem;
}

/* Container */
.pr-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Typography Classes */
h1, h2, h3, h4, h5, h6 {
    color: var(--lux-navy);
    font-weight: 600;
    margin-top: 0;
}

.lux-title {
    font-size: 2.5rem;
    line-height: 1.3;
    color: var(--lux-navy);
    margin-bottom: 1rem;
}

.lux-subtitle {
    font-size: 1.1rem;
    color: var(--lux-muted);
    font-weight: 400;
    margin-bottom: 2rem;
}

/* Badges */
.lux-badge {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    background: rgba(255,255,255,0.7);
    border: 1px solid var(--lux-border);
}

.lux-badge.success { color: #2e664e; background: rgba(143, 175, 157, 0.15); border-color: rgba(143, 175, 157, 0.4); }
.lux-badge.warning { color: #8a6d3b; background: rgba(197, 164, 103, 0.15); border-color: rgba(197, 164, 103, 0.4); }
.lux-badge.info { color: var(--lux-navy); background: rgba(156, 200, 216, 0.2); border-color: rgba(156, 200, 216, 0.5); }
.lux-badge.danger { color: var(--pr-danger); background: rgba(138, 58, 58, 0.1); border-color: rgba(138, 58, 58, 0.3); }

/* Utilities */
.text-center { text-align: center; }
.text-danger { color: var(--pr-danger); }
.text-success { color: var(--lux-sage); }
.text-gold { color: var(--lux-gold); }
.text-navy { color: var(--lux-navy); }
.text-muted { color: var(--lux-muted); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mt-5 { margin-top: 3rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.mb-5 { margin-bottom: 3rem; }

/* Modals */
.lux-modal-backdrop {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(16, 36, 62, 0.4); /* Dark Navy overlay */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; } to { opacity: 1; }
}

/* ==========================================================================
   iPhone & Mobile Responsive System (375px, 390px, 393px, 430px)
   ========================================================================== */

/* Universal Box & Overflow Safety */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    max-width: 100vw;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* Touch Targets: minimum 44px for interactive controls */
.pr-btn,
.quick-action-btn,
.pr-sidebar-link,
button,
input[type="button"],
input[type="submit"],
input[type="reset"] {
    min-height: 44px;
}

/* iOS Safari Safe Area Padding & Dynamic Viewport Height */
:root {
    --sat: env(safe-area-inset-top, 0px);
    --sar: env(safe-area-inset-right, 0px);
    --sab: env(safe-area-inset-bottom, 0px);
    --sal: env(safe-area-inset-left, 0px);
}

body {
    padding-top: var(--sat);
    padding-bottom: var(--sab);
    min-height: 100dvh;
}

/* Responsive Container */
.pr-container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding-left: max(1.25rem, var(--sal));
    padding-right: max(1.25rem, var(--sar));
}

/* iPhone Responsive Breakpoints (< 768px & < 576px) */
@media (max-width: 768px) {
    /* Prevent iOS Safari Auto-Zoom on Input Focus */
    input, select, textarea, .pr-input {
        font-size: 16px !important;
        min-height: 44px;
    }
    
    .lux-title {
        font-size: 1.75rem;
        line-height: 1.25;
    }
    
    .lux-subtitle {
        font-size: 0.95rem;
        margin-bottom: 1.25rem;
    }
    
    .pr-card {
        padding: 1.5rem 1.25rem;
        border-radius: 22px;
        margin-bottom: 1.25rem;
    }
}

@media (max-width: 576px) {
    .pr-card {
        padding: 1.25rem 1rem;
        border-radius: 18px;
        margin-bottom: 1rem;
    }
    
    .lux-title {
        font-size: 1.5rem;
    }
    
    .pr-btn {
        width: 100%;
        padding: 0.75rem 1.25rem;
    }
    
    /* Responsive Modals */
    .lux-modal-backdrop, .pr-modal {
        padding: 0.5rem;
    }
    
    .pr-modal-content, .lux-modal-content {
        width: 94vw !important;
        max-width: 100% !important;
        max-height: 88dvh !important;
        overflow-y: auto !important;
        padding: 1.25rem 1rem !important;
        border-radius: 20px !important;
        margin: auto !important;
    }
}

@media (max-width: 768px) {
    body {
        padding: 0;
        margin: 0;
        overflow-x: hidden;
    }
    .pr-container {
        padding: 0.4rem 0.85rem !important;
        max-width: 100% !important;
    }
    .pr-card {
        padding: 1.25rem 1rem !important;
        margin-bottom: 1rem !important;
        border-radius: 22px !important;
    }
    .ios-bottom-tab-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 9999;
        height: calc(64px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: rgba(255, 255, 255, 0.92);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid rgba(0, 0, 0, 0.08);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
        justify-content: space-around;
        align-items: center;
    }

    .ios-tab-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        height: 100%;
        color: #64748B;
        text-decoration: none;
        background: transparent;
        border: none;
        padding: 0;
        font-family: inherit;
        font-size: 0.72rem;
        font-weight: 500;
        gap: 3px;
        transition: color 0.2s ease, transform 0.15s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .ios-tab-item i {
        font-size: 1.25rem;
        transition: transform 0.2s ease;
    }

    .ios-tab-item.active {
        color: #C5A467;
        font-weight: 700;
    }

    .ios-tab-item.active i {
        transform: scale(1.1);
        color: #C5A467;
    }

    .ios-tab-item:active {
        transform: scale(0.92);
        opacity: 0.8;
    }
}

/* ==========================================================================
   Luxury Clinic Booking Form Theme (Matching Navy & Gold Brand)
   ========================================================================== */

.booking-field-group {
    margin-bottom: 1.25rem;
    text-align: right;
    width: 100%;
}

.booking-field-label {
    font-size: 0.95rem;
    font-weight: 700;
    color: #11223F;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.gold-bullet {
    color: #C5A467;
    font-size: 1.2rem;
    line-height: 1;
}

.booking-select-wrapper {
    position: relative;
    width: 100%;
    display: block;
}

.booking-custom-select {
    width: 100% !important;
    height: 52px !important;
    background: #FFFFFF !important;
    border: 1.5px solid #E2E8F0 !important;
    border-radius: 16px !important;
    padding: 0 42px 0 16px !important;
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    color: #11223F !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    box-shadow: 0 2px 8px rgba(17, 34, 63, 0.04) !important;
    font-family: inherit !important;
    transition: all 0.2s ease !important;
    cursor: pointer;
    box-sizing: border-box !important;
}

.booking-custom-select:focus {
    outline: none !important;
    border-color: #C5A467 !important;
    box-shadow: 0 0 0 4px rgba(197, 164, 103, 0.15) !important;
}

.select-chevron {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #C5A467;
    pointer-events: none;
    font-size: 1rem;
    z-index: 2;
}

/* Time Grid 4 Columns - Single Screen Viewport Fit */
.time-grid-4col {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-top: 4px;
    width: 100%;
    max-height: 145px;
    overflow-y: auto;
    padding: 2px 2px 4px 2px;
    -webkit-overflow-scrolling: touch;
}

.time-grid-4col::-webkit-scrollbar {
    width: 4px;
}
.time-grid-4col::-webkit-scrollbar-track {
    background: #F1EFEA;
    border-radius: 4px;
}
.time-grid-4col::-webkit-scrollbar-thumb {
    background: #C5A467;
    border-radius: 4px;
}

.time-grid-4col .time-slot {
    padding: 6px 3px !important;
    border-radius: 10px !important;
    font-size: 0.78rem !important;
    font-weight: 700 !important;
    border: 1.5px solid #E2E8F0 !important;
    background: #FFFFFF !important;
    color: #11223F !important;
    box-shadow: 0 1px 3px rgba(17, 34, 63, 0.03) !important;
    text-align: center;
    cursor: pointer;
    min-height: 32px !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.1;
    transition: all 0.15s ease;
}

.time-grid-4col .time-slot:hover {
    border-color: #C5A467 !important;
    transform: translateY(-1px);
}

.time-grid-4col .time-slot.selected {
    background: linear-gradient(135deg, #C5A467 0%, #A8833E 100%) !important;
    color: #FFFFFF !important;
    border-color: #C5A467 !important;
    box-shadow: 0 4px 12px rgba(197, 164, 103, 0.35) !important;
}

.time-grid-4col .time-slot.selected .slot-time-text {
    color: #FFFFFF !important;
}

.time-grid-4col .time-slot.booked {
    background: #F8FAFC !important;
    border-color: #E2E8F0 !important;
    color: #94A3B8 !important;
    opacity: 0.6 !important;
    cursor: not-allowed !important;
}

.time-grid-4col .time-slot.admin_blocked {
    background: #FEF2F2 !important;
    border-color: #FECACA !important;
    color: #DC2626 !important;
    opacity: 0.65 !important;
    cursor: not-allowed !important;
}

/* Modern Luxury Segmented Switches */
.booking-segmented-control {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 4px;
    background: #F1EFEA;
    border-radius: 14px;
}

.booking-segmented-btn {
    border: none;
    background: transparent;
    color: #64748B;
    font-weight: 700;
    font-size: 0.84rem;
    border-radius: 10px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.booking-segmented-btn.active {
    background: #FFFFFF !important;
    color: #11223F !important;
    font-weight: 800 !important;
    box-shadow: 0 2px 8px rgba(17, 34, 63, 0.08) !important;
    border: 1px solid rgba(197, 164, 103, 0.35) !important;
}

.booking-segmented-btn.active i {
    color: #C5A467 !important;
}

.mode-segmented-btn {
    border: none;
    background: transparent;
    color: #64748B;
    font-weight: 700;
    font-size: 0.8rem;
    border-radius: 8px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.mode-segmented-btn.active {
    background: #FFFFFF !important;
    color: #11223F !important;
    font-weight: 800 !important;
    box-shadow: 0 2px 6px rgba(17, 34, 63, 0.08) !important;
    border: 1px solid rgba(197, 164, 103, 0.35) !important;
}

.mode-segmented-btn.active i {
    color: #C5A467 !important;
}

@media (max-width: 480px) {
    .time-grid-4col {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 5px !important;
    }
    .time-grid-4col .time-slot {
        padding: 6px 2px !important;
        font-size: 0.76rem !important;
    }
}

@media (max-width: 360px) {
    .time-grid-4col {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 4px !important;
    }
    .time-grid-4col .time-slot {
        padding: 6px 2px !important;
        font-size: 0.74rem !important;
    }
}

/* ==========================================================================
   Universal Mobile Responsiveness & Touch Optimization
   Compatible with all mobile screens: iPhone SE, iPhone 12/13/14/15/16 Pro/Max/Plus,
   Samsung Galaxy, Xiaomi, Pixel, OnePlus (320px - 768px+)
   ========================================================================== */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
    box-sizing: border-box;
}

*, *::before, *::after {
    box-sizing: inherit;
}

body {
    min-height: 100%;
    min-height: 100dvh;
    overflow-x: hidden;
    width: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Ensure images, svgs, and embeds scale fluidly */
img, svg, video, canvas, audio, iframe, embed, object {
    max-width: 100%;
    height: auto;
}

/* Prevent unwanted horizontal overflow on containers */
.pr-container, .container, .admin-layout, .admin-main {
    max-width: 100vw;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-break: break-word;
}

@media (max-width: 768px) {
    /* Critical iOS Safari auto-zoom prevention on form controls */
    input[type="text"],
    input[type="tel"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="date"],
    select,
    textarea,
    .pr-input,
    .booking-custom-select,
    .form-control {
        font-size: 16px !important; /* Prevents auto-zoom on iOS */
    }

    /* iOS Native Active Touch Press Feedback for All Buttons & Cards */
    .pr-btn:active,
    .quick-action-btn:active,
    .pr-card:active,
    .admin-nav a:active {
        transform: scale(0.97) !important;
        opacity: 0.92;
        transition: transform 0.1s ease, opacity 0.1s ease;
    }

    /* Content Padding Offset for Mobile Bottom Bar & Safe Areas */
    body {
        padding-bottom: calc(75px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .admin-main {
        padding-bottom: calc(75px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Mobile Modal Windows: Perfectly fitted to 88dvh with safe-area padding */
    .lux-modal-backdrop, .pr-modal, .modal {
        padding: max(0.5rem, env(safe-area-inset-top, 0px)) max(0.5rem, env(safe-area-inset-right, 0px)) max(0.5rem, env(safe-area-inset-bottom, 0px)) max(0.5rem, env(safe-area-inset-left, 0px)) !important;
        align-items: center !important;
        justify-content: center !important;
        box-sizing: border-box !important;
    }

    .lux-modal-backdrop.active,
    .lux-modal-backdrop[style*="display: flex"],
    .pr-modal.active,
    .pr-modal[style*="display: flex"] {
        display: flex !important;
    }

    .lux-modal-backdrop[style*="display: none"],
    .pr-modal[style*="display: none"],
    .lux-modal[style*="display: none"],
    .modal[style*="display: none"],
    [style*="display: none"] {
        display: none !important;
    }

    .lux-modal-content, 
    .pr-modal-content, 
    .modal-content,
    .lux-modal-backdrop > .pr-card,
    #confirm-modal .pr-card,
    .lux-modal-backdrop > div,
    .pr-modal > div {
        width: min(94vw, 540px) !important;
        max-width: 94vw !important;
        max-height: calc(88dvh) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 1.25rem 1rem !important;
        border-radius: 20px !important;
        margin: auto !important;
        box-sizing: border-box !important;
    }

    /* Touch target comfort */
    .pr-btn, .lux-btn, .booking-nav-btn {
        min-height: 48px;
        touch-action: manipulation;
    }
}

/* Screen width <= 480px (Standard Smartphones & iPhone 13/14/15/16 Pro) */
@media (max-width: 480px) {
    .pr-container {
        padding-left: max(0.6rem, env(safe-area-inset-left, 0px)) !important;
        padding-right: max(0.6rem, env(safe-area-inset-right, 0px)) !important;
    }

    .pr-card {
        padding: 1.15rem 0.85rem !important;
        border-radius: 18px !important;
    }

    .time-grid-4col {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }

    .time-grid-4col .time-slot {
        padding: 10px 4px !important;
        font-size: 0.82rem !important;
    }

    .flatpickr-calendar {
        max-width: calc(100vw - 24px) !important;
        margin: 0 auto !important;
    }
}

/* Screen width <= 360px (iPhone SE, compact Androids) */
@media (max-width: 360px) {
    .time-grid-4col {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 6px !important;
    }

    .time-grid-4col .time-slot {
        padding: 8px 3px !important;
        font-size: 0.78rem !important;
    }

    .lux-btn, .pr-btn {
        padding: 0.65rem 0.75rem !important;
        font-size: 0.85rem !important;
    }
    
    .pr-card {
        padding: 1rem 0.65rem !important;
    }
}

/* ========================================================
   LONDON BANKING LUXURY REDESIGN STYLES
   ======================================================== */

/* 3-Step Banking Stepper */
.bank-stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #FAF8F5;
    border: 1.5px solid #EDE8DF;
    border-radius: 16px;
    padding: 7px 14px;
    margin-bottom: 0.75rem;
}
.bank-step {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    font-weight: 700;
    color: #94A3B8;
    cursor: pointer;
    transition: all 0.2s ease;
}
.bank-step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 800;
    background: #E2E8F0;
    color: #64748B;
    transition: all 0.2s ease;
}
.bank-step.active {
    color: #11223F;
    font-weight: 800;
}
.bank-step.active .bank-step-num {
    background: #11223F;
    color: #FFFFFF;
    box-shadow: 0 2px 8px rgba(17, 34, 63, 0.2);
}
.bank-step.completed {
    color: #059669;
}
.bank-step.completed .bank-step-num {
    background: #10B981;
    color: #FFFFFF;
}
.bank-stepper-line {
    flex: 1;
    height: 2px;
    background: #E2E8F0;
    margin: 0 8px;
    border-radius: 2px;
}
.bank-stepper-line.completed {
    background: #10B981;
}

/* Category Switcher Tabs */
.bank-cat-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    background: #F1EFEA;
    padding: 4px;
    border-radius: 14px;
    margin-bottom: 0.75rem;
}
.bank-cat-btn {
    border: none;
    background: transparent;
    padding: 8px 10px;
    border-radius: 11px;
    font-size: 0.82rem;
    font-weight: 800;
    color: #64748B;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    cursor: pointer;
    transition: all 0.2s ease;
}
/* Blue for therapy */
.bank-cat-btn.cat-therapy.active {
    background: #1E3A8A;
    color: #FFFFFF;
    box-shadow: 0 3px 10px rgba(30, 58, 138, 0.25);
}
/* Purple for Hijama */
.bank-cat-btn.cat-hijama.active {
    background: #6D28D9;
    color: #FFFFFF;
    box-shadow: 0 3px 10px rgba(109, 40, 217, 0.25);
}

/* Royal Blue Outstanding Unpaid Balance Card */
.bank-unpaid-card {
    background: linear-gradient(135deg, #0F172A 0%, #1E3A8A 100%);
    border: 1.5px solid #2563EB;
    border-radius: 16px;
    padding: 0.85rem 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    box-shadow: 0 4px 18px rgba(30, 58, 138, 0.22);
}
.bank-unpaid-amount {
    color: #FBBF24;
    font-size: 1.35rem;
    font-weight: 900;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.35);
    letter-spacing: -0.2px;
}

/* Service Card List / Grid */
.bank-service-card {
    background: #FFFFFF;
    border: 1.5px solid #EDE8DF;
    border-radius: 14px;
    padding: 0.75rem 0.95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 6px;
}
.bank-service-card:hover {
    border-color: #C5A467;
    background: #FDFCF9;
}
.bank-service-card.selected {
    background: #EFF6FF;
    border: 2px solid #1E3A8A;
    box-shadow: 0 3px 12px rgba(30, 58, 138, 0.15);
}
.bank-service-card.selected .bank-service-title {
    color: #1E3A8A;
    font-weight: 800;
}

/* Time Slot Periods Filters (Pagination without scroll) */
.time-period-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
    background: #F1EFEA;
    padding: 3px;
    border-radius: 12px;
}
.time-period-btn {
    flex: 1;
    background: transparent;
    border: none;
    border-radius: 10px;
    padding: 5px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748B;
    cursor: pointer;
    transition: all 0.15s ease;
}
.time-period-btn.active {
    background: #FFFFFF;
    color: #11223F;
    font-weight: 800;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

/* Green Action Button */
.bank-btn-action-green {
    width: 100%;
    height: 48px;
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #FFFFFF;
    border: none;
    border-radius: 14px;
    font-weight: 800;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(5, 150, 105, 0.28);
    transition: all 0.2s ease;
}
.bank-btn-action-green:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(5, 150, 105, 0.35);
}
.bank-btn-action-green:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

/* ========================================================
   PORTRAIT MODE & SMARTPHONE VIEWPORT PERFECTION
   ======================================================== */
@media screen and (max-width: 640px), screen and (orientation: portrait) and (max-width: 900px) {
    /* Complete Viewport Lock: Page absolutely does not drag or bounce */
    html.booking-app-html,
    html {
        height: 100% !important;
        height: 100dvh !important;
        overflow: hidden !important;
        overscroll-behavior: none !important;
        overscroll-behavior-y: none !important;
    }

    body.booking-app-body,
    body {
        height: 100% !important;
        height: 100dvh !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        overscroll-behavior: none !important;
        overscroll-behavior-y: none !important;
        display: flex !important;
        flex-direction: column !important;
        touch-action: pan-x pan-y !important;
    }

    /* Container fills portrait screen with generous bottom clearance for Safari URL bar */
    body.booking-app-body .pr-container {
        flex: 1 !important;
        height: 100% !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: max(4px, env(safe-area-inset-top, 4px)) 10px calc(env(safe-area-inset-bottom, 0px) + 74px) 10px !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }

    /* Hide redundant banners on mobile portrait */
    body.booking-app-body .pr-container > a[href="/my-booking.php"],
    body.booking-app-body footer {
        display: none !important;
    }

    /* Sleek Topbar in Portrait Mode with NO word wrapping */
    .bank-mobile-topbar {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 4px !important;
        height: 38px !important;
        min-height: 38px !important;
        margin-bottom: 0.25rem !important;
        flex-shrink: 0 !important;
    }
    .bank-desktop-header {
        display: none !important;
    }
    .topbar-side {
        display: flex !important;
        align-items: center !important;
        gap: 3px !important;
        flex-shrink: 0 !important;
    }
    .topbar-side button,
    .topbar-side a,
    .topbar-pill {
        white-space: nowrap !important;
        padding: 0.22rem 0.52rem !important;
        font-size: 0.74rem !important;
        line-height: 1 !important;
        flex-shrink: 0 !important;
    }
    .topbar-right { justify-content: flex-start !important; }
    .topbar-left { justify-content: flex-end !important; }
    .topbar-center {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 5px !important;
        flex: 1 !important;
        min-width: 0 !important;
    }
    .header-brand-title {
        font-size: 0.82rem !important;
        font-weight: 800 !important;
        white-space: nowrap !important;
        color: #11223F !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    /* Card fills portrait space and ends above the Safari address bar */
    body.booking-app-body #booking-section.pr-card {
        flex: 1 !important;
        height: 100% !important;
        min-height: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0.65rem 0.85rem !important;
        border-radius: 18px !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        box-sizing: border-box !important;
        box-shadow: 0 4px 18px rgba(17, 34, 63, 0.08) !important;
        overflow: hidden !important;
    }
    body.booking-app-body #booking-section.pr-card::-webkit-scrollbar {
        display: none !important;
    }

    /* Form inside card */
    #booking-form {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 !important;
        min-height: 0 !important;
        justify-content: flex-start !important;
        margin: 0 !important;
    }

    /* Wizard Substeps: ONLY active step is displayed! */
    .wizard-substep {
        display: none !important;
        flex-direction: column !important;
        flex: 1 !important;
        min-height: 0 !important;
        justify-content: flex-start !important;
    }
    .wizard-substep.active {
        display: flex !important;
    }

    /* Stepper in Portrait Mode */
    .bank-stepper {
        padding: 4px 8px !important;
        margin-bottom: 0.45rem !important;
        border-radius: 12px !important;
        flex-shrink: 0 !important;
    }
    .bank-step {
        gap: 4px !important;
        font-size: 0.82rem !important;
        font-weight: 800 !important;
    }
    .bank-step-num {
        width: 24px !important;
        height: 24px !important;
        font-size: 0.8rem !important;
        font-weight: 900 !important;
    }

    /* Enlarged Category Switcher (الخدمات العلاجية و حجامة نبوية) */
    .bank-cat-toggle {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 6px !important;
        background: #F1EFEA !important;
        border: 1.5px solid #E2D9CC !important;
        border-radius: 14px !important;
        padding: 4px !important;
        margin-bottom: 0.65rem !important;
        height: 52px !important;
        min-height: 52px !important;
        flex-shrink: 0 !important;
    }
    .bank-cat-btn {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 7px !important;
        height: 100% !important;
        font-size: 0.94rem !important;
        font-weight: 900 !important;
        border-radius: 11px !important;
        border: none !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
    }
    .bank-cat-btn i {
        font-size: 1.15rem !important;
    }
    .bank-cat-btn.cat-therapy.active {
        background: linear-gradient(135deg, #1E3A8A 0%, #11223F 100%) !important;
        color: #FFFFFF !important;
        box-shadow: 0 4px 12px rgba(30, 58, 138, 0.3) !important;
    }
    .bank-cat-btn.cat-hijama.active {
        background: linear-gradient(135deg, #7C3AED 0%, #581C87 100%) !important;
        color: #FFFFFF !important;
        box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3) !important;
    }

    /* Enlarged Inputs and Selects (اختر الخدمة العلاجية) */
    .booking-custom-select, .pr-input {
        height: 52px !important;
        min-height: 52px !important;
        font-size: 1.02rem !important;
        font-weight: 900 !important;
        border-radius: 14px !important;
        border: 2px solid #CBD5E1 !important;
        color: #11223F !important;
    }

    /* Enlarged Package Promo Box */
    .bank-promo-box {
        min-height: 52px !important;
        padding: 0.65rem 0.9rem !important;
        margin-bottom: 0.65rem !important;
        border-radius: 14px !important;
        flex-shrink: 0 !important;
    }

    /* Enlarged Unpaid Balance Reminder Card */
    .bank-unpaid-card {
        min-height: 56px !important;
        padding: 0.75rem 1rem !important;
        margin-bottom: 0.65rem !important;
        border-radius: 16px !important;
        flex-shrink: 0 !important;
    }

    /* Attendance Mode */
    .mode-segmented-btn {
        font-size: 0.9rem !important;
        font-weight: 900 !important;
    }

    /* Time Slots Grid (Non-scrollable, prominent 3-column layout) */
    .time-slots-grid, #time-grid {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 7px !important;
        overflow: hidden !important;
        max-height: none !important;
        padding: 2px !important;
        margin-top: 2px !important;
    }

    /* Time Slot Boxes */
    .time-slot {
        height: 48px !important;
        min-height: 48px !important;
        padding: 2px 4px !important;
        border-radius: 12px !important;
        border: 2px solid #CBD5E1 !important;
        background: #FFFFFF !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04) !important;
    }

    .time-slot .slot-time-text {
        font-size: 1.1rem !important;
        font-weight: 900 !important;
        color: #11223F !important;
        line-height: 1.1 !important;
    }

    .time-slot.selected {
        background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
        border-color: #047857 !important;
        box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3) !important;
    }
    .time-slot.selected .slot-time-text {
        color: #FFFFFF !important;
    }

    .time-slot.booked, .time-slot.admin_blocked {
        background: #F8FAFC !important;
        border-color: #E2E8F0 !important;
        opacity: 0.55 !important;
    }
    .time-slot.booked .slot-time-text,
    .time-slot.admin_blocked .slot-time-text {
        color: #94A3B8 !important;
        font-size: 1rem !important;
        text-decoration: line-through !important;
    }

    /* Prominent Action Buttons Raised Safely Above Safari URL Bar */
    .bank-btn-action-green {
        height: 50px !important;
        min-height: 50px !important;
        font-size: 1.08rem !important;
        font-weight: 900 !important;
        border-radius: 14px !important;
        flex-shrink: 0 !important;
    }
}


    /* Registration Step Mobile Layout (Elevated above Safari URL bar) */
    #step-register {
        height: 100% !important;
        min-height: 0 !important;
        flex: 1 1 auto !important;
    }
    #step-register.active {
        display: flex !important;
        flex-direction: column !important;
    }
    #step-register form {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        height: 100% !important;
    }
    #step-register .reg-actions-row {
        margin-top: auto !important;
        flex-shrink: 0 !important;
        padding-top: 0.6rem !important;
        padding-bottom: 2px !important;
    }


/* Therapeutic Service Selection 2-Column Grid */
.therapy-services-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
    padding: 2px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.therapy-service-card {
    position: relative;
    background: #FFFFFF;
    border: 1.5px solid #CBD5E1;
    border-radius: 13px;
    padding: 0.65rem 0.65rem;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    transition: all 0.18s ease;
    box-shadow: 0 2px 5px rgba(15, 23, 42, 0.03);
    font-family: inherit;
    color: #0F172A;
    outline: none;
}
.therapy-service-card:hover {
    border-color: #2E8B6E;
    background: #F8FAFC;
}
.therapy-service-card:active {
    transform: scale(0.98);
}
.therapy-service-card.selected {
    background: #EAF7F2 !important;
    border: 2px solid #2E8B6E !important;
    color: #064E3B !important;
    box-shadow: 0 4px 12px rgba(46, 139, 110, 0.15) !important;
}
.therapy-service-card .therapy-service-card-name {
    font-size: 0.92rem;
    font-weight: 800;
    line-height: 1.3;
    color: inherit;
    display: block;
    width: 100%;
}
.therapy-service-card .service-check-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #2E8B6E;
    color: #FFFFFF;
    font-size: 0.6rem;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(46, 139, 110, 0.25);
}
.therapy-service-card.selected .service-check-badge {
    display: inline-flex !important;
}

@media screen and (max-width: 640px), screen and (orientation: portrait) and (max-width: 900px) {
    .therapy-services-grid {
        gap: 7px !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        padding-bottom: 4px !important;
    }
    .therapy-service-card {
        min-height: 44px !important;
        padding: 0.42rem 0.5rem !important;
        border-radius: 11px !important;
    }
    .therapy-service-card .therapy-service-card-name {
        font-size: 0.85rem !important;
        font-weight: 800 !important;
        line-height: 1.25 !important;
    }
    body.booking-app-body #booking-section.pr-card {
        overflow-y: auto !important;
    }
}

/* Ensure warning and empty state cards inside #time-grid always span all columns */
#time-grid > div:not(.time-slot):not(.skeleton-slot),
.existing-appt-warning-box {
    grid-column: 1 / -1 !important;
    width: 100% !important;
}
