/**
 * Lydian Agent - Mobile Fix & Responsive Override
 * Critical mobile fixes for all devices
 * MUST load LAST to override all other styles
 */

/* ============================================
   CRITICAL VIEWPORT & BASE FIXES
   ============================================ */

* {
    -webkit-overflow-scrolling: touch !important;
    -webkit-tap-highlight-color: transparent !important;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: hidden !important;
}

body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
    position: relative;
}

/* ============================================
   NAVIGATION - MOBILE FIRST - FIXED LAYOUT
   ============================================ */

nav {
    width: 100% !important;
    padding: 12px 0 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1000 !important;
    background: rgba(15, 23, 42, 0.95) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
}

/* Body scroll lock when menu open */
body.menu-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
}

.nav-container {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 0 16px !important;
    max-width: 100% !important;
    gap: 12px !important;
}

/* Mobile Header Layout - Perfect Alignment */
@media (max-width: 1023px) {
    .nav-container {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 0 16px !important;
        gap: 12px !important;
    }

    .logo {
        flex-shrink: 0 !important;
        margin-right: auto !important;
    }

    .mobile-menu-toggle {
        flex-shrink: 0 !important;
        order: 2 !important;
        margin-left: 8px !important;
    }

    .lang-switch {
        flex-shrink: 0 !important;
        order: 1 !important;
        margin-left: 0 !important;
    }

    /* Hide desktop nav on mobile */
    .nav-links:not(.active) {
        display: none !important;
    }
}

/* Logo - Mobile Optimized */
.logo {
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
}

.logo-icon {
    width: 36px !important;
    height: 36px !important;
    flex-shrink: 0 !important;
}

.logo-icon i {
    font-size: 18px !important;
}

.logo-brand {
    font-size: 18px !important;
    white-space: nowrap !important;
}

.logo-tagline {
    font-size: 7px !important;
    display: none !important;
}

@media (min-width: 480px) {
    .logo-icon {
        width: 40px !important;
        height: 40px !important;
    }

    .logo-icon i {
        font-size: 20px !important;
    }

    .logo-brand {
        font-size: 20px !important;
    }

    .logo-tagline {
        display: block !important;
        font-size: 8px !important;
    }
}

/* Mobile Menu Overlay */
@media (max-width: 1023px) {
    .nav-links {
        display: none !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100vh !important;
        height: 100dvh !important;
        background: rgba(10, 10, 15, 0.98) !important;
        backdrop-filter: blur(30px) !important;
        -webkit-backdrop-filter: blur(30px) !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 30px !important;
        padding: 80px 20px 40px !important;
        z-index: 9999 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .nav-links.active {
        display: flex !important;
        animation: slideInMenu 0.3s ease-out !important;
    }

    .nav-links li {
        list-style: none !important;
        width: 100% !important;
        max-width: 300px !important;
        text-align: center !important;
    }

    .nav-links a {
        display: block !important;
        font-size: 24px !important;
        padding: 16px 24px !important;
        width: 100% !important;
        border-radius: 12px !important;
        transition: all 0.3s !important;
    }

    .nav-links a:hover {
        background: rgba(255, 0, 51, 0.1) !important;
        transform: translateX(5px) !important;
    }
}

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

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none !important;
    position: relative !important;
    width: 44px !important;
    height: 44px !important;
    padding: 0 !important;
    background: rgba(255, 0, 51, 0.05) !important;
    border: 2px solid rgba(255, 0, 51, 0.3) !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 5px !important;
    transition: all 0.3s ease !important;
    z-index: 10001 !important;
}

@media (max-width: 1023px) {
    .mobile-menu-toggle {
        display: flex !important;
    }
}

/* Toggle button açıkken arka plan */
.mobile-menu-toggle.active {
    background: rgba(255, 0, 51, 0.15) !important;
    border-color: rgba(255, 0, 51, 0.6) !important;
    position: fixed !important;
    top: 20px !important;
    right: 16px !important;
}

.mobile-menu-toggle:hover {
    background: rgba(255, 0, 51, 0.1) !important;
    border-color: rgba(255, 0, 51, 0.6) !important;
}

.mobile-menu-toggle span {
    display: block !important;
    width: 24px !important;
    height: 2px !important;
    background: var(--lydian-primary, #ff0033) !important;
    transition: all 0.3s ease !important;
    border-radius: 2px !important;
}

/* X Icon when active */
.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px) !important;
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0 !important;
    transform: scale(0) !important;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px) !important;
}

/* Close Button inside Mobile Menu - GİZLE (Toggle button X olarak kullanılacak) */
.mobile-menu-close {
    display: none !important;
}

/* Language Switch - Mobile Optimized */
.lang-switch {
    display: flex !important;
    gap: 4px !important;
    flex-shrink: 0 !important;
    background: rgba(255, 255, 255, 0.03) !important;
    padding: 4px !important;
    border-radius: 10px !important;
    border: 1px solid rgba(255, 0, 51, 0.1) !important;
}

@media (max-width: 1023px) {
    .lang-switch {
        position: relative !important;
        z-index: 10002 !important;
    }
}

.lang-btn {
    min-width: 40px !important;
    min-height: 40px !important;
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    border-radius: 7px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
    border: 1px solid transparent !important;
    color: var(--text-secondary) !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
}

.lang-btn.active {
    background: rgba(255, 0, 51, 0.15) !important;
    border-color: rgba(255, 0, 51, 0.3) !important;
    color: var(--lydian-primary) !important;
}

.lang-btn:hover {
    background: rgba(255, 0, 51, 0.1) !important;
    color: var(--lydian-primary) !important;
}

@media (min-width: 480px) {
    .lang-btn {
        min-width: 44px !important;
        min-height: 44px !important;
        width: 44px !important;
        height: 44px !important;
        font-size: 13px !important;
    }
}

/* ============================================
   CONTAINERS & SECTIONS
   ============================================ */

.container,
.content,
section {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    overflow-x: hidden !important;
}

@media (min-width: 640px) {
    .container,
    .content,
    section {
        padding-left: 24px !important;
        padding-right: 24px !important;
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: 1280px !important;
        margin: 0 auto !important;
        padding-left: 40px !important;
        padding-right: 40px !important;
    }
}

/* ============================================
   HERO SECTION - MOBILE
   ============================================ */

.hero,
.hero-section,
[class*="hero"] {
    padding: 80px 16px 40px !important;
    min-height: auto !important;
    overflow-x: hidden !important;
}

.hero h1,
.hero-title,
h1 {
    font-size: clamp(28px, 8vw, 72px) !important;
    line-height: 1.1 !important;
    word-wrap: break-word !important;
    hyphens: auto !important;
}

.hero h2,
.hero-subtitle,
h2 {
    font-size: clamp(20px, 5vw, 48px) !important;
    line-height: 1.2 !important;
}

.hero p,
.hero-description {
    font-size: clamp(14px, 3.5vw, 20px) !important;
    line-height: 1.6 !important;
    max-width: 100% !important;
}

/* ============================================
   BUTTONS - MOBILE OPTIMIZED
   ============================================ */

button,
.btn,
.cta-button,
a.button,
[class*="button"] {
    min-height: 48px !important;
    min-width: 48px !important;
    padding: 14px 24px !important;
    font-size: 16px !important;
    white-space: nowrap;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    border-radius: 12px !important;
    touch-action: manipulation !important;
}

@media (max-width: 480px) {
    button,
    .btn,
    .cta-button {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* ============================================
   GRID & CARDS - MOBILE
   ============================================ */

.grid,
.features-grid,
.cards-grid,
[class*="grid"] {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 16px !important;
    width: 100% !important;
}

@media (min-width: 640px) {
    .grid,
    .features-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px !important;
    }
}

@media (min-width: 1024px) {
    .grid,
    .features-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 24px !important;
    }
}

.card,
.feature-card,
.agent-card,
[class*="card"] {
    width: 100% !important;
    max-width: 100% !important;
    padding: 20px !important;
    box-sizing: border-box !important;
}

/* ============================================
   IMAGES & MEDIA
   ============================================ */

img,
picture,
video,
svg {
    max-width: 100% !important;
    height: auto !important;
    display: block;
}

/* ============================================
   TABLES - RESPONSIVE
   ============================================ */

table {
    width: 100% !important;
    display: block;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

/* ============================================
   FORMS - MOBILE
   ============================================ */

input,
textarea,
select {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 48px !important;
    font-size: 16px !important; /* Prevents iOS zoom */
    padding: 12px 16px !important;
    box-sizing: border-box !important;
    -webkit-appearance: none;
    appearance: none;
}

/* ============================================
   FOOTER - MOBILE
   ============================================ */

footer {
    padding: 40px 16px 20px !important;
}

.footer-grid,
.footer-links {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 30px !important;
}

@media (min-width: 640px) {
    .footer-grid,
    .footer-links {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (min-width: 1024px) {
    .footer-grid,
    .footer-links {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

.footer-bottom {
    flex-direction: column !important;
    gap: 16px !important;
    text-align: center !important;
}

@media (min-width: 768px) {
    .footer-bottom {
        flex-direction: row !important;
        justify-content: space-between !important;
        text-align: left !important;
    }
}

/* ============================================
   TEXT & TYPOGRAPHY
   ============================================ */

h1, h2, h3, h4, h5, h6, p, span, div {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    hyphens: auto !important;
}

/* ============================================
   DEMO PAGE SPECIFIC
   ============================================ */

.demo-container {
    padding: 80px 16px 40px !important;
}

.hospital-selector,
.agent-controls {
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

.slider-container {
    width: 100% !important;
    padding: 16px !important;
}

.vital-card {
    padding: 16px !important;
}

.results-panel {
    width: 100% !important;
    overflow-x: auto !important;
}

/* ============================================
   SCROLLBAR - MOBILE
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 0, 51, 0.3);
    border-radius: 4px;
}

/* ============================================
   LANDSCAPE MODE FIXES
   ============================================ */

@media (orientation: landscape) and (max-height: 600px) {
    .hero,
    .hero-section {
        min-height: auto !important;
        padding: 60px 16px 30px !important;
    }

    .hero h1 {
        font-size: clamp(24px, 6vw, 48px) !important;
    }

    .nav-links {
        gap: 15px !important;
    }
}

/* ============================================
   SAFE AREA INSETS (iPhone Notch)
   ============================================ */

@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left)) !important;
        padding-right: max(0px, env(safe-area-inset-right)) !important;
    }

    nav {
        padding-left: max(16px, env(safe-area-inset-left)) !important;
        padding-right: max(16px, env(safe-area-inset-right)) !important;
    }
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */

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

/* GPU Acceleration for animations */
.card,
.btn,
button,
.nav-links a {
    transform: translateZ(0);
    will-change: transform;
}

/* ============================================
   ACCESSIBILITY - HIGH CONTRAST
   ============================================ */

@media (prefers-contrast: high) {
    button,
    .btn,
    .card {
        border-width: 2px !important;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    nav,
    footer,
    .mobile-menu-toggle,
    .lang-switch {
        display: none !important;
    }

    body {
        background: white !important;
        color: black !important;
    }
}

/* ============================================
   CRITICAL - PREVENT HORIZONTAL SCROLL
   ============================================ */

html,
body,
#root,
#app,
.app,
main {
    max-width: 100vw !important;
    overflow-x: hidden !important;
}

* {
    max-width: 100% !important;
}

img,
video,
iframe,
embed,
object {
    max-width: 100% !important;
    height: auto !important;
}

/* Fix for absolutely positioned elements */
[style*="position: absolute"],
[style*="position: fixed"] {
    max-width: 100vw !important;
}
