@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@300;400;500;600;700&display=swap');

/* ========================================
   CSS CUSTOM PROPERTIES (Design System)
   Easy to maintain and update globally
   ======================================== */
:root {
    /* Spacing System - Consistent across all sections */
    --section-padding-y: 5rem;           /* py-20 = 80px */
    --section-padding-y-lg: 6rem;        /* py-24 = 96px */
    --section-padding-x: 1.5rem;         /* px-6 = 24px */
    --container-max-width: 80rem;        /* max-w-6xl */
    
    /* Page Header Spacing */
    --page-header-pt: 8rem;              /* pt-32 = 128px */
    --page-header-pb: 5rem;              /* pb-20 = 80px */
    
    /* Newsletter Section */
    --newsletter-py: 3rem;               /* py-12 */
    --newsletter-py-md: 4rem;            /* md:py-16 */
    
    /* Footer Spacing */
    --footer-py: 4rem;                   /* py-16 */
    --footer-pb: 3rem;                   /* pb-12 */
    --footer-pb-md: 4rem;                /* md:pb-16 */
    
    /* Component Spacing */
    --card-padding: 2rem;                /* p-8 */
    --card-gap: 2rem;                    /* gap-8 */
    --content-gap: 3rem;                 /* gap-12 */
    
    /* Border Radius */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-2xl: 2rem;
    --radius-3xl: 3rem;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* ========================================
   UTILITY CLASSES FOR CONSISTENT SPACING
   Use these in HTML for maintainability
   ======================================== */
.section-spacing {
    padding-top: var(--section-padding-y);
    padding-bottom: var(--section-padding-y);
    padding-left: var(--section-padding-x);
    padding-right: var(--section-padding-x);
}

.page-header-spacing {
    padding-top: var(--page-header-pt);
    padding-bottom: var(--page-header-pb);
}

.newsletter-spacing {
    padding-top: var(--newsletter-py);
    padding-bottom: var(--newsletter-py);
}

@media (min-width: 768px) {
    .newsletter-spacing {
        padding-top: var(--newsletter-py-md);
        padding-bottom: var(--newsletter-py-md);
    }
}

/* Base Styles */
html {
    scroll-behavior: smooth;
    scroll-padding-top: 100px;
    /* IMPORTANT: overflow-x: hidden on html breaks position: sticky! 
       Moved to body instead */
}

body {
    direction: rtl;
    text-align: right;
    font-family: 'Rubik', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden; /* Prevent horizontal scroll here, not on html */
    background-color: #f9fafb;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.03'/%3E%3C/svg%3E");
}

/* Ensure all text content is right-aligned for RTL by default, but preserve explicit alignments */
p:not([class*="text-center"]):not([class*="text-left"]), 
h1:not([class*="text-center"]):not([class*="text-left"]), 
h2:not([class*="text-center"]):not([class*="text-left"]), 
h3:not([class*="text-center"]):not([class*="text-left"]), 
h4:not([class*="text-center"]):not([class*="text-left"]), 
h5:not([class*="text-center"]):not([class*="text-left"]), 
h6:not([class*="text-center"]):not([class*="text-left"]), 
li:not([class*="text-center"]):not([class*="text-left"]), 
td:not([class*="text-center"]):not([class*="text-left"]), 
th:not([class*="text-center"]):not([class*="text-left"]), 
label:not([class*="text-center"]):not([class*="text-left"]) {
    text-align: right;
    direction: rtl;
}

/* Input fields and textareas should be RTL */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="search"],
textarea {
    text-align: right;
    direction: rtl;
}

/* Preserve center and left alignment when explicitly set */
.text-center,
[class*="text-center"],
[class*="text-center"] *:not([class*="text-left"]):not([class*="text-right"]) {
    text-align: center !important;
}

.text-left,
[class*="text-left"] {
    text-align: left !important;
    direction: ltr;
}

/* Preserve alignment for elements inside text-center containers */
div[class*="text-center"] p:not([class*="text-left"]):not([class*="text-right"]),
div[class*="text-center"] h1:not([class*="text-left"]):not([class*="text-right"]),
div[class*="text-center"] h2:not([class*="text-left"]):not([class*="text-right"]),
div[class*="text-center"] h3:not([class*="text-left"]):not([class*="text-right"]),
div[class*="text-center"] h4:not([class*="text-left"]):not([class*="text-right"]),
div[class*="text-center"] h5:not([class*="text-left"]):not([class*="text-right"]),
div[class*="text-center"] h6:not([class*="text-left"]):not([class*="text-right"]) {
    text-align: center !important;
}

/* Button & Interactive Elements Tweaks */
button, a[class*="bg-"] {
    transition: transform 0.1s ease-in-out, background-color 0.2s, box-shadow 0.2s;
}
button:active, a[class*="bg-"]:active {
    transform: scale(0.97);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #102a43; /* primary-900 (Deep Blue) */
    border-radius: 5px;
    border: 2px solid #f1f1f1;
}

::-webkit-scrollbar-thumb:hover {
    background: #243b53; /* primary-800 */
}

/* Utilities */
.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

/* Enhanced Glassmorphism */
.glass-panel {
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
}

.glass-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    transition: all 0.3s ease;
}

.glass-card:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: translateY(-5px);
    box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.dark-glass {
    background: rgba(17, 25, 40, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.125);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Animations */
@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

.animate-float {
    animation: float 6s ease-in-out infinite;
}

/* Form Styles */
input:focus,
textarea:focus,
select:focus {
    outline: none;
}

/* Selection Color */
::selection {
    background-color: #d9e2ec; /* primary-100 */
    color: #102a43; /* primary-900 */
}

/* Typography refinements */
h1, h2, h3, h4, h5, h6 {
    letter-spacing: -0.025em;
}

/* RTL Support for border-right utilities */
html[dir="rtl"] [class*="border-r-"] {
    border-left: none;
}

html[dir="ltr"] [class*="border-r-"] {
    border-right: none;
    border-left: var(--border-width, 3px) solid var(--border-color, currentColor);
}

/* ========================================
   UNIFIED FORM & NEWSLETTER MESSAGE STYLES
   Mobile-first, responsive design
   ======================================== */

/* Base Message Container - Used by all messages */
.msg-container {
    margin-top: 1rem;
    animation: msgSlideIn 0.35s ease-out;
}

@keyframes msgSlideIn {
    0% {
        opacity: 0;
        transform: translateY(8px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Form Message Box - Contact forms, etc */
.msg-box {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 0.75rem;
    background: #ffffff;
    box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.08);
    width: 100%;
    box-sizing: border-box;
}

/* Mobile adjustments */
@media (max-width: 639px) {
    .msg-box {
        padding: 0.75rem;
        gap: 0.625rem;
        border-radius: 0.625rem;
    }
}

/* Tablet and up */
@media (min-width: 640px) {
    .msg-box {
        padding: 1rem 1.25rem;
        gap: 0.875rem;
        border-radius: 0.875rem;
    }
}

/* Success variant */
.msg-box.msg-success {
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border: 1px solid #86efac;
}

html[dir="rtl"] .msg-box.msg-success {
    border-right: 3px solid #22c55e;
}

html[dir="ltr"] .msg-box.msg-success {
    border-left: 3px solid #22c55e;
}

/* Error variant */
.msg-box.msg-error {
    background: linear-gradient(135deg, #fef2f2 0%, #fff1f2 100%);
    border: 1px solid #fca5a5;
}

html[dir="rtl"] .msg-box.msg-error {
    border-right: 3px solid #ef4444;
}

html[dir="ltr"] .msg-box.msg-error {
    border-left: 3px solid #ef4444;
}

/* Message Icon */
.msg-icon {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
}

@media (min-width: 640px) {
    .msg-icon {
        width: 2.25rem;
        height: 2.25rem;
        border-radius: 0.625rem;
    }
}

.msg-icon svg {
    width: 1rem;
    height: 1rem;
    stroke-width: 2.5;
}

@media (min-width: 640px) {
    .msg-icon svg {
        width: 1.125rem;
        height: 1.125rem;
    }
}

.msg-success .msg-icon {
    background: linear-gradient(135deg, #dcfce7 0%, #d1fae5 100%);
    color: #16a34a;
}

.msg-error .msg-icon {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #dc2626;
}

/* Message Content */
.msg-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.msg-title {
    font-weight: 700;
    font-size: 0.875rem;
    line-height: 1.3;
    margin: 0;
}

@media (min-width: 640px) {
    .msg-title {
        font-size: 0.9375rem;
    }
}

.msg-success .msg-title {
    color: #166534;
}

.msg-error .msg-title {
    color: #991b1b;
}

.msg-text {
    font-size: 0.8125rem;
    line-height: 1.4;
    font-weight: 500;
    margin: 0;
}

@media (min-width: 640px) {
    .msg-text {
        font-size: 0.875rem;
    }
}

.msg-success .msg-text {
    color: #15803d;
}

.msg-error .msg-text {
    color: #b91c1c;
}

/* ========================================
   NEWSLETTER MESSAGE STYLES
   Inline, centered message for newsletter forms
   ======================================== */

.newsletter-msg {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem;
    margin-top: 0.75rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.8125rem;
    text-align: center;
    animation: msgSlideIn 0.35s ease-out;
    width: 100%;
    box-sizing: border-box;
}

@media (min-width: 640px) {
    .newsletter-msg {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
        border-radius: 0.625rem;
        margin-top: 1rem;
    }
}

.newsletter-msg svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

@media (min-width: 640px) {
    .newsletter-msg svg {
        width: 1.125rem;
        height: 1.125rem;
    }
}

.newsletter-msg.msg-success {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #86efac;
    color: #16a34a;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.newsletter-msg.msg-error {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #fca5a5;
    color: #dc2626;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Darker backgrounds (newsletter sections) need higher contrast */
.bg-gray-900 .newsletter-msg,
.bg-primary-700 .newsletter-msg,
.bg-primary-800 .newsletter-msg,
.bg-primary-900 .newsletter-msg,
[class*="from-primary-7"] .newsletter-msg,
[class*="from-primary-8"] .newsletter-msg,
[class*="from-primary-9"] .newsletter-msg {
    box-shadow: 0 4px 16px -2px rgba(0, 0, 0, 0.15);
}

/* Newsletter Message Container - Center content */
#newsletterMessage {
    margin-top: 0.75rem;
    display: flex;
    justify-content: center;
    width: 100%;
}

#newsletterMessage.hidden {
    display: none;
}

@media (min-width: 640px) {
    #newsletterMessage {
        margin-top: 1rem;
    }
}


/* ========== MODAL SCROLL PREVENTION ========== */
/* Prevents background scrolling when modal is open */
/* IMPORTANT: Do NOT use position: fixed on body - it causes scroll jump to top! */
body.modal-open {
    overflow: hidden !important;
    /* Removed position: fixed - causes scroll jump */
    touch-action: none;
    -webkit-overflow-scrolling: none;
}

html.modal-open {
    overflow: hidden !important;
}

/* ========== MODAL POSITIONING FIX ========== */
/* Ensure modal always centers content properly */
#policyModal,
#articleModal,
#readModal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 100 !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 1rem !important;
    overflow-y: auto !important;
    /* Reset any scroll position */
    margin: 0 !important;
}

#policyModal.flex,
#articleModal.flex,
#readModal.flex {
    display: flex !important;
}

#policyModal.hidden,
#articleModal.hidden,
#readModal.hidden {
    display: none !important;
}

/* Ensure modal content is properly centered */
#policyModal > div:first-child,
#articleModal > div:first-child,
#readModal > div:first-child {
    position: relative !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
    margin: auto !important;
    /* Flex item - don't let it stretch */
    flex-shrink: 0 !important;
    /* Center horizontally and vertically */
    align-self: center !important;
}

/* Special handling for articleModal on mobile (bottom aligned) */
@media (max-width: 639px) {
    #articleModal {
        align-items: flex-end !important;
        padding: 0 !important;
    }
    
    #articleModal > div:first-child {
        max-height: 100vh !important;
        border-radius: 1.5rem 1.5rem 0 0 !important;
    }
}

/* Mobile optimizations for modal */
@media (max-width: 767px) {
    #policyModal {
        padding: 1rem !important;
    }
    
    #policyModal > div:first-child {
        max-height: calc(100vh - 2rem) !important;
        border-radius: 1rem !important;
    }
    
    #policyModal .sticky {
        padding: 1rem !important;
    }
    
    #policyModal h2 {
        font-size: 1.25rem !important;
    }
}

/* ========== MOBILE MENU SCROLL PREVENTION ========== */
/* Prevents background scrolling when mobile menu is open */
body.mobile-menu-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
    touch-action: none !important;
    -webkit-overflow-scrolling: none !important;
}

html.mobile-menu-open {
    overflow: hidden !important;
    height: 100% !important;
}

/* Prevent scroll on mobile menu overlay */
#mobileMenuOverlay {
    touch-action: none;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: none;
}

/* Mobile specific - ensure mobile menu overlay covers full viewport */
@media (max-width: 768px) {
    #mobileMenuOverlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        min-height: 100vh !important;
        min-height: 100dvh !important;
        min-height: -webkit-fill-available !important;
        z-index: 60 !important;
    }
}

/* Allow scroll only inside mobile menu panel */
#mobileMenu {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* ========== MOBILE MENU - PREVENT OVERFLOW ON PAGE LOAD ========== */
/* CRITICAL FIX: The mobile menu with translate-x-full can cause horizontal overflow
   on page load before CSS fully renders. This ensures it's truly invisible. */

/* Default state: Menu is closed (translate-x-full present) = hidden */
#mobileMenu.translate-x-full {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

/* When menu is open (translate-x-full removed) = visible */
#mobileMenu:not(.translate-x-full) {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

/* Smooth transition for all properties */
#mobileMenu {
    transition: transform 0.3s ease-in-out, visibility 0s 0.3s, opacity 0.3s ease-in-out;
}

/* When opening: remove visibility delay */
#mobileMenu:not(.translate-x-full) {
    transition: transform 0.3s ease-in-out, visibility 0s 0s, opacity 0.3s ease-in-out;
}

/* Modal backdrop - prevent scroll passthrough */
.modal-backdrop {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Modal content - allow internal scroll only */
.modal-scroll-container {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* ========== PAGE TRANSITIONS & LOADING EFFECTS ========== */

/* Page Transition Effects */
/* IMPORTANT: Do NOT use transform on body - it breaks position: fixed for modals! */
body {
    opacity: 0;
    animation: fadeInPage 0.4s ease-in-out forwards;
}

@keyframes fadeInPage {
    from {
        opacity: 0;
        /* Removed transform - it creates a containing block that breaks position: fixed */
    }
    to {
        opacity: 1;
        /* No transform here - keeps position: fixed working correctly */
    }
}

/* CRITICAL: Ensure navbar is ALWAYS visible, even during body fade-in animation */
/* This prevents the "header not loading" issue on mobile */
#navbar {
    opacity: 1 !important;
    visibility: visible !important;
}

.page-content {
    animation: fadeInContent 0.5s ease-out forwards;
}

@keyframes fadeInContent {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: none; /* Use 'none' instead of translateY(0) to clear the transform */
    }
}

/* Loading Overlay - Page Navigation */
#loadingOverlay {
    position: fixed;
    inset: 0;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    max-height: 100vh;
    max-height: 100dvh;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 999999;
    /* Hidden by default - NO !important so JS can override */
    display: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    overflow: hidden;
    touch-action: none;
    margin: 0;
    padding: 0;
    /* Flexbox centering (applied when display: flex) */
    align-items: center;
    justify-content: center;
    flex-direction: column;
    transform: none;
}

/* When .show is added - use !important to ensure it shows */
#loadingOverlay.show {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
}

/* Prevent body scroll when overlay is shown */
body.loading-overlay-active {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
    touch-action: none !important;
}

html.loading-overlay-active {
    overflow: hidden !important;
    height: 100% !important;
}

/* Mobile specific - ensure full screen coverage */
@media (max-width: 768px) {
    #loadingOverlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        min-height: 100vh;
        min-height: 100dvh;
        min-height: -webkit-fill-available;
        height: 100vh;
        height: 100dvh;
        max-width: none;
        max-height: none;
    }
    
    #loadingOverlay.show {
        display: flex !important;
        height: 100vh !important;
        height: 100dvh !important;
        min-height: 100vh !important;
        min-height: 100dvh !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
    }
}

/* Inner container - centered via flexbox parent */
#loadingOverlay .loading-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 1;
    opacity: 1;
    visibility: visible;
}

/* Spinner */
#loadingOverlay .spinner {
    width: 56px;
    height: 56px;
    border: 4px solid rgba(72, 101, 129, 0.25);
    border-top-color: #486581;
    border-radius: 50%;
    animation: overlaySpinner 0.75s linear infinite;
    margin-bottom: 18px;
    background: transparent;
    box-sizing: border-box;
    opacity: 1;
    visibility: visible;
    display: block;
}

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

/* Loading Text */
#loadingOverlay .loading-text {
    color: #334e68;
    font-weight: 700;
    font-size: 15px;
    text-align: center;
    white-space: nowrap;
    padding: 10px 24px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    opacity: 1;
    visibility: visible;
    display: block;
}

/* Desktop specific */
@media (min-width: 769px) {
    #loadingOverlay .spinner {
        width: 52px;
        height: 52px;
        border-width: 4px;
    }
    
    #loadingOverlay .loading-text {
        font-size: 15px;
        padding: 10px 24px;
    }
}

/* Mobile specific adjustments */
@media (max-width: 768px) {
    #loadingOverlay .spinner {
        width: 60px !important;
        height: 60px !important;
        border-width: 4px !important;
        margin-bottom: 20px !important;
    }
    
    #loadingOverlay .loading-text {
        font-size: 16px !important;
        padding: 12px 28px !important;
    }
}

/* Spin Animation for Buttons */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Button Loading State */
.btn-loading {
    position: relative;
    pointer-events: none;
}

.btn-loading > * {
    opacity: 0;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-top: -10px;
    margin-left: -10px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    z-index: 1;
}

/* For buttons with white background and dark text */
button.bg-white.btn-loading::after,
.btn-loading.text-primary-700::after {
    border-top-color: rgb(29, 78, 216);
    border-right-color: rgba(29, 78, 216, 0.2);
    border-bottom-color: rgba(29, 78, 216, 0.2);
    border-left-color: rgba(29, 78, 216, 0.2);
}

/* For buttons with dark background and white text */
button.bg-primary-600.btn-loading::after,
button.bg-primary-700.btn-loading::after,
.btn-loading.text-white::after {
    border-top-color: white;
    border-right-color: rgba(255, 255, 255, 0.3);
    border-bottom-color: rgba(255, 255, 255, 0.3);
    border-left-color: rgba(255, 255, 255, 0.3);
}

/* Success Flash Animation */
@keyframes successFlash {
    0% {
        background-color: transparent;
    }
    50% {
        background-color: rgba(16, 185, 129, 0.2);
    }
    100% {
        background-color: transparent;
    }
}

.success-flash {
    animation: successFlash 0.6s ease-in-out;
}

/* ========== STICKY HEADER STYLES ========== */

/* Base navbar z-index */
#navbar {
    z-index: 50;
}

/* Mobile: Fixed positioning (max-width: 767px) */
@media (max-width: 767px) {
    #navbar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        transform: none !important; /* Use 'none' instead of translateY(0) for cleaner initial render */
        transition: background-color 0.3s ease, box-shadow 0.3s ease, backdrop-filter 0.3s ease;
        will-change: background-color, box-shadow;
        /* Ensure navbar is visible immediately on page load */
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 50 !important;
    }
    
    /* Mobile scroll state */
    #navbar.scrolled {
        background: rgba(255, 255, 255, 0.98) !important;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        transform: none !important;
    }
    
    /* Ensure navbar stays in place during scroll */
    body:not(.mobile-menu-open) #navbar {
        transform: none !important;
    }
}

/* Desktop & Tablet: Sticky positioning (min-width: 768px) */
@media (min-width: 768px) {
    #navbar {
        position: -webkit-sticky !important; /* Safari support */
        position: sticky !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        z-index: 50 !important;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        will-change: background-color, box-shadow;
    }
    
    /* Enhanced scroll state */
    #navbar.scrolled {
        background: rgba(255, 255, 255, 0.95) !important;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
        border-bottom: 1px solid rgba(255, 255, 255, 0.5);
    }
    
    /* Smooth height transition on scroll */
    #navbar.scrolled .container > div {
        transition: height 0.3s ease;
    }
}

/* Smooth scroll behavior - Account for navbar height */
html {
    scroll-padding-top: 80px; /* Matches navbar height (h-20 = 80px) */
}

/* ========== MOBILE READ MODAL FIXES ========== */
@media (max-width: 767px) {
    /* Read Modal (Article View) Mobile Improvements */
    #readModal {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    
    #readModal > * {
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }
    
    /* Hero image mobile */
    #readModal .h-\[40vh\] {
        height: 35vh !important;
    }
    
    /* Content padding mobile */
    #readModal .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Title size mobile */
    #readModal h1 {
        font-size: 1.5rem !important;
        line-height: 1.3 !important;
    }
    
    /* Excerpt mobile */
    #readModal .text-lg {
        font-size: 1rem !important;
        padding-right: 0.75rem !important;
        border-right-width: 3px !important;
    }
    
    /* Article content mobile */
    #readModal .article-content {
        font-size: 1rem !important;
        line-height: 1.75 !important;
    }
    
    #readModal .article-content img {
        max-width: 100% !important;
        height: auto !important;
        border-radius: 0.75rem !important;
    }
    
    /* Close button mobile - more accessible */
    #readModal .close-btn {
        top: 0.5rem !important;
        right: 0.5rem !important;
        padding: 0.625rem !important;
        background: white !important;
        box-shadow: 0 2px 10px rgba(0,0,0,0.15) !important;
    }
    
    /* Share section mobile */
    #readModal .mt-16 {
        margin-top: 2.5rem !important;
        padding-top: 1.5rem !important;
    }
    
    /* Share buttons mobile */
    #readModal .flex.justify-center.gap-4 {
        gap: 0.75rem !important;
    }
    
    /* CTA box mobile */
    #readModal .bg-primary-50 {
        padding: 1.25rem !important;
    }
    
    /* Content container rounded top mobile */
    #readModal .rounded-t-3xl {
        border-radius: 1.5rem 1.5rem 0 0 !important;
    }
    
    /* Progress bar thinner on mobile */
    #readModal .reading-progress-bar {
        height: 3px !important;
    }
}

/* ========== PREVENT HORIZONTAL SCROLL ON ALL PAGES ========== */
/* IMPORTANT: Only apply overflow-x: hidden to body on desktop - breaks sticky! */
/* On mobile we use position: fixed for navbar, so we CAN use overflow-x: hidden on html */
html {
    max-width: 100vw;
}
body {
    max-width: 100vw;
    overflow-x: hidden;
}

/* Mobile: Safe to use overflow-x hidden on html since we use position: fixed, not sticky */
@media (max-width: 767px) {
    html {
        overflow-x: hidden !important;
    }
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        width: 100% !important;
    }
}

/* Ensure all sections stay within viewport */
section, header, footer, nav, main, article, aside, div {
    max-width: 100vw;
}

/* Fix any potential overflow from animations or transforms */
@media (max-width: 767px) {
    .container {
        max-width: 100vw !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    img, video, iframe, embed, object {
        max-width: 100% !important;
        height: auto;
    }
    
    /* Prevent blob animations from causing overflow */
    .blob-anim {
        animation: none !important;
    }
    
    /* Fix any absolute positioned elements that might overflow */
    [class*="absolute"] {
        max-width: 100vw;
    }
}

/* ========== FORM SUBMISSION MOBILE FIX ========== */
/* Prevent any unwanted form behaviors on mobile */
form {
    -webkit-tap-highlight-color: transparent;
}

form button[type="submit"] {
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
}

/* Prevent iOS zoom on input focus */
@media (max-width: 767px) {
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

