/* ==========================================================================
   Font System Enforcement
   Ensures consistent font rendering across local and production environments
   ========================================================================== */

/* Base font system - Inter for Latin scripts, Cairo for Arabic */
html, body {
    font-family: 'Inter', Helvetica, Arial, sans-serif !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Arabic pages use Cairo font */
html[lang="ar"], 
html[lang="ar"] body {
    font-family: 'Cairo', 'Inter', Helvetica, Arial, sans-serif !important;
}

/* Ensure all text elements inherit the font system */
h1, h2, h3, h4, h5, h6,
p, span, a, button, input, textarea, select, label {
    font-family: inherit;
}

/* Force font-display: swap behavior for consistent FOUT handling */
@font-face {
    font-family: 'Inter';
    font-display: swap;
}

@font-face {
    font-family: 'Cairo';
    font-display: swap;
}

/* ==========================================================================
   No-JS Fallback
   ========================================================================== */

/*
   No-JS fallback: if JavaScript is slow or fails, ensure elements hidden via
   `opacity-0` or `invisible` are still visible so content isn't invisible to users.
*/
.no-js .opacity-0,
.no-js .invisible {
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
}

/* CSS-only fallback for critical content - will be visible even if JS fails
   GSAP targets elements with data-gsap, but if GSAP doesn't load, this ensures
   elements are visible after a reasonable delay for page load */
@media (prefers-reduced-motion: no-preference) {
    /* Animation fallback - show after 3 seconds if GSAP hasn't run */
    .opacity-0[data-gsap] {
        animation: reveal-fallback 0.5s ease-out 3s forwards;
    }
    
    @keyframes reveal-fallback {
        to {
            opacity: 1;
            transform: none;
        }
    }
}

/**
 * Portfolio Theme CSS
 * Custom utilities and overrides for Tailwind
 */

/* ==========================================================================
   Branding: Selection & Caret
   ========================================================================== */

::selection {
    background-color: #212842;
    color: #ffffff;
}

::-moz-selection {
    background-color: #212842;
    color: #ffffff;
}

input,
textarea,
[contenteditable] {
    caret-color: #212842;
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] [contenteditable] {
    caret-color: #e1d4c2;
}

/* ==========================================================================
   CSS Variables for Theme
   ========================================================================== */

:root {
    --color-bg: #e1d4c2;
    --color-text: #362017;
    --color-primary: #212842;
    --color-accent: #0a0a0a;
    --color-bg-secondary: rgba(255, 255, 255, 0.5);
    --color-border: rgba(54, 32, 23, 0.1);
    --color-header-bg: rgba(225, 212, 194, 0.95);
    /* Bubble ring color for light theme */
    --bubble-ring: #212842;
}

[data-theme="dark"] {
    --color-bg: #0a0a0a;
    --color-text: #e1d4c2;
    --color-primary: #e1d4c2;
    --color-accent: #e1d4c2;
    --color-bg-secondary: rgba(33, 40, 66, 0.3);
    --color-border: rgba(225, 212, 194, 0.2);
    --color-header-bg: rgba(10, 10, 10, 0.95);
    /* Bubble ring color for dark theme */
    --bubble-ring: #e1d4c2;
}

/* High-contrast fixes: ensure text and links meet contrast on indigodeep backgrounds */
[data-theme="dark"] .bg-indigodeep a,
[data-theme="dark"] .bg-indigodeep .text-white,
[data-theme="dark"] .bg-indigodeep .text-beige {
    color: #ffffff !important;
}

[data-theme="dark"] .text-white\/80,
[data-theme="dark"] .text-beige\/60 {
    color: rgba(255,255,255,0.95) !important;
}

/* Fix dark colors that would be invisible on dark backgrounds */
[data-theme="dark"] .text-ink\/60,
[data-theme="dark"] .text-ink\/70,
[data-theme="dark"] .text-ink\/80 {
    color: rgba(225, 212, 194, 0.6) !important;
}

/* Fix 01/02/03 numbers in deep-dive.html to be visible in dark mode */
[data-theme="dark"] .text-indigodeep\/20 {
    color: rgba(225, 212, 194, 0.3) !important;
}

/* Mini-game (easter egg) dark mode text colors */
[data-theme="dark"] #mini-game-root {
    color: #e1d4c2;
}

[data-theme="dark"] #mini-game-root .text-indigodeep {
    color: #e1d4c2 !important;
}

[data-theme="dark"] #mini-game-root .mg-end .text-indigodeep {
    color: #e1d4c2 !important;
}

[data-theme="dark"] #mini-game-root .mg-end a.text-indigodeep {
    color: #e1d4c2 !important;
    border-color: rgba(225, 212, 194, 0.2) !important;
}

[data-theme="dark"] #mini-game-root .mg-end a.text-indigodeep:hover {
    background-color: rgba(225, 212, 194, 0.1) !important;
}

/* Make Tailwind's dark: prefix work with [data-theme="dark"] */
[data-theme="dark"] .dark\:text-beige {
    color: #e1d4c2 !important;
}

[data-theme="dark"] .dark\:text-chocolate {
    color: #362017 !important;
}

[data-theme="dark"] .dark\:text-indigodeep {
    color: #212842 !important;
}

/* Apply theme colors to elements */
body {
    background-color: var(--color-bg) !important;
    color: var(--color-text) !important;
    overscroll-behavior-y: none; /* Prevent rubber-banding on mobile */
}

/* Typography: Balanced headings */
h1, h2, h3 {
    text-wrap: balance;
}

/* Blockquotes: Hanging punctuation */
blockquote {
    hanging-punctuation: first;
}

/* Image safety: prevent distortion */
img {
    max-width: 100%;
    height: auto;
    object-fit: cover;
}

header {
    background-color: var(--color-header-bg) !important;
    border-color: var(--color-border) !important;
}

.bg-beige {
    background-color: var(--color-bg) !important;
}

.text-chocolate {
    color: var(--color-text) !important;
}

/* Ensure text-chocolate variants also use the variable */
.text-chocolate\/60 {
    color: rgba(54, 32, 23, 0.6);
}

.text-chocolate\/70 {
    color: rgba(54, 32, 23, 0.7);
}

.text-chocolate\/80 {
    color: rgba(54, 32, 23, 0.8);
}

/* Dark mode: override text-chocolate variants to use beige */
[data-theme="dark"] .text-chocolate\/60 {
    color: rgba(225, 212, 194, 0.6) !important;
}

[data-theme="dark"] .text-chocolate\/70 {
    color: rgba(225, 212, 194, 0.7) !important;
}

[data-theme="dark"] .text-chocolate\/80 {
    color: rgba(225, 212, 194, 0.8) !important;
}

/* Dark mode: override arbitrary text-[#362017] classes (used in chat widgets) */
[data-theme="dark"] .text-\[\#362017\] {
    color: #e1d4c2 !important;
}

[data-theme="dark"] .text-\[\#362017\]\/60 {
    color: rgba(225, 212, 194, 0.6) !important;
}

[data-theme="dark"] .hover\:text-\[\#362017\]:hover {
    color: #e1d4c2 !important;
}

/* Dark mode: override hover:text-chocolate to use beige */
[data-theme="dark"] .hover\:text-chocolate:hover {
    color: #e1d4c2 !important;
}

.text-beige {
    color: #e1d4c2 !important;
}

.hover\:text-beige:hover {
    color: #e1d4c2 !important;
}

.text-indigodeep {
    color: var(--color-primary) !important;
}

.bg-indigodeep {
    background-color: var(--color-primary) !important;
}

.bg-white\/50,
.bg-white\/30 {
    background-color: var(--color-bg-secondary) !important;
}

.border-chocolate\/10 {
    border-color: var(--color-border) !important;
}

[data-theme="dark"] .bg-indigodeep {
    background-color: #212842 !important;
}

[data-theme="dark"] .text-white {
    color: #e1d4c2 !important;
}

[data-theme="dark"] footer {
    background-color: #212842 !important;
}

/* ==========================================================================
   Responsive Typography & Layout (Hybrid Approach - Mobile First)
   ========================================================================== */

/* Fluid typography - constrained to mobile/tablet only */
:root {
    /* Constrained fluid scaling - stops at desktop */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;
    --font-size-5xl: 3rem;
    --font-size-6xl: 3.75rem;
    --font-size-7xl: 4.5rem;
    
    /* Container padding - only fluid on mobile */
    --container-padding: 1.5rem;
}

/* Mobile-only fluid typography (below 1024px) */
@media (max-width: 1023px) {
    :root {
        --font-size-base: clamp(0.875rem, 0.8rem + 0.5vw, 1rem);
        --font-size-lg: clamp(1rem, 0.9rem + 0.625vw, 1.125rem);
        --font-size-xl: clamp(1.125rem, 1rem + 0.75vw, 1.25rem);
        --font-size-2xl: clamp(1.25rem, 1.1rem + 1vw, 1.5rem);
        --font-size-3xl: clamp(1.5rem, 1.2rem + 1.5vw, 1.875rem);
        --font-size-4xl: clamp(1.75rem, 1.4rem + 2vw, 2.25rem);
        --font-size-5xl: clamp(2rem, 1.5rem + 3vw, 3rem);
        --font-size-6xl: clamp(2.5rem, 2rem + 3.5vw, 3.75rem);
        --font-size-7xl: clamp(3rem, 2.5rem + 4vw, 4.5rem);
        
        --container-padding: clamp(1rem, 3vw, 1.5rem);
    }
}

/* Desktop: Lock to original sizes (1024px and above) */
@media (min-width: 1024px) {
    .text-xs { font-size: 0.75rem !important; line-height: 1rem !important; }
    .text-sm { font-size: 0.875rem !important; line-height: 1.25rem !important; }
    .text-base { font-size: 1rem !important; line-height: 1.5rem !important; }
    .text-lg { font-size: 1.125rem !important; line-height: 1.75rem !important; }
    .text-xl { font-size: 1.25rem !important; line-height: 1.75rem !important; }
    .text-2xl { font-size: 1.5rem !important; line-height: 2rem !important; }
    .text-3xl { font-size: 1.875rem !important; line-height: 2.25rem !important; }
    .text-4xl { font-size: 2.25rem !important; line-height: 2.5rem !important; }
    .text-5xl { font-size: 3rem !important; line-height: 1 !important; }
    .lg\:text-6xl { font-size: 3.75rem !important; line-height: 1 !important; }
    .lg\:text-7xl { font-size: 4.5rem !important; line-height: 1 !important; }
}

/* Mobile-only fluid typography */
@media (max-width: 1023px) {
    .text-xs { font-size: var(--font-size-xs) !important; }
    .text-sm { font-size: var(--font-size-sm) !important; }
    .text-base { font-size: var(--font-size-base) !important; }
    .text-lg { font-size: var(--font-size-lg) !important; }
    .text-xl { font-size: var(--font-size-xl) !important; }
    .text-2xl { font-size: var(--font-size-2xl) !important; }
    .text-3xl { font-size: var(--font-size-3xl) !important; }
    .text-4xl { font-size: var(--font-size-4xl) !important; }
    .text-5xl { font-size: var(--font-size-5xl) !important; }
    .text-6xl { font-size: var(--font-size-6xl) !important; }
    .text-7xl { font-size: var(--font-size-7xl) !important; }
}

/* Smooth mobile menu animations */
#mobile-menu {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#mobile-menu.hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

#mobile-menu:not(.hidden) {
    opacity: 1;
    transform: translateY(0);
}

#mobile-menu-toggle svg {
    transition: transform 0.3s ease;
}

/* Mobile-only: Fluid container padding */
@media (max-width: 1023px) {
    .container,
    section > div {
        padding-left: var(--container-padding) !important;
        padding-right: var(--container-padding) !important;
    }
    
    /* Ensure headings have breathing room on mobile */
    h1, h2, h3, h4, h5, h6 {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

/* Desktop: Original fixed padding */
@media (min-width: 1024px) {
    .px-6 { padding-left: 1.5rem !important; padding-right: 1.5rem !important; }
    .lg\:px-12 { padding-left: 3rem !important; padding-right: 3rem !important; }
    .py-20 { padding-top: 5rem !important; padding-bottom: 5rem !important; }
    .lg\:py-32 { padding-top: 8rem !important; padding-bottom: 8rem !important; }
    .py-12 { padding-top: 3rem !important; padding-bottom: 3rem !important; }
}

/* Desktop: Restore original max-widths */
@media (min-width: 1024px) {
    .max-w-7xl { max-width: 80rem !important; }
    .max-w-6xl { max-width: 72rem !important; }
    .max-w-5xl { max-width: 64rem !important; }
    .max-w-4xl { max-width: 56rem !important; }
    .max-w-3xl { max-width: 48rem !important; }
    .max-w-2xl { max-width: 42rem !important; }
    .max-w-xl { max-width: 36rem !important; }
}

/* Mobile: Constrained max-widths */
@media (max-width: 1023px) {
    .max-w-7xl { max-width: 95vw !important; }
    .max-w-6xl { max-width: 92vw !important; }
    .max-w-5xl { max-width: 90vw !important; }
    .max-w-4xl { max-width: 88vw !important; }
    .max-w-3xl { max-width: 85vw !important; }
    .max-w-2xl { max-width: 82vw !important; }
    .max-w-xl { max-width: 80vw !important; }
}

/* ==========================================================================
   Fix CTA button visibility in dark mode
   ========================================================================== */

[data-theme="dark"] .bg-indigodeep a.bg-white {
    background-color: #e1d4c2 !important;
    color: #212842 !important;
}

[data-theme="dark"] .bg-indigodeep a.bg-white:hover {
    background-color: #ffffff !important;
    color: #212842 !important;
}

/* ==========================================================================
   Base Styles & Resets
   ========================================================================== */

* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    background-color: var(--color-bg);
    color: var(--color-text);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ==========================================================================
   RTL Support for Arabic
   ========================================================================== */

[dir="rtl"] {
    text-align: right;
}

[dir="rtl"] .space-x-reverse > * + * {
    margin-right: var(--tw-space-x-reverse);
    margin-left: 0;
}

/* ==========================================================================
   Accessibility Utilities
   ========================================================================== */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.sr-only:not(.focus\:not-sr-only:focus) {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border-width: 0 !important;
}

/* ==========================================================================
   Custom Scrollbar
   ========================================================================== */

::-webkit-scrollbar {
    width: 12px;
}

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

::-webkit-scrollbar-thumb {
    background: #362017;
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: #212842;
}

/* ==========================================================================
   Focus Visible (Modern Browsers)
   ========================================================================== */

*:focus-visible {
    outline: 2px solid #212842;
    outline-offset: 2px;
}

/* ==========================================================================
   GSAP Animation Initial States
   ========================================================================== */

.js [data-gsap="fade-up"] {
    opacity: 0;
    transform: translateY(30px);
}

/* ==========================================================================
   Backdrop Blur Fallback
   ========================================================================== */

@supports not (backdrop-filter: blur(10px)) {
    .backdrop-blur-sm {
        background-color: rgba(225, 212, 194, 0.95);
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    header,
    nav,
    footer,
    .no-print,
    #chat-widget,
    #chat-window,
    #welcome-bubble,
    button {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    a {
        color: black !important;
        text-decoration: underline !important;
    }
}

/* ==========================================================================
   Mobile Menu Animation
   ========================================================================== */

#mobile-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
}

#mobile-menu:not(.hidden) {
    max-height: 500px;
}

/* ==========================================================================
   Custom Gradient Backgrounds
   ========================================================================== */

.gradient-hero {
    background: linear-gradient(135deg, #212842 0%, #362017 100%);
}

/* ==========================================================================
   Link Underline Animation
   ========================================================================== */

.link-underline {
    position: relative;
    text-decoration: none;
}

.link-underline::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 2px;
    bottom: -2px;
    left: 0;
    background-color: currentColor;
    transform: scaleX(0);
    transform-origin: bottom right;
    transition: transform 0.3s ease-out;
}

.link-underline:hover::after {
    transform: scaleX(1);
    transform-origin: bottom left;
}

/* ==========================================================================
   Chatbase Widget Customization
   ========================================================================== */

/* Override Chatbase default styles if needed */
#chatbase-bubble-button {
    bottom: 24px !important;
    right: 24px !important;
    width: 64px !important;
    height: 64px !important;
    /* Inverted background logic: light theme uses dark circle, dark theme uses light circle */
    background-color: #212842 !important; /* light theme base (dark) */
    border: 2px solid rgba(0,0,0,0.25) !important;
    border-radius: 50% !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    /* Layer 1 (top): ring that covers image corners; Layer 2: Savonie image */
    background-image: radial-gradient(circle at center, transparent 43%, var(--bubble-ring) 44%), url('/assets/img/savonie-icon.webp') !important;
    background-repeat: no-repeat, no-repeat !important;
    background-size: 100% 100%, 80% 80% !important; /* full-size ring + scaled icon */
    background-position: center center, center center !important;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: background-color 0.3s ease, border-color 0.3s ease, filter 0.3s ease;
}

[dir="rtl"] #chatbase-bubble-button {
    right: auto !important;
    left: 24px !important;
}

/* Invert state (auto applied via JS when over dark region) */
.chatbot-invert #chatbase-bubble-button,
#chatbase-bubble-button.chatbot-invert {
    /* Disable previous full-bubble inversion so the orangutan stays true-color */
    filter: none !important;
}

/* Dark theme adjustment so icon ring matches */
[data-theme="dark"] #chatbase-bubble-button {
    background-color: #e1d4c2 !important; /* invert to light circle in dark mode */
    border-color: rgba(225,212,194,0.35) !important;
}

/* Hide any default Chatbase icon layers so only our background shows */
#chatbase-bubble-button img,
#chatbase-bubble-button svg {
    display: none !important;
}

/* Reduce chat window size by targeting the window container */
#chatbase-bubble-window {
    max-width: 600px !important;
    max-height: 700px !important;
    width: 400px !important;
    height: 550px !important;
    min-width: 320px !important;
    min-height: 400px !important;
    right: 24px !important;
    bottom: 90px !important;
    border-radius: 12px !important;
    resize: none !important;
    overflow: hidden !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4) !important;
}

/* Edge hover resize visual feedback */
#chatbase-bubble-window.resize-hover-edge {
    box-shadow: 0 0 0 2px rgba(255,255,255,0.35), 0 0 0 6px rgba(255,255,255,0.08), 0 8px 32px rgba(0,0,0,0.45) !important;
}

#chatbase-bubble-window.resize-hover-corner {
    box-shadow: 0 0 0 2px rgba(255,255,255,0.45), 0 0 0 8px rgba(255,255,255,0.10), 0 8px 40px rgba(0,0,0,0.55) !important;
}

/* Overlay resize handles (explicit capture zones) */
.chatbase-edge-handle, .chatbase-corner-handle {
    position: absolute;
    z-index: 2147483648; /* above iframe */
    background: transparent; /* invisible by default */
    pointer-events: auto;
}
.chatbase-edge-handle:hover, .chatbase-corner-handle:hover {
    background: rgba(255,255,255,0.06);
}
.chatbase-edge-handle.top { top:0; left:0; height:28px; width:100%; cursor:ns-resize; }
.chatbase-edge-handle.bottom { bottom:0; left:0; height:28px; width:100%; cursor:ns-resize; }
.chatbase-edge-handle.left { left:0; top:0; width:28px; height:100%; cursor:ew-resize; }
.chatbase-edge-handle.right { right:0; top:0; width:28px; height:100%; cursor:ew-resize; }
.chatbase-corner-handle.tl { top:0; left:0; width:34px; height:34px; cursor:nwse-resize; }
.chatbase-corner-handle.tr { top:0; right:0; width:34px; height:34px; cursor:nesw-resize; }
.chatbase-corner-handle.bl { bottom:0; left:0; width:34px; height:34px; cursor:nesw-resize; }
.chatbase-corner-handle.br { bottom:0; right:0; width:34px; height:34px; cursor:nwse-resize; }

/* Chevron-down state when chat is open */
#chatbase-bubble-button.chatbot-open {
    /* Replace background with chevron-down arrow */
    background-image: none !important;
    background-color: var(--bubble-ring) !important;
}

#chatbase-bubble-button.chatbot-open::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    /* SVG chevron-down, color inverts by theme */
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23e1d4c2" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

[data-theme="dark"] #chatbase-bubble-button.chatbot-open::after {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23212842" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>');
}

/* ==========================================================================
   Form Input Enhancements
   ========================================================================== */

input[type="text"],
input[type="email"],
textarea,
select {
    transition: all 0.2s ease-in-out;
}

input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus,
select:focus {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(33, 40, 66, 0.1);
}

/* Theme-aware input backgrounds */
input[type="text"],
input[type="email"],
input[type="url"],
input[type="file"],
textarea,
select {
    background-color: var(--color-bg-secondary) !important;
    color: var(--color-text) !important;
}

[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="url"],
[data-theme="dark"] input[type="file"],
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background-color: rgba(33, 40, 66, 0.4) !important;
    border-color: rgba(225, 212, 194, 0.3) !important;
    color: #e1d4c2 !important;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: rgba(225, 212, 194, 0.5) !important;
}

/* ==========================================================================
   Loading States
   ========================================================================== */

.loading {
    opacity: 0.6;
    pointer-events: none;
    cursor: not-allowed;
}

/* ==========================================================================
   Card Hover Effects
   ========================================================================== */

.card-hover {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(33, 40, 66, 0.15);
}

/* ==========================================================================
   Responsive Utilities
   ========================================================================== */

@media (max-width: 768px) {
    h1 {
        font-size: 2.5rem;
        line-height: 1.2;
    }
    
    h2 {
        font-size: 2rem;
        line-height: 1.3;
    }
}

/* ==========================================================================
   High Contrast Mode Support
   ========================================================================== */

@media (prefers-contrast: high) {
    * {
        border-width: 2px !important;
    }
}

/* ==========================================================================
   Reduced Motion Support
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ==========================================================================
   Dark Mode Preparation (Future Use)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    /* Dark mode styles can be added here in the future */
}

/* ==========================================================================
   Dark Mode Toggle Button
   ========================================================================== */

.theme-toggle {
    position: relative;
    width: 92px;
    height: 32px;
    background: var(--color-primary);
    border-radius: 16px;
    cursor: pointer;
    transition: background 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.theme-toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

[data-theme="dark"] .theme-toggle-slider {
    transform: translateX(64px);
    background: #ffeb3b;
}

.theme-icon-sun,
.theme-icon-moon {
    width: 14px;
    height: 14px;
    transition: opacity 0.3s ease;
}

.theme-icon-sun {
    color: #fbbf24;
}

.theme-icon-moon {
    color: #212842;
    display: none;
}

[data-theme="dark"] .theme-icon-sun {
    display: none;
}

[data-theme="dark"] .theme-icon-moon {
    display: block;
    color: #212842;
}

/* Responsive theme toggle */
@media (max-width: 767px) {
    .theme-toggle {
        width: 70px;
        height: 28px;
        border-radius: 14px;
    }
    
    .theme-toggle-slider {
        width: 20px;
        height: 20px;
        top: 2px;
        left: 2px;
    }
    
    [data-theme="dark"] .theme-toggle-slider {
        transform: translateX(46px);
    }
    
    .theme-icon-sun,
    .theme-icon-moon {
        width: 12px;
        height: 12px;
    }
}

@media (max-width: 480px) {
    .theme-toggle {
        width: 40px;
        height: 40px;
        border-radius: 50%;
    }
    
    .theme-toggle-slider {
        width: 32px;
        height: 32px;
        top: 2px;
        left: 2px;
        border-radius: 50%;
    }
    
    [data-theme="dark"] .theme-toggle-slider {
        transform: translateX(0px);
        background: #ffeb3b;
    }
    
    .theme-icon-sun,
    .theme-icon-moon {
        width: 16px;
        height: 16px;
    }
}

/* ==========================================================================
   Draggable / Resizable Chat Component (Custom Replacement)
   ========================================================================== */

/* Hide original Chatbase bubble if present */
#chatbase-bubble-button { display: none !important; }

/* Bubble toggle button */
#custom-chat-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: var(--bubble-ring);
    box-shadow: 0 4px 16px rgba(0,0,0,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2147483600;
    border: 2px solid rgba(0,0,0,0.25);
    background-image: radial-gradient(circle at center, transparent 44%, var(--bubble-ring) 45%), url('/assets/img/savonie-icon.webp');
    background-size: 100% 100%, 78% 78%;
    background-position: center center;
    background-repeat: no-repeat;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

[data-theme="dark"] #custom-chat-bubble {
    background-color: #e1d4c2;
    border-color: rgba(225,212,194,0.35);
}

/* Welcome bubble dark mode */
[data-theme="dark"] #welcome-bubble {
    background-color: #212842;
    border-color: rgba(225,212,194,0.2);
}

[data-theme="dark"] #welcome-bubble p {
    color: #e1d4c2 !important;
}

#custom-chat-bubble:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.45);
}

#custom-chat-bubble:active { transform: scale(0.94); }

/* Panel container */
.draggable-chat-panel {
    position: fixed;
    bottom: 90px; /* initial offset above bubble */
    right: 24px;
    width: 420px;
    height: 560px;
    max-width: 600px;
    max-height: 700px;
    min-width: 320px;
    min-height: 400px;
    background: var(--color-accent);
    color: var(--color-text);
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    overflow: hidden;
    display: none;
    flex-direction: column;
    z-index: 2147483601;
    transition: box-shadow 0.25s ease;
}

[data-theme="dark"] .draggable-chat-panel { background: #000; }

.draggable-chat-panel.open { display: flex; }

.draggable-chat-header {
    flex: 0 0 46px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    background: var(--color-primary);
    color: #e1d4c2;
    cursor: move;
    user-select: none;
}

[data-theme="dark"] .draggable-chat-header { background: #212842; }

.draggable-chat-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .5px;
}

.draggable-chat-actions { display: flex; gap: 4px; }

.draggable-chat-actions button {
    background: transparent;
    border: none;
    color: #e1d4c2;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .18s ease, color .18s ease;
}

.draggable-chat-actions button:hover { background: rgba(255,255,255,0.14); }
.draggable-chat-actions button:active { background: rgba(255,255,255,0.22); }

.draggable-chat-content { flex: 1 1 auto; position: relative; }
.draggable-chat-content iframe { width:100%; height:100%; border:0; display:block; }

/* Corner resize handles (proportional) */
.chat-corner-handle {
    position: absolute;
    width: 24px; height: 24px;
    z-index: 2147483602;
    background: rgba(255,255,255,0.08);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #e1d4c2;
    cursor: nwse-resize;
    opacity: 0;
    transition: opacity .18s ease, background .18s ease;
}

.draggable-chat-panel.open .chat-corner-handle { opacity: .5; }
.chat-corner-handle:hover { background: rgba(255,255,255,0.22); opacity: 1; }

.chat-corner-handle.tl { top: 6px; left: 6px; cursor: nwse-resize; }
.chat-corner-handle.tr { top: 6px; right: 6px; cursor: nesw-resize; }
.chat-corner-handle.bl { bottom: 6px; left: 6px; cursor: nesw-resize; }
.chat-corner-handle.br { bottom: 6px; right: 6px; cursor: nwse-resize; }

/* Subtle outline when hovering panel edges (optional) */
.draggable-chat-panel.resizing { box-shadow: 0 0 0 3px rgba(255,255,255,0.25), 0 10px 42px rgba(0,0,0,0.55); }

/* Bubble hidden while panel open */
.chat-open-hide-bubble { display: none !important; }

/* ==========================================================================
   Scroll to Top Button
   ========================================================================== */

#scroll-to-top {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 50px;
    height: 50px;
    background: var(--color-primary);
    color: white;
    border: 2px solid var(--color-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#scroll-to-top:hover {
    background: var(--color-accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

#scroll-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#scroll-to-top svg {
    width: 24px;
    height: 24px;
}

@media (max-width: 768px) {
    #scroll-to-top {
        bottom: 20px;
        left: 20px;
        width: 45px;
        height: 45px;
    }
}

/* ==========================================================================
   Form Loading States & Validation
   ========================================================================== */

/* Loading spinner animation */
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Submit button loading state */
button[type="submit"].loading {
    position: relative;
    color: transparent;
    pointer-events: none;
    cursor: wait;
}

button[type="submit"].loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.6s linear infinite;
}

/* Inline error messages */
.inline-error {
    animation: fadeInError 0.3s ease;
}

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

/* Error border animation */
input.border-red-500,
textarea.border-red-500,
select.border-red-500 {
    border-color: #ef4444 !important;
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ==========================================================================
   Achievement Notifications
   ========================================================================== */

.achievement-notification {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--color-primary);
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10001;
    max-width: 350px;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.achievement-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.achievement-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.achievement-content {
    flex: 1;
}

.achievement-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.8;
    margin-bottom: 4px;
}

.achievement-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.achievement-desc {
    font-size: 13px;
    opacity: 0.9;
}

.achievement-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
    opacity: 0.7;
}

.achievement-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
    opacity: 1;
}

/* Dark mode achievement colors */
[data-theme="dark"] .achievement-notification {
    background: #e1d4c2;
    color: #362017;
}

[data-theme="dark"] .achievement-close {
    color: #362017;
}

@media (max-width: 768px) {
    .achievement-notification {
        bottom: 20px;
        right: 20px;
        left: 20px;
        max-width: none;
    }
}

/* ==========================================================================
   Konami Code Modal
   ========================================================================== */

.konami-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10002;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.konami-modal.show {
    opacity: 1;
}

.konami-content {
    background: var(--color-bg);
    border-radius: 20px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.konami-modal.show .konami-content {
    transform: scale(1);
}

.konami-header {
    background: var(--color-primary);
    color: white;
    padding: 24px;
    border-radius: 20px 20px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.konami-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
}

.konami-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 32px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.konami-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.konami-body {
    padding: 32px 24px;
    text-align: center;
}

.konami-message {
    font-size: 18px;
    color: var(--color-text);
    margin-bottom: 24px;
}

.konami-gift {
    background: var(--color-bg-secondary);
    border: 2px dashed var(--color-border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

.gift-emoji {
    font-size: 48px;
    margin-bottom: 12px;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.gift-text {
    font-size: 14px;
    color: var(--color-text);
    opacity: 0.8;
    margin-bottom: 12px;
}

.gift-code {
    display: block;
    background: var(--color-primary);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.gift-subtext {
    font-size: 13px;
    color: var(--color-text);
    opacity: 0.7;
}

.konami-stats {
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

.konami-stats p {
    font-size: 14px;
    color: var(--color-text);
}

.konami-stats strong {
    color: var(--color-primary);
    font-weight: 700;
}

/* ==========================================================================
   Testimonials Component
   ========================================================================== */

.testimonial-card {
    background: white;
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--color-border);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

[data-theme="dark"] .testimonial-card {
    background: var(--color-bg-secondary);
}

.testimonial-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.testimonial-quote {
    font-size: 1.125rem;
    line-height: 1.75;
    color: var(--color-text);
    font-style: italic;
    margin-bottom: 24px;
    position: relative;
}

.testimonial-quote::before {
    content: '"';
    position: absolute;
    left: -24px;
    top: -8px;
    font-size: 4rem;
    color: var(--color-primary);
    opacity: 0.2;
    font-family: Georgia, serif;
}

.testimonial-author {
    display: flex;
    align-items: center;
    gap: 16px;
}

.testimonial-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #212842, #362017);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 20px;
}

.testimonial-info h4 {
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 4px;
}

.testimonial-info p {
    font-size: 0.875rem;
    color: var(--color-text);
    opacity: 0.7;
}

/* ==========================================================================
   Blog Card Styles
   ========================================================================== */

.blog-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--color-border);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

[data-theme="dark"] .blog-card {
    background: var(--color-bg-secondary);
}

.blog-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.blog-card-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: linear-gradient(135deg, #e1d4c2, #a89682);
}

.blog-card-content {
    padding: 24px;
}

.blog-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 0.875rem;
    color: var(--color-text);
    opacity: 0.7;
}

.blog-card-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 12px;
    line-height: 1.3;
}

.blog-card-excerpt {
    color: var(--color-text);
    opacity: 0.8;
    line-height: 1.6;
    margin-bottom: 16px;
}

.blog-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.blog-tag {
    padding: 4px 12px;
    background: var(--color-primary);
    color: white;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

[data-theme="dark"] .blog-tag {
    background: var(--color-bg-secondary);
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
}

/* ==========================================================================
   Resume Download Button
   ========================================================================== */

.resume-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 14px 28px;
    background: linear-gradient(135deg, #212842, #362017);
    color: white;
    font-weight: 600;
    border-radius: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(33, 40, 66, 0.3);
}

.resume-download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(33, 40, 66, 0.4);
}

.resume-download-btn svg {
    width: 20px;
    height: 20px;
}

[data-theme="dark"] .resume-download-btn {
    background: linear-gradient(135deg, #e1d4c2, #a89682);
    color: #0a0a0a;
}

/* ==========================================================================
   Savonie AI Chat Widget Styles
   ========================================================================== */

/* Hide scrollbars in chat messages (keep clean look) */
#chat-messages::-webkit-scrollbar {
    display: none;
}

#chat-messages {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Visible horizontal scrollbar for chat chips */
#chat-chips {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(33, 40, 66, 0.3) transparent;
}

#chat-chips::-webkit-scrollbar {
    height: 4px;
    display: block;
}

#chat-chips::-webkit-scrollbar-track {
    background: rgba(54, 32, 23, 0.05);
    border-radius: 2px;
}

#chat-chips::-webkit-scrollbar-thumb {
    background: rgba(33, 40, 66, 0.25);
    border-radius: 2px;
}

#chat-chips::-webkit-scrollbar-thumb:hover {
    background: rgba(33, 40, 66, 0.4);
}

/* Dark mode chat chips scrollbar */
[data-theme="dark"] #chat-chips {
    scrollbar-color: rgba(225, 212, 194, 0.3) transparent;
}

[data-theme="dark"] #chat-chips::-webkit-scrollbar-track {
    background: rgba(225, 212, 194, 0.05);
}

[data-theme="dark"] #chat-chips::-webkit-scrollbar-thumb {
    background: rgba(225, 212, 194, 0.25);
}

[data-theme="dark"] #chat-chips::-webkit-scrollbar-thumb:hover {
    background: rgba(225, 212, 194, 0.4);
}

/* Proof-strip metrics: force beige text in dark mode */
[data-theme="dark"] #proof-strip .grid > .text-center > .text-5xl,
[data-theme="dark"] #proof-strip .grid > .text-center > .text-sm,
[data-theme="dark"] #proof-strip .grid > .text-center > .text-xs {
    color: #e1d4c2 !important;
}
/* Mobile chat widget adjustments */
@media (max-width: 640px) {
    #chat-widget {
        bottom: 1rem !important;
    }

    :lang(ar) #chat-widget {
        left: 1rem !important;
        right: auto !important;
    }

    :not(:lang(ar)) #chat-widget {
        right: 1rem !important;
        left: auto !important;
    }

    #chat-window {
        width: calc(100vw - 32px) !important;
        max-width: calc(100vw - 32px) !important;
        margin: 0 auto;
    }

    /* Allow dragged chat window to be positioned anywhere */
    #chat-window[style*="position: fixed"] {
        width: 320px !important;
        max-width: 320px !important;
        margin: 0 !important;
    }
}
    
    #chat-toggle {
        width: 56px !important;
        height: 56px !important;
    }
    
    #welcome-bubble {
        bottom: 80px !important;
        max-width: calc(100vw - 100px);
        font-size: 0.875rem;
    }

    :lang(ar) #welcome-bubble {
        left: 20px !important;
        right: auto !important;
    }

    :not(:lang(ar)) #welcome-bubble {
        right: 20px !important;
        left: auto !important;
    }
    
    /* Prevent chat from blocking content on mobile */
    body.chat-open {
        padding-bottom: 80px;
    }
}

/* Style links in bot messages to be visible and clickable */
#chat-messages a {
    color: #212842 !important;
    text-decoration: underline !important;
    font-weight: 600 !important;
    transition: color 0.2s ease;
}

#chat-messages a:hover {
    color: #362017 !important;
    text-decoration: none !important;
}

/* Ensure links in user messages stay white */
#chat-messages .bg-\[\#212842\] a {
    color: #e1d4c2 !important;
}

#chat-messages .bg-\[\#212842\] a:hover {
    color: #ffffff !important;
}

/* Dark Mode Chat Widget Styling */
[data-theme="dark"] #chat-window {
    background: linear-gradient(145deg, rgba(33, 40, 66, 0.98), rgba(20, 25, 40, 0.98)) !important;
    border-color: rgba(225, 212, 194, 0.15) !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5) !important;
}

[data-theme="dark"] #chat-header {
    background: linear-gradient(135deg, rgba(225, 212, 194, 0.12), rgba(225, 212, 194, 0.08)) !important;
    border-bottom: 1px solid rgba(225, 212, 194, 0.08) !important;
    backdrop-filter: blur(10px);
}

[data-theme="dark"] #chat-header h3 {
    color: #e1d4c2 !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] #close-chat {
    color: rgba(225, 212, 194, 0.7) !important;
    transition: all 0.2s ease;
}

[data-theme="dark"] #close-chat:hover {
    color: #e1d4c2 !important;
    transform: scale(1.1);
}

[data-theme="dark"] #chat-messages {
    background: rgba(10, 10, 10, 0.4) !important;
}

/* Bot messages in dark mode */
[data-theme="dark"] #chat-messages .bg-white {
    background: linear-gradient(135deg, rgba(225, 212, 194, 0.08), rgba(225, 212, 194, 0.05)) !important;
    border: 1px solid rgba(225, 212, 194, 0.12) !important;
    color: rgba(225, 212, 194, 0.95) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* User messages in dark mode */
[data-theme="dark"] #chat-messages .bg-\[\#212842\] {
    background: linear-gradient(135deg, rgba(225, 212, 194, 0.25), rgba(225, 212, 194, 0.20)) !important;
    color: #f5f0e8 !important;
    border: 1px solid rgba(225, 212, 194, 0.3) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    font-weight: 500;
}

/* Links in dark mode bot messages */
[data-theme="dark"] #chat-messages a {
    color: #f0e6d8 !important;
    text-decoration-color: rgba(240, 230, 216, 0.4) !important;
}

[data-theme="dark"] #chat-messages a:hover {
    color: #ffffff !important;
    text-decoration-color: rgba(255, 255, 255, 0.6) !important;
}

/* Links in dark mode user messages */
[data-theme="dark"] #chat-messages .bg-\[\#212842\] a {
    color: #0a0a0a !important;
    font-weight: 700 !important;
}

/* Chat chips in dark mode - completely redesigned */
[data-theme="dark"] #chat-chips {
    background: linear-gradient(180deg, rgba(225, 212, 194, 0.03), rgba(225, 212, 194, 0.01)) !important;
    border-top: 1px solid rgba(225, 212, 194, 0.08) !important;
    padding: 10px 12px !important;
}

/* Fix: Chat Chips Container - Horizontal Scrolling */
#chat-chips {
    display: flex !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    gap: 8px !important;
    padding-bottom: 4px !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important; /* Hide scrollbar on mobile */
}

/* Mobile: Hide scrollbar */
#chat-chips::-webkit-scrollbar {
    display: none !important;
}

/* Desktop: Show thin custom scrollbar for mouse users */
@media (min-width: 768px) {
    #chat-chips {
        scrollbar-width: thin !important;
        scrollbar-color: #212842 rgba(225, 212, 194, 0.2) !important;
    }
    
    #chat-chips::-webkit-scrollbar {
        display: block !important;
        height: 6px !important;
    }
    
    #chat-chips::-webkit-scrollbar-track {
        background: rgba(225, 212, 194, 0.2) !important;
        border-radius: 3px !important;
    }
    
    #chat-chips::-webkit-scrollbar-thumb {
        background: #212842 !important;
        border-radius: 3px !important;
    }
    
    #chat-chips::-webkit-scrollbar-thumb:hover {
        background: #362017 !important;
    }
    
    /* Dark mode scrollbar */
    [data-theme="dark"] #chat-chips {
        scrollbar-color: rgba(225, 212, 194, 0.6) rgba(225, 212, 194, 0.1) !important;
    }
    
    [data-theme="dark"] #chat-chips::-webkit-scrollbar-track {
        background: rgba(225, 212, 194, 0.1) !important;
    }
    
    [data-theme="dark"] #chat-chips::-webkit-scrollbar-thumb {
        background: rgba(225, 212, 194, 0.6) !important;
    }
    
    [data-theme="dark"] #chat-chips::-webkit-scrollbar-thumb:hover {
        background: rgba(225, 212, 194, 0.8) !important;
    }
}

/* Fix: AI Chat Bubble - Single Line Chips */
.chip-btn {
    white-space: nowrap !important;
    flex: 0 0 auto !important;
    width: auto !important;
    height: auto !important;
    color: #212842 !important;
    line-height: 1.4;
}

[data-theme="dark"] .chip-btn {
    background: linear-gradient(135deg, rgba(225, 212, 194, 0.12), rgba(225, 212, 194, 0.08)) !important;
    border: 1px solid rgba(225, 212, 194, 0.2) !important;
    color: rgba(225, 212, 194, 0.9) !important;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .chip-btn:hover {
    background: linear-gradient(135deg, rgba(225, 212, 194, 0.2), rgba(225, 212, 194, 0.15)) !important;
    color: #e1d4c2 !important;
    border-color: rgba(225, 212, 194, 0.35) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Input section in dark mode - refined */
[data-theme="dark"] #chat-input {
    background: rgba(10, 10, 10, 0.5) !important;
    color: #e1d4c2 !important;
    border: 1px solid rgba(225, 212, 194, 0.15) !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] #chat-input::placeholder {
    color: rgba(225, 212, 194, 0.4) !important;
}

[data-theme="dark"] #chat-input:focus {
    border-color: rgba(225, 212, 194, 0.3) !important;
    box-shadow: 0 0 0 2px rgba(225, 212, 194, 0.1), inset 0 2px 4px rgba(0, 0, 0, 0.2) !important;
}

[data-theme="dark"] #send-btn {
    background: linear-gradient(135deg, rgba(225, 212, 194, 0.2), rgba(225, 212, 194, 0.15)) !important;
    color: #e1d4c2 !important;
    border: 1px solid rgba(225, 212, 194, 0.2);
    transition: all 0.2s ease;
}

[data-theme="dark"] #send-btn:hover {
    background: linear-gradient(135deg, rgba(225, 212, 194, 0.3), rgba(225, 212, 194, 0.25)) !important;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Welcome bubble in dark mode */
[data-theme="dark"] #welcome-bubble {
    background: linear-gradient(135deg, rgba(33, 40, 66, 0.98), rgba(20, 25, 40, 0.98)) !important;
    border: 1px solid rgba(225, 212, 194, 0.2) !important;
    color: #e1d4c2 !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* Toggle button in dark mode */
[data-theme="dark"] #chat-toggle {
    background: linear-gradient(135deg, rgba(225, 212, 194, 0.25), rgba(225, 212, 194, 0.15)) !important;
    border: 2px solid rgba(225, 212, 194, 0.3) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] #chat-toggle:hover {
    border-color: rgba(225, 212, 194, 0.4) !important;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

/* Project cards in dark mode */
[data-theme="dark"] #chat-messages .bg-white.rounded-lg.shadow-md {
    background: linear-gradient(135deg, rgba(225, 212, 194, 0.1), rgba(225, 212, 194, 0.05)) !important;
    border: 1px solid rgba(225, 212, 194, 0.15) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

[data-theme="dark"] #chat-messages .bg-white.rounded-lg.shadow-md h4 {
    color: #e1d4c2 !important;
}

[data-theme="dark"] #chat-messages .bg-white.rounded-lg.shadow-md a {
    background: linear-gradient(135deg, rgba(225, 212, 194, 0.2), rgba(225, 212, 194, 0.15)) !important;
    color: #e1d4c2 !important;
    border: 1px solid rgba(225, 212, 194, 0.25);
    transition: all 0.2s ease;
}

[data-theme="dark"] #chat-messages .bg-white.rounded-lg.shadow-md a:hover {
    background: linear-gradient(135deg, rgba(225, 212, 194, 0.3), rgba(225, 212, 194, 0.25)) !important;
    border-color: rgba(225, 212, 194, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   Voice Input Microphone Button
   ========================================================================== */

#mic-btn {
    background-color: transparent;
    color: #362017;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#mic-btn:hover {
    background-color: rgba(33, 40, 66, 0.1);
    color: #212842;
}

#mic-btn.listening {
    background-color: #dc2626;
    color: white;
    animation: pulse-mic 1s infinite;
}

@keyframes pulse-mic {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 8px rgba(220, 38, 38, 0);
    }
}

/* Dark mode mic button */
[data-theme="dark"] #mic-btn {
    color: #e1d4c2;
}

[data-theme="dark"] #mic-btn:hover {
    background-color: rgba(225, 212, 194, 0.15);
    color: #ffffff;
}

[data-theme="dark"] #mic-btn.listening {
    background-color: #dc2626;
    color: white;
}

/* ========================================
   ACCESSIBILITY: Touch Targets & Contrast
   ======================================== */

/* Minimum 48x48px touch targets for mobile */
#chat-toggle,
#mobile-menu-toggle,
#send-btn,
#mic-btn,
#theme-toggle,
#scroll-to-top {
    min-width: 48px;
    min-height: 48px;
}

/* Improved contrast for beige text on dark backgrounds (WCAG AA) */
.text-beige\/80 {
    color: rgba(225, 212, 194, 0.95) !important;
}

[data-theme="dark"] .text-beige\/60 {
    color: rgba(225, 212, 194, 0.85) !important;
}

/* Ensure footer links have sufficient contrast in dark mode */
[data-theme="dark"] footer a {
    color: rgba(225, 212, 194, 0.9);
}

[data-theme="dark"] footer a:hover {
    color: #ffffff;
}

/* ==========================================================================
   Custom Chat Widget Dark Mode Styles
   ========================================================================== */

[data-theme="dark"] #chat-widget .p-4.bg-white {
    background-color: #362017 !important;
}

[data-theme="dark"] #mic-btn {
    background-color: #362017 !important;
}

[data-theme="dark"] #send-btn {
    background-color: #362017 !important;
}

[data-theme="dark"] #chat-input {
    background-color: #362017 !important;
    color: #e1d4c2 !important;
}

/* Dark mode styles for suggestions button */
[data-theme="dark"] #suggestions-btn {
    background-color: #362017 !important;
}

/* Dark mode styles for chip close button */
[data-theme="dark"] .chip-close-btn {
    font-size: 1.25rem !important; /* text-lg */
    color: #e1d4c2 !important;
}

/* Konami Code Gift Animations */
.gift-emoji {
    font-size: 4rem;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: bounce 2s infinite;
}

.gift-emoji:hover {
    transform: scale(1.1);
}

.gift-emoji.gift-opened {
    animation: gift-open 0.6s ease forwards;
}

@keyframes gift-open {
    0% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(1.2) rotate(180deg);
        opacity: 0.8;
    }
    100% {
        transform: scale(0) rotate(360deg);
        opacity: 0;
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.compliment-container {
    text-align: center;
    animation: fadeInUp 0.8s ease forwards;
}

.compliment-text {
    font-size: 1.5rem;
    font-weight: bold;
    color: #362017;
    margin: 0;
    animation: sparkle-text 2s ease-in-out infinite alternate;
}

[data-theme="dark"] .compliment-text {
    color: #e1d4c2;
}

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

@keyframes sparkle-text {
    from {
        text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
    }
    to {
        text-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 0 0 30px rgba(255, 215, 0, 0.6);
    }
}

/* Confetti Animation */
.confetti {
    position: fixed;
    top: -10px;
    width: 10px;
    height: 10px;
    z-index: 10001;
    animation: confetti-fall linear infinite;
    pointer-events: none;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-10px) rotate(0deg);
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
    }
}

/* Sparkle effect */
.sparkle::before {
    content: '✨';
    position: absolute;
    left: -20px;
    top: -20px;
    font-size: 2rem;
    animation: sparkle-float 3s ease-in-out infinite;
}

.sparkle::after {
    content: '✨';
    position: absolute;
    right: -20px;
    bottom: -20px;
    font-size: 1.5rem;
    animation: sparkle-float 3s ease-in-out infinite 1s;
}

@keyframes sparkle-float {
    0%, 100% {
        transform: translateY(0px) scale(1);
        opacity: 0.7;
    }
    50% {
        transform: translateY(-10px) scale(1.2);
        opacity: 1;
    }
}

/* Performance: Skip rendering off-screen content */
footer, .section-below-fold {
    content-visibility: auto;
    contain-intrinsic-size: 1px 1000px;
}

/* Fix: Chat widget high z-index for mobile visibility */
#chat-widget {
    z-index: 9999 !important;
}

/* Fix: Chat message links - bold and underlined */
#chat-messages a {
    font-weight: 700 !important;
    text-decoration: underline !important;
}

/* Fix: Mobile language button spacing - reduce gap and padding */
@media (max-width: 640px) {
    /* Brand logo - reduce font size on mobile to prevent collision */
    #brand-logo {
        font-size: 1.125rem !important; /* text-lg */
        margin-right: 8px !important;
        flex-shrink: 1 !important;
        min-width: 0 !important;
    }
    
    /* Language switcher container - prevent crushing */
    #lang-switcher {
        flex-shrink: 0 !important;
        gap: 0.5rem !important;
    }
    
    /* Language link buttons - reduce padding on mobile */
    #lang-switcher a {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
}

/* Extra small screens - further reduce brand logo font */
@media (max-width: 360px) {
    #brand-logo {
        font-size: 1rem !important; /* text-base */
    }
}

/* ==========================================================================
   Scroll Progress Bar (CSS-only)
   ========================================================================== */

.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
    z-index: 9998;
}

.scroll-progress::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(to right, #212842 var(--scroll-progress, 0%), transparent 0%);
    transform-origin: 0 50%;
    animation: scroll-progress linear;
    animation-timeline: scroll();
}

@supports (animation-timeline: scroll()) {
    @keyframes scroll-progress {
        from { --scroll-progress: 0%; }
        to { --scroll-progress: 100%; }
    }
}

/* Fallback for browsers without scroll timeline support */
@supports not (animation-timeline: scroll()) {
    .scroll-progress::before {
        display: none;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    /* Hide non-essential elements */
    header,
    footer,
    nav,
    #chat-widget,
    .scroll-progress,
    #scroll-to-top,
    .no-print {
        display: none !important;
    }
    
    /* Reset backgrounds */
    body {
        background: white !important;
        color: black !important;
    }
    
    /* Reset colors for readability */
    * {
        color: black !important;
        background: white !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    /* Ensure links are visible */
    a {
        text-decoration: underline !important;
    }
    
    /* Show URLs after links */
    a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        word-break: break-all;
    }
    
    /* Don't show URLs for navigation links */
    a[href^="/"]::after,
    a[href^="#"]::after {
        content: none;
    }
    
    /* Reset margins and padding */
    main {
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* Avoid page breaks inside important elements */
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }
    
    img, figure, blockquote {
        page-break-inside: avoid;
    }
    
    /* Ensure images print */
    img {
        max-width: 100% !important;
        filter: none !important;
    }
}

