/* ============================================
   Modal Styles (Desktop & All Screens)
   ============================================ */

   .modal {
    display: none;
    position: fixed;
    z-index: 1002;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow: auto;
    padding: 20px 0;
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    overflow: hidden;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-top: 20px;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-body {
    overflow-y: auto;
    flex: 1;
    padding: 0;
}

.calendly-inline-widget {
    min-height: 700px;
    height: 700px;
    width: 100%;
    display: block;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6b7280;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #1f2937;
}

/* ============================================
   Responsive Design
   ============================================ */

/* Prevent background scroll when mobile menu is open (iOS fix) */
body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Tablet Screens (768px and below) */
@media (max-width: 768px) {
    :root {
        --font-size-4xl: 2.5rem;
        --font-size-3xl: 2rem;
        --spacing-2xl: 3rem;
        --spacing-xl: 2rem;
    }

    /* Navigation – menu below header so hamburger stays tappable on iOS */
    .nav-menu {
        position: fixed;
        left: -110%;
        top: calc(72px + env(safe-area-inset-top, 0px));
        bottom: 0;
        width: 100%;
        height: auto;
        min-height: calc(100vh - 72px - env(safe-area-inset-top, 0px));
        flex-direction: column;
        background-color: #0d2438;
        text-align: center;
        transition: left 0.3s ease;
        -webkit-overflow-scrolling: touch;
        overflow-y: auto;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        gap: 0;
        padding: var(--spacing-lg) 0;
        z-index: 999;
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-link {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: var(--spacing-md) var(--spacing-lg);
        min-height: 44px;
        box-sizing: border-box;
        color: #ffffff !important;
        -webkit-text-fill-color: #ffffff !important;
        border: none;
        touch-action: manipulation;
    }

    .nav-link:hover,
    .nav-link:active,
    .nav-link:focus {
        background-color: #1a4d7a;
        border: none;
        color: #ffffff !important;
        -webkit-text-fill-color: #ffffff !important;
    }

    .nav-link-cta {
        margin: var(--spacing-md) var(--spacing-lg);
        width: calc(100% - var(--spacing-lg) * 2);
        background-color: #c62828;
        color: #ffffff !important;
        -webkit-text-fill-color: #ffffff !important;
    }
    
    .nav-link-cta:hover,
    .nav-link-cta:active {
        background-color: #b71c1c;
        color: #ffffff !important;
        -webkit-text-fill-color: #ffffff !important;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .mobile-menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(8px, 8px);
    }

    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .mobile-menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -7px);
    }

    /* Hero Section */
    .hero-content {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }

    .hero-text h1 {
        font-size: var(--font-size-3xl);
    }

    .hero-subtitle {
        font-size: var(--font-size-base);
    }

    .hero-cta {
        flex-direction: column;
    }

    .hero-cta .btn {
        width: 100%;
    }

    /* About Section */
    .about-content {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }

    .about-image {
        order: -1;
    }

    /* Services Grid */
    .services-grid {
        grid-template-columns: 1fr;
    }

    /* Testimonials Grid */
    .testimonial-grid {
        grid-template-columns: 1fr;
    }

    /* Value Grid */
    .value-grid {
        grid-template-columns: 1fr;
    }

    /* Resources Grid */
    .resources-grid {
        grid-template-columns: 1fr;
    }

    /* Footer Grid */
    .footer-content {
        grid-template-columns: 1fr;
    }

    .footer-bottom {
        text-align: center;
    }

    .footer-legal {
        flex-direction: column;
        gap: var(--spacing-sm);
    }

    /* Modal - Tablet adjustments */
    .modal-content {
        width: 95%;
        max-height: 85vh;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-close {
        font-size: 1.25rem;
    }

    .calendly-inline-widget {
        min-height: 600px;
    }

    /* Buttons */
    .btn-large {
        padding: var(--spacing-md) var(--spacing-lg);
    }

    /* Spacing adjustments */
    section {
        padding: var(--spacing-xl) 0;
    }

    .container {
        padding: 0 var(--spacing-md);
    }

    h1 {
        font-size: var(--font-size-3xl);
    }

    h2 {
        font-size: var(--font-size-2xl);
        margin-bottom: var(--spacing-lg);
    }

    h3 {
        font-size: var(--font-size-lg);
    }
}

/* Mobile Screens (480px and below) */
@media (max-width: 480px) {
    :root {
        --font-size-4xl: 2rem;
        --font-size-3xl: 1.625rem;
        --font-size-2xl: 1.5rem;
        --spacing-2xl: 2rem;
        --spacing-xl: 1.5rem;
        --spacing-lg: 1.5rem;
    }

    /* Header */
    .navbar {
        min-height: 56px !important;
        padding: var(--spacing-md);
    }

    .logo-text {
        font-size: var(--font-size-base);
    }

    /* Hero */
    .hero {
        padding: var(--spacing-xl) 0;
    }

    .hero-text h1 {
        font-size: var(--font-size-2xl);
        line-height: 1.2;
        margin-bottom: var(--spacing-md);
    }

    .hero-subtitle {
        font-size: var(--font-size-sm);
        margin-bottom: var(--spacing-lg);
    }

    .hero-cta {
        gap: var(--spacing-sm);
    }

    .headshot {
        max-width: 100%;
    }

    /* Value Cards */
    .value-card {
        padding: var(--spacing-lg);
    }

    .card-icon {
        font-size: 2rem;
    }

    /* Service Cards */
    .service-card {
        padding: var(--spacing-lg);
    }

    .service-topics {
        gap: var(--spacing-xs);
    }

    .topic-tag {
        font-size: var(--font-size-xs);
        padding: var(--spacing-xs) var(--spacing-sm);
    }

    /* About */
    .about-headshot {
        max-width: 100%;
    }

    .about-credentials {
        padding: var(--spacing-md);
    }

    /* Testimonial */
    .testimonial-card {
        padding: var(--spacing-md);
    }

    /* CTA Section */
    .cta-section h2 {
        font-size: var(--font-size-2xl);
    }

    .cta-section p {
        font-size: var(--font-size-base);
    }

    /* Footer */
    .footer-section h3,
    .footer-section h4 {
        font-size: var(--font-size-base);
    }

    .footer-social {
        justify-content: center;
        gap: var(--spacing-md);
    }

    /* Modal - Mobile adjustments */
    .modal {
        padding: 10px 0;
    }

    .modal-content {
        width: 98%;
        max-height: 80vh;
        margin-top: 10px;
    }

    .modal-header {
        padding: 12px;
    }

    .modal-close {
        font-size: 1.25rem;
        width: 28px;
        height: 28px;
    }

    .calendly-inline-widget {
        min-height: 500px;
    }

    /* Buttons */
    .btn {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: var(--font-size-sm);
    }

    .btn-large {
        width: 100%;
    }

    /* Spacing */
    section {
        padding: var(--spacing-lg) 0;
    }

    .container {
        padding: 0 var(--spacing-md);
    }

    h1 {
        font-size: var(--font-size-2xl);
    }

    h2 {
        font-size: var(--font-size-xl);
    }

    p {
        font-size: var(--font-size-sm);
    }

    .value-grid,
    .services-grid,
    .testimonial-grid,
    .resources-grid {
        gap: var(--spacing-md);
    }
}

/* Small Mobile Screens (320px and below) */
@media (max-width: 320px) {
    :root {
        --font-size-lg: 1rem;
        --font-size-xl: 1.25rem;
        --spacing-lg: 1rem;
        --spacing-md: 1rem;
    }

    .logo-text {
        font-size: var(--font-size-sm);
    }

    .nav-menu {
        top: 60px;
    }

    .hero-text h1 {
        font-size: 1.5rem;
    }

    .container {
        padding: 0 var(--spacing-sm);
    }

    .btn {
        padding: var(--spacing-xs) var(--spacing-sm);
    }

    .service-card,
    .value-card,
    .testimonial-card {
        padding: var(--spacing-md);
    }

    /* Modal - Small mobile adjustments */
    .modal-content {
        width: 100%;
        max-height: 75vh;
    }

    .modal-header {
        padding: 10px;
    }

    .calendly-inline-widget {
        min-height: 400px;
    }
}

/* Print Styles */
@media print {
    .header,
    .footer,
    .modal,
    .hero-cta {
        display: none;
    }

    body {
        font-size: 12pt;
        line-height: 1.5;
    }

    a {
        text-decoration: underline;
    }

    section {
        page-break-inside: avoid;
    }
}

/* Dark mode: keep header and content readable on iOS/small screens – force light UI */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #ffffff !important;
        color: #1a1a1a !important;
    }

    .header {
        background-color: #ffffff !important;
        border-bottom-color: #e9ecef;
    }

    .header .logo-text {
        color: #1a1a1a !important;
        -webkit-text-fill-color: #1a1a1a;
    }

    /* Header bar nav links (desktop) – dark text on light header */
    .header .navbar .nav-link {
        color: #1a1a1a !important;
        -webkit-text-fill-color: #1a1a1a;
    }

    /* Mobile menu panel: always white text on dark background for contrast */
    .nav-menu .nav-link {
        color: #ffffff !important;
        -webkit-text-fill-color: #ffffff !important;
    }
    .nav-menu .nav-link:hover,
    .nav-menu .nav-link:active,
    .nav-menu .nav-link:focus {
        color: #ffffff !important;
        -webkit-text-fill-color: #ffffff !important;
        background-color: #1a4d7a !important;
    }
    .nav-menu .nav-link-cta {
        background-color: #c62828 !important;
        color: #ffffff !important;
        -webkit-text-fill-color: #ffffff !important;
    }
    .nav-menu .nav-link-cta:hover,
    .nav-menu .nav-link-cta:active {
        background-color: #b71c1c !important;
        color: #ffffff !important;
        -webkit-text-fill-color: #ffffff !important;
    }

    .nav-link-cta {
        background-color: #c62828 !important;
        color: #ffffff !important;
        -webkit-text-fill-color: #ffffff;
    }

    .modal-content {
        background-color: #ffffff !important;
        color: #1a1a1a !important;
    }

    .modal-header {
        border-bottom-color: #e5e7eb;
    }

    .modal-close {
        color: #374151;
    }

    .modal-close:hover {
        color: #1f2937;
    }

    /* Keep content sections light so text stays readable */
    section {
        background-color: inherit;
    }

    .clinical-welcome,
    .clinical-approach,
    .clinical-faq,
    .clinical-practice-info .practice-section {
        background: #ffffff !important;
    }

    .clinical-specializations,
    .clinical-practice-info,
    .approach-card,
    .faq-item,
    .specialization-card {
        background: #f8f9fa !important;
    }
}

/* High DPI Screens */
@media (-webkit-min-device-pixel-ratio: 2),
       (min-resolution: 192dpi) {
    .headshot,
    .about-headshot {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }
}

/* Accessibility - High Contrast */
@media (prefers-contrast: more) {
    :root {
        --primary-dark: #000080;
        --primary-medium: #000080;
        --secondary: #008080;
        --accent: #ff0000;
        --text-dark: #000000;
        --bg-white: #ffffff;
    }

    .btn {
        border-width: 3px;
    }

    a {
        text-decoration: underline;
    }

    .modal-content {
        border: 3px solid #000000;
    }
}

/* ============================================
   iOS-Specific Fixes
   ============================================ */

/* Fix for iOS Safari color rendering issues */
@supports (-webkit-touch-callout: none) {
    /* iOS-specific styles */
    
    /* Force explicit colors on iOS to prevent transparency issues */
    .nav-menu {
        background-color: #0d2438 !important;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
    
    .nav-link {
        color: #ffffff !important;
        -webkit-text-fill-color: #ffffff;
    }
    
    .nav-link:hover,
    .nav-link:active,
    .nav-link:focus {
        color: #ffffff !important;
        -webkit-text-fill-color: #ffffff;
        background-color: #1a4d7a !important;
    }
    
    .nav-link-cta {
        background-color: #c62828 !important;
        color: #ffffff !important;
        -webkit-text-fill-color: #ffffff;
    }
    
    .nav-link-cta:hover,
    .nav-link-cta:active {
        background-color: #b71c1c !important;
        color: #ffffff !important;
        -webkit-text-fill-color: #ffffff;
    }
    
    /* Fix button colors on iOS – high contrast, explicit white text */
    .btn {
        -webkit-text-fill-color: currentColor;
    }
    
    .btn-primary {
        background-color: #c62828 !important;
        color: #ffffff !important;
        -webkit-text-fill-color: #ffffff;
    }
    
    .btn-secondary {
        background-color: #1f6b7a !important;
        color: #ffffff !important;
        -webkit-text-fill-color: #ffffff;
    }
    
    /* Fix link colors on iOS */
    a {
        -webkit-text-fill-color: currentColor;
    }
    
    /* Disable iOS tap highlight that can interfere with colors */
    * {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
    
    /* Fix form input colors on iOS – exclude radio/checkbox so they stay visible */
    input:not([type="radio"]):not([type="checkbox"]),
    textarea,
    select {
        -webkit-appearance: none;
        appearance: none;
    }

    /* Keep radio and checkbox visible on iOS with native appearance and touch-friendly size */
    input[type="radio"],
    input[type="checkbox"] {
        -webkit-appearance: auto;
        appearance: auto;
        min-width: 20px;
        min-height: 20px;
        width: 20px;
        height: 20px;
    }
}

/* Additional iOS Safari fixes for all screen sizes */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    /* Webkit/Safari specific fixes */
    
    /* Fix white text on white background issues */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    /* Ensure links maintain proper color */
    a:link {
        color: var(--secondary, #2b7a8f);
    }
    
    a:visited {
        color: var(--secondary, #2b7a8f);
    }
    
    a:hover {
        color: var(--primary-dark, #0d2438);
    }
}

/* iOS Dark Mode Override - Force light mode colors */
@media (prefers-color-scheme: dark) {
    @supports (-webkit-touch-callout: none) {
        /* Disable dark mode color scheme on iOS if causing issues */
        :root {
            color-scheme: light;
        }
        
        body {
            background-color: #ffffff !important;
            color: #1a1a1a !important;
        }
        
        .nav-menu {
            background-color: #0d2438 !important;
        }
        
        .nav-link {
            color: #ffffff !important;
        }
    }
}