/* ═══════════════════════════════════════════════════════════════════════════════
   ORAVYS NANO-RESPONSIVE SYSTEM v1.0
   Garantit la responsivité parfaite de 200px à 4K
   À inclure dans TOUS les templates : <link rel="stylesheet" href="/static/css/nano-responsive.css">
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════════════════
   1. RESET & BASE CENTERING
   ═══════════════════════════════════════════════════════════════════════════════ */

*, *::before, *::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Hide scrollbars globally while keeping scroll functionality */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    display: none; /* Chrome/Safari/WebKit */
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport for mobile */
    overflow-x: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

/* Force centering on all major containers */
.app-container,
.container,
.main-container,
.report-container,
.glass-card,
.card,
main,
section,
article {
    width: 100%;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* Perfect Horizontal Centering for Mobile */
@media (max-width: 768px) {
    .container, .app-container, .card, .glass-card, .main-container {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
    }
}

/* Perfect Horizontal Centering for Flex Items */
.flex-center, .flex-col-center {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    text-align: center !important;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   2. FLUID TYPOGRAPHY (scales from 200px to 2000px)
   ═══════════════════════════════════════════════════════════════════════════════ */

:root {
    /* Fluid font sizes using clamp() */
    --fs-nano: clamp(0.5rem, 2vw, 0.75rem);
    --fs-xs: clamp(0.6rem, 2.5vw, 0.8rem);
    --fs-sm: clamp(0.7rem, 3vw, 0.9rem);
    --fs-base: clamp(0.8rem, 3.5vw, 1rem);
    --fs-md: clamp(0.9rem, 4vw, 1.1rem);
    --fs-lg: clamp(1rem, 4.5vw, 1.3rem);
    --fs-xl: clamp(1.2rem, 5vw, 1.8rem);
    --fs-2xl: clamp(1.5rem, 6vw, 2.5rem);
    --fs-hero: clamp(2rem, 8vw, 4rem);
    
    /* Fluid spacing */
    --space-nano: clamp(2px, 0.5vw, 4px);
    --space-xs: clamp(4px, 1vw, 8px);
    --space-sm: clamp(6px, 1.5vw, 12px);
    --space-md: clamp(8px, 2vw, 16px);
    --space-lg: clamp(12px, 3vw, 24px);
    --space-xl: clamp(16px, 4vw, 32px);
    --space-2xl: clamp(20px, 5vw, 48px);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   3. RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────────────────
   NANO: 0 - 220px (Smartwatch, Ultra-Small)
   ───────────────────────────────────────────────────────────────────────────── */
@media (max-width: 220px) {
    html {
        font-size: 10px !important;
    }
    
    body {
        padding: 2px !important;
        font-size: 0.8rem !important;
        line-height: 1.3 !important;
        text-align: center !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
    }
    
    /* Global Reset for Nano Screens */
    * {
        min-width: 0 !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Force single column for EVERYTHING */
    .grid, .grid-2, .grid-3, .grid-4, .grid-auto,
    [class*="grid-"], .flex-row, .row, .sidebar, .main-content,
    .page-center-wrapper, .flex-center, .justify-center {
        display: flex !important;
        flex-direction: column !important;
        gap: 4px !important;
        width: 100% !important;
        min-width: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        position: static !important;
        height: auto !important;
        align-items: center !important;
        justify-content: flex-start !important;
    }
    
    /* Compact containers */
    .container, .app-container, main, .card, .glass-card,
    .report-container, section, article {
        padding: 4px !important;
        margin: 2px auto !important;
        width: calc(100% - 4px) !important;
        max-width: 100% !important;
        border-radius: 6px !important;
        min-height: 0 !important;
        display: block !important;
    }
    
    /* Layout Parts */
    header, .header, footer, .footer, .top-bar, .bottom-nav {
        width: 100% !important;
        padding: 4px 8px !important;
        position: static !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 4px !important;
    }
    
    /* Typography scaling */
    h1, .title-xl { font-size: 1.1rem !important; line-height: 1.2 !important; margin-bottom: 4px !important; }
    h2, .title-lg { font-size: 0.95rem !important; line-height: 1.2 !important; margin-bottom: 3px !important; }
    h3, .title-md { font-size: 0.85rem !important; line-height: 1.2 !important; margin-bottom: 2px !important; }
    h4, h5, h6 { font-size: 0.75rem !important; line-height: 1.2 !important; }
    p, span, div, label { font-size: 0.7rem !important; line-height: 1.3 !important; }
    
    /* Buttons - Stack and fill width */
    button, .btn, [class*="btn-"], input[type="submit"], input[type="button"] {
        width: 100% !important;
        min-height: 32px !important;
        padding: 6px 8px !important;
        font-size: 0.7rem !important;
        border-radius: 6px !important;
        margin-bottom: 4px !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
    }
    
    /* Inputs */
    input, textarea, select {
        width: 100% !important;
        padding: 6px !important;
        font-size: 0.75rem !important;
        border-radius: 6px !important;
    }
    
    /* Hide non-essential elements */
    .hide-nano, .no-nano, .desktop-only,
    .nav-logo span, .brand-text, .logo-text,
    .watermark, .qrcode, #qrcode,
    .decorative, .illustration,
    .tooltip, [data-tooltip],
    .subtitle:not(.keep-nano),
    .description:not(.keep-nano) {
        display: none !important;
    }
    
    /* Navigation - Vertical stack */
    nav, .nav-bar, .nav-links, .navbar {
        flex-direction: column !important;
        padding: 4px !important;
        gap: 2px !important;
    }
    
    .nav-btn, .nav-link {
        width: 100% !important;
        text-align: center !important;
        padding: 6px !important;
        font-size: 0.65rem !important;
    }
    
    /* Tables - Block layout */
    table { display: block !important; width: 100% !important; overflow-x: auto !important; }
    thead { display: none !important; }
    tbody, tr, td, th {
        display: block !important;
        width: 100% !important;
        text-align: center !important;
        padding: 3px !important;
        font-size: 0.65rem !important;
    }
    tr { 
        border: 1px solid rgba(255,255,255,0.1) !important;
        margin-bottom: 4px !important;
        border-radius: 4px !important;
    }
    
    /* Images - Scale down */
    img, svg:not(.icon):not(.logo-icon) {
        max-width: 80% !important;
        height: auto !important;
        margin: 0 auto !important;
        display: block !important;
    }
    
    /* Icons - Smaller */
    .icon, i, svg.icon, .fa, .fas, .far, .fab {
        font-size: 0.8rem !important;
        width: 16px !important;
        height: 16px !important;
    }
    
    /* Metrics and values */
    .metric-value, .m-val, .value, .score {
        font-size: 1rem !important;
    }
    
    /* Progress bars */
    .progress-bar, .bar, [class*="progress"] {
        height: 4px !important;
    }
    
    /* Modals and Dropdowns */
    .modal, .modal-content, .popup, .overlay-content,
    .uni-menu-dropdown, .dropdown-menu {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: 95vh !important;
        padding: 8px !important;
        border-radius: 8px !important;
        margin: 0 !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        transform: none !important;
    }
    
    /* Force text wrapping */
    * {
        white-space: normal !important;
        word-break: break-word !important;
        hyphens: auto !important;
    }
    
    /* Keep icons inline */
    i, .icon, svg.icon {
        white-space: nowrap !important;
        display: inline-block !important;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   MICRO: 221px - 320px (Small phones, old devices)
   ───────────────────────────────────────────────────────────────────────────── */
@media (min-width: 221px) and (max-width: 320px) {
    html {
        font-size: 12px;
    }
    
    body {
        padding: 4px;
        text-align: center;
    }
    
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr !important;
        gap: 8px;
    }
    
    .container, .app-container, main {
        padding: 8px;
    }
    
    h1 { font-size: 1.3rem; }
    h2 { font-size: 1.1rem; }
    h3 { font-size: 0.95rem; }
    
    button, .btn {
        padding: 10px 12px;
        font-size: 0.8rem;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   SMALL: 321px - 480px (Standard phones)
   ───────────────────────────────────────────────────────────────────────────── */
@media (min-width: 321px) and (max-width: 480px) {
    html {
        font-size: 14px;
    }
    
    body {
        padding: 8px;
    }
    
    .grid-3, .grid-4 {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .grid-2 {
        grid-template-columns: 1fr;
    }
    
    .container, .app-container {
        padding: 12px;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   MEDIUM: 481px - 768px (Large phones, small tablets)
   ───────────────────────────────────────────────────────────────────────────── */
@media (min-width: 481px) and (max-width: 768px) {
    html {
        font-size: 15px;
    }
    
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .container, .app-container {
        padding: 16px;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   TABLET: 769px - 1024px
   ───────────────────────────────────────────────────────────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
    html {
        font-size: 16px;
    }
    
    .container, .app-container {
        max-width: 900px;
        padding: 20px;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   DESKTOP: 1025px+
   ───────────────────────────────────────────────────────────────────────────── */
@media (min-width: 1025px) {
    .container, .app-container {
        max-width: 1200px;
        padding: 24px;
    }
    
    /* Show desktop-only elements */
    .desktop-only {
        display: block !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   4. CENTERING UTILITIES
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Flexbox center */
.flex-center {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.flex-center-col {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Grid center */
.grid-center {
    display: grid !important;
    place-items: center !important;
}

/* Text center */
.text-center {
    text-align: center !important;
}

/* Margin auto center */
.mx-auto {
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Full-page centering (for login pages, splash screens) */
.page-center {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    padding: var(--space-md) !important;
}

/* Card centering */
.card-center {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    margin: 0 auto !important;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   5. SAFE AREA INSETS (iPhone notch, Android gesture bar)
   ═══════════════════════════════════════════════════════════════════════════════ */

@supports (padding: env(safe-area-inset-top)) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    /* Fixed elements need safe areas too */
    .fixed-bottom, .sticky-bottom, [class*="fixed"][class*="bottom"] {
        padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom));
    }
    
    .fixed-top, .sticky-top, [class*="fixed"][class*="top"] {
        padding-top: calc(var(--space-md) + env(safe-area-inset-top));
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   6. TOUCH-FRIENDLY TARGETS (WCAG 2.5.5 - 44x44px minimum)
   ═══════════════════════════════════════════════════════════════════════════════ */

@media (pointer: coarse) {
    button, .btn, [class*="btn-"],
    input[type="button"], input[type="submit"], input[type="reset"],
    a.button, .clickable, [role="button"],
    .nav-btn, .nav-link, .tab-btn {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 16px;
    }
    
    /* Larger tap targets for small screens */
    @media (max-width: 320px) {
        button, .btn, [class*="btn-"] {
            min-height: 40px;
            padding: 10px 14px;
        }
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   7. OVERLAY & MODAL SAFETY (Prevent blocking)
   Based on: https://cloud.google.com/appsheet - "Invisible Glass Wall" Fix
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Hidden overlays should never block clicks */
.overlay:not(.visible):not(.active):not(.show):not(.open),
.modal:not(.visible):not(.active):not(.show):not(.open),
.processing-overlay:not(.visible):not(.active),
[class*="overlay"]:not(.visible):not(.active):not(.show):not(.open) {
    pointer-events: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

/* Visible overlays get pointer events */
.overlay.visible, .overlay.active, .overlay.show, .overlay.open,
.modal.visible, .modal.active, .modal.show, .modal.open,
.processing-overlay.visible {
    pointer-events: auto !important;
}

/* CRITICAL: Google Translate overlay safety */
.oravys-gt-overlay:not(.open),
.oravys-overlay:not(.open),
.goog-te-menu-frame:not(.visible) {
    pointer-events: none !important;
}

/* CRITICAL: Ensure buttons are always clickable above any hidden layers */
button, .btn, [class*="btn-"], 
input[type="submit"], input[type="button"],
a.button, [role="button"], .clickable,
.record-btn, .start-btn, .action-btn {
    position: relative;
    z-index: 10 !important;
}

/* Emergency clickability - main action buttons */
.record-btn, #recordBtn, #startBtn, .start-button,
[id*="record"], [id*="start"], [class*="record"], [class*="start"] {
    pointer-events: auto !important;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   8. GOOGLE TRANSLATE STABILITY
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Prevent Google Translate from breaking layout */
.notranslate, [translate="no"] {
    transform: none !important;
    position: relative !important;
}

/* Center content after translation */
body.translated-ltr,
html.translated-ltr {
    text-align: center;
}

/* Hide Google Translate banner to save space on nano */
@media (max-width: 320px) {
    .goog-te-banner-frame,
    .goog-te-balloon-frame,
    #goog-gt-tt {
        display: none !important;
    }
    
    body {
        top: 0 !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   9. PRINT STYLES
   ═══════════════════════════════════════════════════════════════════════════════ */

@media print {
    body {
        background: white !important;
        color: black !important;
        font-size: 12pt !important;
    }
    
    .no-print, .hide-print,
    nav, .nav-bar, .navbar,
    .overlay, .modal,
    button:not(.keep-print),
    .feedback-hub, .watermark {
        display: none !important;
    }
    
    .card, .glass-card, section {
        background: white !important;
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        page-break-inside: avoid;
    }
    
    a {
        color: black !important;
        text-decoration: underline !important;
    }
    
    a::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   10. ACCESSIBILITY
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Reduced motion for users who prefer it */
@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;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    button, .btn, [class*="btn-"] {
        border: 2px solid currentColor !important;
    }
    
    .card, .glass-card {
        border: 2px solid currentColor !important;
    }
}

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 2px solid #7c3aed !important;
    outline-offset: 2px !important;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   11. UTILITY CLASSES
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Visibility */
.show-nano { display: none !important; }
@media (max-width: 220px) { .show-nano { display: block !important; } }

.hide-mobile { display: block; }
@media (max-width: 768px) { .hide-mobile { display: none !important; } }

.show-mobile { display: none; }
@media (max-width: 768px) { .show-mobile { display: block !important; } }

/* Spacing */
.p-0 { padding: 0 !important; }
.p-nano { padding: var(--space-nano) !important; }
.p-xs { padding: var(--space-xs) !important; }
.p-sm { padding: var(--space-sm) !important; }
.p-md { padding: var(--space-md) !important; }
.p-lg { padding: var(--space-lg) !important; }

.m-0 { margin: 0 !important; }
.m-auto { margin: auto !important; }

/* Width */
.w-full { width: 100% !important; }
.w-auto { width: auto !important; }
.max-w-full { max-width: 100% !important; }

/* Text */
.text-xs { font-size: var(--fs-xs) !important; }
.text-sm { font-size: var(--fs-sm) !important; }
.text-base { font-size: var(--fs-base) !important; }
.text-lg { font-size: var(--fs-lg) !important; }
.text-xl { font-size: var(--fs-xl) !important; }

.truncate {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

.wrap {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    hyphens: auto !important;
}

/* Flex */
.flex { display: flex !important; }
.flex-col { flex-direction: column !important; }
.flex-wrap { flex-wrap: wrap !important; }
.items-center { align-items: center !important; }
.justify-center { justify-content: center !important; }
.gap-sm { gap: var(--space-sm) !important; }
.gap-md { gap: var(--space-md) !important; }

/* Position */
.relative { position: relative !important; }
.absolute { position: absolute !important; }
.fixed { position: fixed !important; }
.sticky { position: sticky !important; }

/* Overflow */
.overflow-hidden { overflow: hidden !important; }
.overflow-auto { overflow: auto !important; }
.overflow-x-hidden { overflow-x: hidden !important; }
.overflow-y-auto { overflow-y: auto !important; }

/* ═══════════════════════════════════════════════════════════════════════════════
   7. SYSTEM UI COMPONENTS (Language, Home, Recording)
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Universal Language Button */
.oravys-gt-btn {
    position: fixed !important;
    bottom: 25px !important;
    left: 25px !important;
    z-index: 9999 !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%) !important;
    box-shadow: 0 8px 25px rgba(124, 58, 237, 0.4) !important;
    border: 1px solid rgba(255,255,255,0.2) !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    transition: all 0.3s ease !important;
}

/* Universal Home Button */
#home-btn, .universal-home-btn {
    position: fixed !important;
    bottom: 25px !important;
    right: 25px !important;
    z-index: 9999 !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(20, 10, 40, 0.8) !important;
    backdrop-filter: blur(10px) !important;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3) !important;
    border: 1px solid rgba(139, 92, 246, 0.3) !important;
    color: #a78bfa !important;
    text-decoration: none !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    transition: all 0.3s ease !important;
}

/* Adjust for App Bottom Nav */
body.has-bottom-nav .oravys-gt-btn,
body.has-bottom-nav #home-btn {
    bottom: 85px !important;
}

@media (max-width: 768px) {
    .oravys-gt-btn, #home-btn {
        width: 40px !important;
        height: 40px !important;
        bottom: 20px !important;
    }
    body.has-bottom-nav .oravys-gt-btn,
    body.has-bottom-nav #home-btn {
        bottom: 80px !important;
    }
}

/* Critical Action Buttons Fix */
.record-btn, #recordBtn, #startBtn, .start-button, .record-first-cta, .mn-item.main-action {
    pointer-events: auto !important;
    z-index: 1000 !important;
}

/* Ensure no invisible overlays block buttons */
.modal-overlay:not(.active), .prm-overlay:not(.active), #sidebarOverlay:not(.active) {
    pointer-events: none !important;
}

