/* Custom Styles that extend Tailwind */

/* ═══════════════════════════════════════════════════════════════════════════ */
/* LOADING SCREEN */
/* ═══════════════════════════════════════════════════════════════════════════ */
#page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #fdfcfa 0%, #f8f6f3 50%, #fdfcfa 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#page-loader.loaded {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Logo Animation */
.loader-logo {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: 2.5rem;
    color: #3E5C65;
    letter-spacing: 0.02em;
    margin-bottom: 0.25rem;
    animation: logoFadeIn 0.8s ease-out forwards;
}

.loader-tagline {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.625rem;
    letter-spacing: 0.3em;
    color: #AB9478;
    font-weight: 500;
    margin-bottom: 2.5rem;
    animation: logoFadeIn 0.8s ease-out 0.2s forwards;
    opacity: 0;
}

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

/* Animated Coins/Dots */
.loader-coins {
    display: flex;
    gap: 12px;
    margin-bottom: 2rem;
}

.loader-coin {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, #AB9478 0%, #c4aa8c 100%);
    box-shadow: 0 2px 8px rgba(171, 148, 120, 0.3);
    animation: coinBounce 1.4s ease-in-out infinite;
}

.loader-coin:nth-child(1) { animation-delay: 0s; }
.loader-coin:nth-child(2) { animation-delay: 0.2s; }
.loader-coin:nth-child(3) { animation-delay: 0.4s; }

@keyframes coinBounce {
    0%, 80%, 100% {
        transform: scale(0.8) translateY(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2) translateY(-16px);
        opacity: 1;
    }
}

/* Progress Bar */
.loader-progress-container {
    width: 200px;
    height: 3px;
    background: rgba(62, 92, 101, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.loader-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #3E5C65, #AB9478, #3E5C65);
    background-size: 200% 100%;
    border-radius: 3px;
    animation: progressShimmer 1.5s ease-in-out infinite, progressGrow 1.2s ease-out forwards;
}

@keyframes progressShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes progressGrow {
    from { width: 0%; }
    to { width: 100%; }
}

/* Loading Text */
.loader-text {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.75rem;
    color: #394144;
    opacity: 0.7;
    animation: textPulse 2s ease-in-out infinite;
}

@keyframes textPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.9; }
}

/* Decorative Floating Elements */
.loader-float {
    position: absolute;
    opacity: 0.1;
    animation: floatAround 6s ease-in-out infinite;
}

.loader-float-1 {
    top: 20%;
    left: 15%;
    width: 40px;
    height: 40px;
    border: 2px solid #3E5C65;
    border-radius: 50%;
    animation-delay: 0s;
}

.loader-float-2 {
    top: 60%;
    right: 20%;
    width: 24px;
    height: 24px;
    background: #AB9478;
    border-radius: 50%;
    animation-delay: -2s;
}

.loader-float-3 {
    bottom: 25%;
    left: 25%;
    width: 16px;
    height: 16px;
    border: 2px solid #AB9478;
    border-radius: 4px;
    transform: rotate(45deg);
    animation-delay: -4s;
}

@keyframes floatAround {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(-15px) rotate(5deg);
    }
    50% {
        transform: translateY(-5px) rotate(-3deg);
    }
    75% {
        transform: translateY(-20px) rotate(3deg);
    }
}

/* Hide body scroll while loading */
body.loading {
    overflow: hidden;
}

/* CRITICAL: Prevent horizontal scrolling on mobile (for Wix embed) */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
    scroll-behavior: smooth;
}

* {
    box-sizing: border-box;
}

/* Ensure all sections don't overflow */
section, header, footer, main, nav, div {
    max-width: 100%;
}

/* Fix any elements that might cause overflow */
img, video, iframe, embed, object {
    max-width: 100%;
    height: auto;
}

/* Mobile-specific fixes */
@media (max-width: 768px) {
    .max-w-7xl, .max-w-6xl, .max-w-5xl, .max-w-4xl {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Prevent text from causing overflow */
    h1, h2, h3, h4, h5, h6, p, span, a {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Fix grid layouts on mobile */
    .grid {
        width: 100%;
    }
}

/* Triangle for chat bubble */
.triangle-bottom-right::after {
    content: '';
    position: absolute;
    bottom: -10px;
    right: 20px;
    border-width: 10px 10px 0;
    border-style: solid;
    border-color: #FFFFFF transparent;
    display: block;
    width: 0;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px; /* For horizontal scroll */
}

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

::-webkit-scrollbar-thumb {
    background: #ab9478;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #567b84;
}

/* Chatbot Specific Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: #f9f9f9;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #d4d4d4;
    border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #ab9478;
}

/* Hide Scrollbar for Horizontal Chips */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

/* Animation Utilities - REFINED */

/* 1. Reveal on Scroll (Base Class) */
body.animations-enabled .reveal-on-scroll,
body.animations-enabled .fade-in-up {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.5, 0, 0, 1), transform 0.8s cubic-bezier(0.5, 0, 0, 1);
}

body.animations-enabled .reveal-on-scroll.is-visible,
body.animations-enabled .fade-in-up.is-visible {
    opacity: 1;
    transform: translateY(0);
}

body.animations-enabled .fade-in-up.is-visible {
    animation: fadeInUp 0.8s ease-out forwards;
}

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

/* 2. Chat Bubble Pulse */
@keyframes blob-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(171, 148, 120, 0.7);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(171, 148, 120, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(171, 148, 120, 0);
    }
}

.animate-blob-pulse {
    animation: blob-pulse 2s infinite;
}

/* 3. Gold Shimmer Effect (for Buttons/Cards) */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.shimmer-gold {
    background: linear-gradient(
        90deg, 
        rgba(255,255,255,0) 0%, 
        rgba(255,255,255,0.2) 50%, 
        rgba(255,255,255,0) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 3s infinite linear;
}

/* 4. Hover Lift (Cards) */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.hover-lift:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Legacy Fade In (Base State to ensure visibility without JS) */
.fade-in-up,
.reveal-on-scroll {
    opacity: 1;
    transform: translateY(0);
}

.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }

/* Range Slider Customization */
input[type=range] {
    -webkit-appearance: none; 
    width: 100%; 
    background: transparent; 
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: #ab9478;
    cursor: pointer;
    margin-top: -8px; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: #e4e0d8;
    border-radius: 2px;
}

input[type=range]:focus {
    outline: none;
}

/* ============================================
   COMPREHENSIVE RESPONSIVE DESIGN SYSTEM
   Optimized for: Mobile, Tablet, Desktop, Large Screens
   ============================================ */

/* ---------- EXTRA SMALL DEVICES (320px - 479px) ---------- */
@media (max-width: 479px) {
    /* Typography scaling */
    h1 { font-size: 1.75rem !important; line-height: 1.2 !important; }
    h2 { font-size: 1.5rem !important; line-height: 1.3 !important; }
    h3 { font-size: 1.25rem !important; }
    h4 { font-size: 1.1rem !important; }
    
    /* Container padding */
    .container, .max-w-7xl, .max-w-6xl, .max-w-5xl, .max-w-4xl, .max-w-3xl {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    /* Section spacing */
    section {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    /* Button sizing */
    .btn, button, a[class*="bg-brand"], a[class*="px-"] {
        padding: 0.625rem 1rem !important;
        font-size: 0.875rem !important;
    }
    
    /* Grid to single column */
    .grid-cols-2, .grid-cols-3, .grid-cols-4, 
    .md\:grid-cols-2, .md\:grid-cols-3, .md\:grid-cols-4,
    .lg\:grid-cols-2, .lg\:grid-cols-3, .lg\:grid-cols-4 {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* Flex wrap on mobile */
    .flex {
        flex-wrap: wrap;
    }
    
    /* Card padding reduction */
    [class*="p-6"], [class*="p-8"], [class*="p-10"], [class*="p-12"] {
        padding: 1rem !important;
    }
    
    /* Image galleries */
    .gallery-thumbnails, .thumbnail-row {
        gap: 0.25rem !important;
    }
    
    .gallery-thumbnails img, .thumbnail-row img {
        width: 40px !important;
        height: 40px !important;
    }
    
    /* Pricing cards */
    .pricing-card {
        padding: 1rem !important;
    }
    
    /* Hide decorative elements on very small screens */
    .absolute.-top-4, .absolute.-bottom-6, .absolute.-right-6 {
        display: none !important;
    }
}

/* ---------- SMALL DEVICES / MOBILE (480px - 639px) ---------- */
@media (min-width: 480px) and (max-width: 639px) {
    h1 { font-size: 2rem !important; }
    h2 { font-size: 1.625rem !important; }
    h3 { font-size: 1.375rem !important; }
    
    .container, .max-w-7xl, .max-w-6xl, .max-w-5xl {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    section {
        padding-top: 2.5rem !important;
        padding-bottom: 2.5rem !important;
    }
    
    .grid-cols-2, .grid-cols-3, .grid-cols-4 {
        grid-template-columns: 1fr !important;
    }
    
    .gallery-thumbnails img, .thumbnail-row img {
        width: 50px !important;
        height: 50px !important;
    }
}

/* ---------- TABLET PORTRAIT (640px - 767px) ---------- */
@media (min-width: 640px) and (max-width: 767px) {
    h1 { font-size: 2.25rem !important; }
    h2 { font-size: 1.75rem !important; }
    
    .container, .max-w-7xl, .max-w-6xl {
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
    }
    
    section {
        padding-top: 3rem !important;
        padding-bottom: 3rem !important;
    }
    
    /* Two column grids become single on tablet portrait */
    .grid-cols-3, .grid-cols-4, .lg\:grid-cols-3, .lg\:grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .gallery-thumbnails img, .thumbnail-row img {
        width: 60px !important;
        height: 60px !important;
    }
}

/* ---------- TABLET LANDSCAPE (768px - 1023px) ---------- */
@media (min-width: 768px) and (max-width: 1023px) {
    h1 { font-size: 2.5rem !important; }
    h2 { font-size: 2rem !important; }
    
    .container, .max-w-7xl, .max-w-6xl {
        padding-left: 2rem !important;
        padding-right: 2rem !important;
    }
    
    section {
        padding-top: 4rem !important;
        padding-bottom: 4rem !important;
    }
    
    /* Three column grids */
    .grid-cols-4, .lg\:grid-cols-4 {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    
    /* Plan page layout - stack on tablet */
    .lg\:grid-cols-5 {
        grid-template-columns: 1fr !important;
    }
    
    .lg\:col-span-3, .lg\:col-span-2 {
        grid-column: span 1 !important;
    }
    
    .gallery-thumbnails img, .thumbnail-row img {
        width: 70px !important;
        height: 70px !important;
    }
}

/* ---------- SMALL DESKTOP (1024px - 1279px) ---------- */
@media (min-width: 1024px) and (max-width: 1279px) {
    .container, .max-w-7xl {
        padding-left: 2rem !important;
        padding-right: 2rem !important;
    }
    
    .gallery-thumbnails img, .thumbnail-row img {
        width: 80px !important;
        height: 80px !important;
    }
}

/* ---------- LARGE DESKTOP (1280px - 1535px) ---------- */
@media (min-width: 1280px) and (max-width: 1535px) {
    .max-w-7xl {
        max-width: 1200px !important;
    }
}

/* ---------- EXTRA LARGE / 4K (1536px+) ---------- */
@media (min-width: 1536px) {
    html {
        font-size: 18px;
    }
    
    .max-w-7xl {
        max-width: 1400px !important;
    }
    
    h1 { font-size: 3.5rem !important; }
    h2 { font-size: 2.75rem !important; }
}

/* ============================================
   COMPONENT-SPECIFIC RESPONSIVE FIXES
   ============================================ */

/* Navigation Header Responsive */
@media (max-width: 1023px) {
    .mm-nav-inner {
        padding: 0 1rem !important;
    }
    
    .mm-logo-text {
        font-size: 1rem !important;
    }
    
    .mm-logo-tagline {
        font-size: 0.5rem !important;
    }
}

/* Hero Section Responsive */
@media (max-width: 767px) {
    .hero-section, [class*="hero"] {
        min-height: auto !important;
        padding: 3rem 1rem !important;
    }
    
    .hero-section h1 {
        font-size: 1.75rem !important;
        margin-bottom: 1rem !important;
    }
    
    .hero-section p {
        font-size: 1rem !important;
    }
}

/* Pricing Cards Responsive */
@media (max-width: 767px) {
    .pricing-grid, [class*="pricing"] .grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }
    
    .pricing-card, [class*="pricing"] > div {
        padding: 1.5rem !important;
    }
    
    .pricing-card h3 {
        font-size: 1.25rem !important;
    }
    
    .pricing-card .price, [class*="text-4xl"] {
        font-size: 2rem !important;
    }
}

/* Feature Cards Responsive */
@media (max-width: 767px) {
    .feature-card, [class*="feature"] {
        padding: 1.25rem !important;
    }
    
    .feature-icon, [class*="feature"] i {
        font-size: 1.5rem !important;
        margin-bottom: 0.75rem !important;
    }
}

/* Plan Detail Pages Responsive */
@media (max-width: 1023px) {
    /* Stack gallery and info vertically */
    .plan-layout, .lg\:grid-cols-5 {
        display: flex !important;
        flex-direction: column !important;
        gap: 2rem !important;
    }
    
    /* Main image */
    .plan-main-image, .main-image-container {
        width: 100% !important;
        max-height: 400px !important;
    }
    
    .plan-main-image img {
        object-fit: contain !important;
        max-height: 350px !important;
    }
    
    /* Thumbnails in row */
    .thumbnail-gallery, .gallery-thumbnails {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 0.5rem !important;
    }
}

/* Testimonials Responsive */
@media (max-width: 767px) {
    .testimonial-card {
        padding: 1.5rem !important;
    }
    
    .testimonial-card blockquote {
        font-size: 0.9375rem !important;
        line-height: 1.6 !important;
    }
    
    .testimonial-avatar {
        width: 48px !important;
        height: 48px !important;
    }
}

/* Footer Responsive */
@media (max-width: 767px) {
    footer .grid {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
        text-align: center !important;
    }
    
    footer .social-links {
        justify-content: center !important;
    }
}

/* Hub Page Responsive */
@media (max-width: 767px) {
    .hub-sidebar {
        display: none !important;
    }
    
    .hub-main {
        width: 100% !important;
    }
    
    .hub-cards .grid {
        grid-template-columns: 1fr !important;
    }
}

/* Quiz Page Responsive */
@media (max-width: 639px) {
    .quiz-container {
        padding: 1rem !important;
    }
    
    .quiz-option {
        padding: 0.875rem !important;
        font-size: 0.9375rem !important;
    }
    
    .quiz-progress {
        height: 6px !important;
    }
}

/* ============================================
   SAFE AREA & NOTCH SUPPORT (iOS)
   ============================================ */
@supports (padding: env(safe-area-inset-bottom)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    footer {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    nav, footer, .chat-widget, .mobile-menu, button {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
    }
    
    h1 { font-size: 24pt; }
    h2 { font-size: 18pt; }
    h3 { font-size: 14pt; }
    
    a[href]:after {
        content: " (" attr(href) ")";
    }
}

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

/* Focus visible styles */
:focus-visible {
    outline: 2px solid #3E5C65;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .bg-brand-accent {
        background-color: #f0f0f0 !important;
    }
    
    .text-brand-charcoal\/70 {
        color: #333 !important;
    }
}
