/* Common Styles for Header, Navigation, and Footer */
:root {
    --primary: #4CAF50;
    --secondary: #8BC34A;
    --accent: #FFC107;
    --light: #F5F5F5;
    --dark: #333333;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
}

body {
    background-color: var(--light);
    color: var(--dark);
    line-height: 1.6;
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
}

/* Enhanced Sticky Header */
header {
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    position: -webkit-sticky !important; /* Safari support */
    position: sticky !important;
    top: 0 !important;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 9999 !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-bottom: 1px solid rgba(76, 175, 80, 0.1);
    will-change: transform, background-color, box-shadow;
    contain: layout style paint;
}

/* Scrolled state - more compact */
header.scrolled {
    background-color: rgba(255, 255, 255, 0.98);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.15);
    border-bottom-color: rgba(76, 175, 80, 0.2);
    transform: translateZ(0); /* Force hardware acceleration */
}

header.scrolled .header-container {
    padding: 10px 0;
}

header.scrolled .logo-image {
    width: 45px;
    height: 45px;
}

header.scrolled .logo-text {
    font-size: 20px;
}

/* Fallback for browsers without sticky support */
@supports not (position: sticky) {
    header {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
    }
    
    body {
        padding-top: 140px; /* Adjust based on header height */
    }
}

/* Add a subtle indicator when header is sticky/scrolled */
header.scrolled::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    opacity: 0.8;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: opacity 0.3s;
}

.logo:hover {
    opacity: 0.8;
}

.logo-image {
    width: 60px;
    height: 60px;
    margin-right: 10px;
    object-fit: contain;
}

.logo-text {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary);
}

/* Enhanced Navigation with Theme Colors */
nav {
    background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(248,249,250,0.95));
    backdrop-filter: blur(10px);
    border-radius: 25px;
    padding: 8px 0;
    margin-top: 15px;
    box-shadow: 0 4px 20px rgba(76, 175, 80, 0.1);
}

nav ul {
    display: flex;
    list-style: none;
    justify-content: center;
    margin: 0;
    padding: 0;
}

nav ul li {
    margin: 0 8px;
    position: relative;
}

nav ul li a {
    text-decoration: none;
    color: var(--dark);
    font-weight: 600;
    padding: 12px 20px;
    border-radius: 20px;
    transition: all 0.3s ease;
    display: block;
    position: relative;
    overflow: hidden;
}

nav ul li a:hover {
    color: #4CAF50;
    background: rgba(76, 175, 80, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.2);
}

/* Enhanced Dropdown Styles - Improved Reliability */
.dropdown {
    position: relative;
    display: inline-block;
}

/* Larger hover area for better UX */
.dropdown::after {
    content: '';
    position: absolute;
    top: 0;
    left: -10px;
    right: -10px;
    bottom: -15px;
    background: transparent;
    z-index: 998;
}

.dropdown-content {
    display: none;
    position: absolute;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(15px);
    min-width: 240px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    z-index: 10000 !important;
    top: calc(100% + 5px);
    left: 50%;
    transform: translateX(-50%);
    border: 1px solid rgba(76, 175, 80, 0.2);
    padding: 8px 0;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
}

/* Show dropdown on hover */
.dropdown:hover .dropdown-content {
    display: block;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

/* Keep dropdown visible when hovering over content */
.dropdown-content:hover {
    display: block;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.dropdown-content a {
    color: var(--dark);
    padding: 14px 20px;
    text-decoration: none;
    display: block;
    font-weight: 500;
    transition: all 0.2s ease;
    border-radius: 8px;
    margin: 2px 8px;
    position: relative;
    white-space: nowrap;
}

.dropdown-content a:hover {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.12), rgba(139, 195, 74, 0.08));
    color: #4CAF50;
    transform: translateX(3px);
    border-left: 3px solid #8BC34A;
}

/* Larger invisible bridge for better hover stability */
.dropdown::before {
    content: '';
    position: absolute;
    top: 100%;
    left: -20px;
    right: -20px;
    height: 15px;
    background: transparent;
    z-index: 999;
}

/* Active state for dropdowns */
.dropdown.active .dropdown-content {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

.dropdown.active > a::after {
    transform: rotate(180deg);
    color: #4CAF50;
}

/* Smooth animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.dropdown-content.show {
    animation: fadeInDown 0.2s ease-out;
}

/* Dropdown arrow styling */
.dropdown > a::after {
    content: " ▼";
    font-size: 0.75em;
    margin-left: 8px;
    color: #8BC34A;
    transition: all 0.2s ease;
    display: inline-block;
}

.dropdown:hover > a::after,
.dropdown.active > a::after {
    transform: rotate(180deg);
    color: #4CAF50;
}

/* Improved focus states for accessibility */
.dropdown > a:focus {
    outline: 2px solid #4CAF50;
    outline-offset: 2px;
    border-radius: 4px;
}

.dropdown-content a:focus {
    outline: 2px solid #4CAF50;
    outline-offset: -2px;
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.15), rgba(139, 195, 74, 0.1));
}

/* CTA Button Styles */
.cta-button {
    background-color: var(--primary);
    color: white;
    padding: 10px 20px;
    border-radius: 30px;
    font-weight: bold;
    text-decoration: none;
    margin-right: 10px;
    transition: background-color 0.3s;
    min-height: 44px;
    min-width: 44px;
}

.cta-button:hover {
    background-color: var(--secondary);
}

/* Footer Styles */
footer {
    background: linear-gradient(135deg, #2c1810, #3d2817);
    color: white;
    padding: 40px 0;
    text-align: center;
    margin-top: 60px;
}

.footer-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    margin-bottom: 30px;
}

.footer-col {
    flex: 1;
    min-width: 250px;
    margin-bottom: 30px;
}

.footer-col h3 {
    margin-bottom: 20px;
    color: var(--accent);
}

.footer-col ul {
    list-style: none;
}

.footer-col ul li {
    margin-bottom: 10px;
}

.footer-col ul li a {
    color: white;
    text-decoration: none;
    transition: color 0.3s;
}

.footer-col ul li a:hover {
    color: var(--accent);
}

/* iPad Responsive */
@media (max-width: 1024px) and (min-width: 769px) {
    .container {
        width: 92%;
    }
    
    .header-container {
        padding: 18px 0;
    }
    
    .header-container > div {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        justify-content: center;
    }
    
    .cta-button {
        padding: 12px 20px;
        font-size: 0.95rem;
        min-width: 160px;
        text-align: center;
        white-space: nowrap;
    }
    
    nav ul li a {
        padding: 11px 18px;
        font-size: 0.95rem;
    }
    
    .dropdown-content {
        min-width: 200px;
    }
}

/* Google Translate Widget Styling - Shine Pediatrics Style */
.translate-widget-container {
    margin-top: 30px;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 25px;
    text-align: right;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-direction: column;
    gap: 8px;
}

#google_translate_element {
    display: inline-block;
}

#google_translate_element .goog-te-combo {
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 13px;
    color: #333;
    outline: none;
    cursor: pointer;
    min-width: 140px;
    font-family: Arial, sans-serif;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' 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: right 8px center;
    background-size: 12px;
    padding-right: 30px;
}

#google_translate_element .goog-te-combo:hover {
    border-color: #999;
    background-color: #f8f9fa;
}

#google_translate_element .goog-te-combo:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
    background-color: white;
}

.translate-placeholder {
    color: #666;
    font-size: 13px;
    font-family: Arial, sans-serif;
}

.translate-powered-by {
    margin-top: 5px;
}

.translate-powered-by span {
    color: rgba(255, 255, 255, 0.7);
    font-size: 11px;
    font-family: Arial, sans-serif;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

/* Hide Google Translate banner and branding */
.goog-te-banner-frame {
    display: none !important;
}

body {
    top: 0 !important;
}

.goog-te-balloon-frame {
    display: none !important;
}

.goog-te-gadget {
    font-family: inherit !important;
}

.goog-te-gadget .goog-te-combo {
    margin: 0 !important;
}

/* Mobile responsive for translate widget */
@media (max-width: 768px) {
    .translate-widget-container {
        margin-top: 25px;
        padding-top: 20px;
    }
    
    #google_translate_element {
        margin-bottom: 12px;
    }
    
    #google_translate_element .goog-te-combo {
        min-width: 140px;
        font-size: 12px;
        padding: 7px 10px;
    }
    
    .translate-powered-by span {
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    #google_translate_element .goog-te-combo {
        min-width: 120px;
        font-size: 11px;
        padding: 6px 8px;
    }
}

/* Enhanced Mobile Responsive Navigation */
@media (max-width: 768px) {
    header {
        background-color: rgba(255, 255, 255, 0.98);
        position: -webkit-sticky;
        position: sticky;
        top: 0;
        z-index: 9999;
    }

    header.scrolled {
        background-color: rgba(255, 255, 255, 0.99);
    }

    header.scrolled .header-container {
        padding: 15px 0;
        gap: 15px;
    }

    /* Mobile Safari specific fixes */
    @supports (-webkit-overflow-scrolling: touch) {
        header {
            position: -webkit-sticky;
            position: sticky;
            top: 0;
            transform: translateZ(0);
            -webkit-transform: translateZ(0);
        }
    }

    /* Fallback for mobile browsers without sticky support */
    @supports not (position: sticky) {
        header {
            position: fixed !important;
            top: 0 !important;
            width: 100% !important;
        }
        
        body {
            padding-top: 160px !important;
        }
    }

    .container {
        width: 95%;
        padding: 0 10px;
    }
    
    .header-container {
        flex-direction: column;
        gap: 20px;
        padding: 25px 0 !important;
        align-items: center;
    }
    
    .header-container > div {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 15px !important;
        width: 100% !important;
        margin-top: 15px !important;
    }
    
    .cta-button {
        padding: 16px 24px !important;
        font-size: 1rem !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 320px !important;
        text-align: center !important;
        display: block !important;
        box-sizing: border-box !important;
        border-radius: 25px !important;
        min-height: 48px !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    
    /* Button container improvements */
    div[style*="display: flex"][style*="justify-content: center"] {
        flex-direction: column !important;
        align-items: center !important;
        gap: 15px !important;
    }
    
    div[style*="display: flex"][style*="gap: 20px"] {
        flex-direction: column !important;
        align-items: center !important;
        gap: 15px !important;
    }
    
    nav {
        padding: 8px 0;
        margin-top: 15px;
        border-radius: 20px;
    }
    
    nav ul {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
        margin-top: 8px;
        padding: 5px;
    }
    
    nav ul li {
        margin: 0 2px;
    }
    
    nav ul li a {
        padding: 12px 16px;
        font-size: 0.9rem;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Mobile dropdown improvements */
    .dropdown-content {
        position: fixed;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: 90vw;
        max-width: 320px;
        max-height: 70vh;
        overflow-y: auto;
        z-index: 9999;
        border-radius: 16px;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    }
    
    .dropdown-content a {
        padding: 16px 20px;
        font-size: 1rem;
        min-height: 48px;
        display: flex;
        align-items: center;
        border-radius: 12px;
        margin: 4px 12px;
    }
    
    /* Mobile overlay for better UX */
    .dropdown.active::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.3);
        z-index: 9998;
        backdrop-filter: blur(2px);
    }
    
    .footer-container {
        flex-direction: column;
        text-align: center;
        gap: 20px;
    }
    
    .footer-col {
        margin-bottom: 25px;
        min-width: auto;
    }
    
    .logo-image {
        width: 50px;
        height: 50px;
    }
    
    .logo-text {
        font-size: 1.2rem;
    }
}

/* Small Mobile Devices - iPhone SE, etc. */
@media (max-width: 480px) {
    .container {
        width: 98%;
        padding: 0 5px;
    }
    
    .header-container {
        padding: 20px 0 !important;
        gap: 15px;
    }
    
    .cta-button {
        padding: 14px 20px !important;
        font-size: 0.95rem !important;
        max-width: 280px !important;
        min-height: 44px !important;
    }
    
    .logo-image {
        width: 45px;
        height: 45px;
    }
    
    .logo-text {
        font-size: 1.1rem;
    }
    
    nav ul li a {
        padding: 10px 14px;
        font-size: 0.85rem;
    }
    
    .dropdown-content {
        width: 95vw;
        max-width: 280px;
    }
}

/* Extra Small Mobile - Very narrow screens */
@media (max-width: 360px) {
    .container {
        width: 100%;
        padding: 0 8px;
    }
    
    .cta-button {
        padding: 12px 16px !important;
        font-size: 0.9rem !important;
        max-width: 260px !important;
    }
    
    .logo-text {
        font-size: 1rem;
    }
    
    nav ul li a {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
}

/* Touch-friendly interactions for mobile devices */
@media (hover: none) and (pointer: coarse) {
    .cta-button {
        min-height: 48px;
        min-width: 48px;
        padding: 14px 20px;
        font-size: 1rem;
        border-radius: 24px;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    
    .cta-button:active {
        transform: scale(0.98);
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    }
    
    nav ul li a {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background-color 0.2s ease;
    }
    
    nav ul li a:active {
        background-color: rgba(76, 175, 80, 0.2);
    }
    
    /* Improve dropdown for touch */
    .dropdown-content a {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding: 12px 20px;
    }
    
    .dropdown-content a:active {
        background-color: rgba(76, 175, 80, 0.15);
    }
}

/* Reduce animations on mobile for better performance */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Mobile Layout Optimizations */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Prevent horizontal scrolling on mobile */
body {
    overflow-x: hidden;
}

/* Improve button containers for mobile */
@media (max-width: 768px) {
    /* Fix inline button containers */
    [style*="display: flex"][style*="justify-content: center"][style*="gap"] {
        flex-direction: column !important;
        align-items: center !important;
        gap: 15px !important;
        width: 100% !important;
    }
    
    /* Ensure buttons don't break layout */
    .cta-button,
    a[class*="cta-button"],
    a[style*="cta-button"] {
        width: 100% !important;
        max-width: 300px !important;
        text-align: center !important;
        display: block !important;
        box-sizing: border-box !important;
        margin: 0 auto 10px auto !important;
        padding: 16px 20px !important;
        font-size: 1rem !important;
        line-height: 1.3 !important;
        border-radius: 25px !important;
        min-height: 48px !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
    
    /* Grid layouts become single column on mobile */
    [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    /* Improve text readability */
    p, div {
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }
    
    /* Better spacing for mobile */
    section {
        padding: 30px 0;
    }
    
    h1 {
        font-size: 1.8rem;
        line-height: 1.3;
        margin-bottom: 15px;
    }
    
    h2 {
        font-size: 1.5rem;
        line-height: 1.3;
        margin-bottom: 15px;
    }
    
    h3 {
        font-size: 1.3rem;
        line-height: 1.3;
        margin-bottom: 12px;
    }
}

/* Optimize font loading on mobile */
.container {
    font-display: swap;
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .cta-button {
        -webkit-appearance: none;
        -webkit-tap-highlight-color: transparent;
    }
    
    input, button, select, textarea {
        -webkit-appearance: none;
        border-radius: 0;
    }
}

/* Landscape orientation optimizations */
@media (max-width: 768px) and (orientation: landscape) {
    .header-container {
        padding: 15px 0 !important;
        gap: 10px;
    }
    
    .cta-button {
        padding: 12px 20px !important;
        font-size: 0.9rem !important;
        min-height: 40px !important;
    }
    
    nav {
        margin-top: 10px;
    }
    
    nav ul li a {
        padding: 8px 14px;
        font-size: 0.85rem;
    }
}
