/* assets/css/responsive.css - FIXAD VERSION FÖR MOBIL SCROLLNING */

/* FÖRBÄTTRING: En bättre metod för att låsa scroll vid overlays. 
   Lägg till/ta bort denna klass på <body> via JavaScript. */
body.no-scroll {
    overflow: hidden;
    /* VIKTIGT: Tillåt scrollning i barn-element */
    position: fixed;
    width: 100%;
}

/* Tablet Styles (768px - 1024px) */
@media (max-width: 1024px) {
    .container {
        max-width: 100%;
        padding: 30px 16px;
    }

    .main-content {
        grid-template-columns: 1fr;
    }

    .preset-buttons {
        gap: 8px;
    }

    .preset-btn {
        font-size: 12px;
        padding: 6px 12px;
    }
}

/* Mobile Styles (768px and below) */
@media (max-width: 768px) {
    /* Container and Layout */
    .container {
        padding: 20px 16px;
    }
    
    .input-section,
    .output-section {
        padding: 24px 20px;
    }

    .section-title {
        font-size: 18px;
        margin-bottom: 20px;
    }

    /* Top Bar Mobile */
    .top-bar {
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
    }

    .left-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .left-section > div:first-child {
        display: flex;
        align-items: center;
        gap: 16px;
        width: 100%;
    }

    .top-actions {
        justify-content: space-between;
    }

    /* Mode Tabs Mobile */
    .mode-tab {
        padding: 10px 12px;
        font-size: 13px;
    }

    /* Preset Buttons Mobile */
    .preset-buttons {
        gap: 8px;
        justify-content: flex-start;
    }

    .preset-btn {
        font-size: 12px;
        padding: 6px 12px;
        border-radius: 16px;
    }

    /* Input Section Mobile */
    .input-controls {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .input-actions {
        align-self: flex-end;
    }

    /* KRITISK FIX: Mobil textarea scrollning */
    .code-input,
    .code-output {
        min-height: 250px;
        max-height: 400px; /* Begränsa höjd på mobil */
        padding: 16px;
        font-size: 13px;
        /* VIKTIGT: Tvinga fram scrollning */
        overflow-y: auto !important;
        overflow-x: auto !important;
        /* Förbättra touch-scrollning på iOS */
        -webkit-overflow-scrolling: touch;
        /* Säkerställ att elementet kan scrollas */
        overscroll-behavior: contain;
        /* Fix för iOS Safari */
        position: relative;
        z-index: 1;
    }

    /* Extra fix för iOS Safari textareas */
    .code-input:focus,
    .code-output:focus {
        overflow-y: auto !important;
        overflow-x: auto !important;
    }

    /* Säkerställ att parent containers inte blockerar scrollning */
    .input-section,
    .output-section {
        overflow: visible !important;
        position: relative;
    }

    /* Action Section Mobile */
    .action-section {
        justify-content: stretch;
    }

    .action-btn,
    .transform-btn {
        width: 100%;
        padding: 14px 20px;
        font-size: 15px;
    }

    /* Results Section Mobile */
    .results-section {
        padding-top: 24px;
    }

    .results-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .copy-btn {
        align-self: flex-end;
    }

    /* Side Menu Mobile */
    .side-menu {
        width: 280px;
        left: -280px;
    }

    .side-menu-content {
        padding: 20px;
    }

    .menu-section {
        margin-bottom: 24px;
    }

    /* Auth & Other Overlays Mobile */
    .auth-content,
    .profile-content {
        padding: 32px 24px;
        width: 95%;
        max-width: none;
        /* Tillåt scrollning i overlays om nödvändigt */
        max-height: 90vh;
        overflow-y: auto;
    }

    .auth-title {
        font-size: 20px;
    }

    .language-content {
        padding: 24px 20px;
        width: 95%;
        max-width: none;
        max-height: 90vh;
        overflow-y: auto;
    }

    .language-title {
        font-size: 18px;
    }
}

/* Small Mobile (480px and below) */
@media (max-width: 480px) {
    /* More compact spacing */
    .container {
        padding: 16px 12px;
    }

    /* Logo Mobile */
    .logo {
        font-size: 1.3rem;
    }

    /* Preset Buttons Very Small */
    .presets {
        gap: 6px;
    }
    .preset-btn {
        font-size: 11px;
        padding: 5px 10px;
    }

    /* Input/Output Very Small - MEN BEHÅLL SCROLLNING */
    .code-input,
    .code-output {
        min-height: 200px;
        max-height: 350px; /* Mindre på mycket små skärmar */
        padding: 12px;
        font-size: 12px;
        /* VIKTIGT: Behåll scrollning även på små skärmar */
        overflow-y: auto !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Transform Button Very Small */
    .transform-btn {
        padding: 14px 24px;
        font-size: 14px;
    }

    /* Auth Very Small */
    .auth-content {
        padding: 24px 16px;
        max-height: 85vh; /* Lite mindre på små skärmar */
    }

    .auth-title {
        font-size: 18px;
    }
}

/* Landscape Phone Orientation */
@media (max-width: 768px) and (orientation: landscape) {
    .code-input {
        min-height: 160px;
        max-height: 200px; /* Begränsa i landscape */
    }

    .code-output {
        min-height: 180px;
        max-height: 250px; /* Begränsa i landscape */
    }

    /* Säkerställ scrollning även i landscape */
    .code-input,
    .code-output {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }
}

/* Large Desktop (1200px and above) */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
        padding: 50px 20px;
    }

    .code-input {
        height: 320px;
    }

    .code-output {
        height: 450px;
    }
}

/* Very Large Desktop (1600px and above) */
@media (min-width: 1600px) {
    .container {
        max-width: 1400px;
    }
}

/* Print Styles */
@media print {
    /* Hide interactive elements */
    .side-menu,
    .side-menu-overlay,
    .auth-overlay,
    .limit-overlay,
    .language-overlay,
    .hamburger,
    .input-actions,
    .results-header .copy-btn {
        display: none !important;
    }

    /* Optimize for printing */
    body {
        background: white !important;
        color: black !important;
    }

    .main-panel {
        box-shadow: none;
        border: 1px solid #000;
    }

    .code-input,
    .code-output {
        border: 1px solid #000;
        background: white !important;
        color: black !important;
        overflow: visible !important; /* För print */
        max-height: none !important; /* För print */
    }
}

/* EXTRA FIX: Säkerställ att textareas aldrig blockeras av föräldrar */
textarea.code-input,
textarea.code-output {
    touch-action: auto !important;
    pointer-events: auto !important;
}

/* EXTRA iOS Safari Fix */
@supports (-webkit-touch-callout: none) {
    .code-input,
    .code-output {
        /* iOS Safari specifika fixes */
        -webkit-appearance: none;
        border-radius: 8px; /* Måste ha border-radius på iOS */
    }
}