/* ==========================================================================
   MOBILE RESPONSIVE STYLES - Smart Responsive Design
   ========================================================================== */

/* CSS Custom Properties for responsive breakpoints */
:root {
    --mobile-breakpoint: 1080px;
    --tablet-breakpoint: 1024px;
    --desktop-breakpoint: 1400px;
    --drawer-width: 320px;
    --drawer-height-mobile: 40vh;
    --drawer-height-tablet: 50vh;
    --header-height: 5.6rem;
}

/* ==========================================================================
   TABLET BREAKPOINT (1024px and below)
   ========================================================================== */

@media screen and (max-width: 1024px) {

    /* Reduce drawer width on tablets */
    :root {
        --drawer-width: 280px;
    }

    .hide-on-mobile, .hide-mobile {
        display: none !important;
    }
}

/* ==========================================================================
   MOBILE BREAKPOINT (1080px and below)
   ========================================================================== */

@media screen and (max-width: 1080px) {

    .logo-main-text {
        font-size: 18px;
    }

    #user-info{
        position: absolute;
        top: 10px;
        right: 10px;
    }

    main.main-container {
        margin-top: var(--top-mobile-margin-height);
        padding: 1rem !important;
    }

    .info-box {
        width: calc(100vw - 20px);
        top: 10px;
        right: 10px;
        left: 10px;
        background: rgba(0, 0, 0, 0.25);
        display: flex;
        flex-direction: column;
    }

    .info-box-content.expanded {
        height: 80vh;
    }

    .info-box-container {
        background: transparent;
    }

    .info-box-meta {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .info-box-meta-item {
        padding: 10px;
        background: rgba(0, 0, 0, 0.75);
    }

    .info-box-prompt-item {
        background: rgba(0, 0, 0, 0.75);
    }

    .search-container, #search {
        width: 100%;
    }

    /* Mobile touch scrolling improvements for info box content */
    .info-box-content {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        height: calc(100dvh - 120px);
        overflow-y: auto;
        scroll-behavior: smooth;
        position: relative;
        touch-action: pan-y;
        padding-bottom: 100px;
    }

    /* Mobile info-box header should not scroll */
    .info-box-header {
        flex-shrink: 0;
    }

    .info-box-thumbnail {
        width: 100%;
        object-fit: contain;
    }

    .label {
        border-radius: 8px;
        padding: 3px 6px;
    }

    .label span {
        font-size: 16px;
        padding: 0 3px;
        font-weight: 700;
    }

    input[type="number"] {
        height: 28px;
        font-size: 16px;
    }

    .search-replace {
        display: none !important;
    }

    .sub-controls {
        display: none !important;
    }

    label {
        flex: 1;
        white-space: nowrap;
    }

    /* Remove main content padding on mobile */
    body>main {
        padding: 0 !important;
        margin: 0;
        width: 100%;
        max-width: 100vw;
    }


    /* Mobile list view adjustments */
    .list-view {
        flex-direction: column;
        padding: 0.75rem;
    }

    .list-image-thumb {
        width: 100% !important;
        margin-bottom: 0.5rem;
    }

    .list-content {
        width: 100% !important;
        margin-bottom: 0.5rem;
    }

    /* Mobile section spacing */
    #controls-drawer [data-section] {
        margin-bottom: 1.5rem;
    }

    /* Mobile header adjustments */
    #controls-drawer h3 {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }

    /* Logo container */
    .logo-container {
        margin-top: -10px;
    }

    /* Header container */
    .header-container {
        flex-flow: column;
        align-items: flex-start;
        justify-content: flex-start;
        gap: 10px;
    }

    /* Sub header container */
    .sub-header-container {
        flex-flow: column;
        align-items: flex-start;
        justify-content: flex-start;
        gap: 10px;
    }
}

/* ==========================================================================
   SMALL MOBILE BREAKPOINT (480px and below)
   ========================================================================== */

@media screen and (max-width: 480px) {

    /* Smaller drawer height for small mobile */
    :root {
        --drawer-height-mobile: 35vh;
    }

    /* Adjust main content padding */
    body:not(.drawer-collapsed) main {
        padding-bottom: 35vh;
    }


    /* Smaller drawer content */
    #controls-drawer .p-6 {
        padding: 0.75rem;
    }


    /* Smaller section spacing */
    #controls-drawer [data-section] {
        margin-bottom: 1rem;
    }

    /* Smaller headers */
    #controls-drawer h3 {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }
}

/* ==========================================================================
   SMOOTH TRANSITIONS AND ANIMATIONS
   ========================================================================== */

/* Smooth transitions for all responsive changes */
* {
    transition: margin 0.3s ease-in-out, padding 0.3s ease-in-out,
        width 0.3s ease-in-out, height 0.3s ease-in-out,
        transform 0.3s ease-in-out;
}

/* Disable transitions on reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* ==========================================================================
   ACCESSIBILITY IMPROVEMENTS
   ========================================================================== */

/* Focus indicators for mobile */
@media screen and (max-width: 1080px) {

    button:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 2px solid var(--color-primary);
        outline-offset: 2px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    #controls-drawer {
        border-color: rgba(255, 255, 255, 0.5);
    }

    .drawer-backdrop {
        background: rgba(0, 0, 0, 0.8);
    }
}

/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */

/* Hide on mobile */
.mobile-hidden {
    display: block;
}

@media screen and (max-width: 1080px) {
    .mobile-hidden {
        display: none !important;
    }
}

/* Show only on mobile */
.mobile-only {
    display: none;
}

@media screen and (max-width: 1080px) {
    .mobile-only {
        display: block !important;
    }
}

/* Mobile hamburger button positioning */
@media screen and (max-width: 1080px) {
    #mobile-hamburger {
        position: fixed;
        top: 0.5rem;
        left: 0.75rem;
        z-index: 60;
        background: rgba(31, 41, 55, 0.9);
        backdrop-filter: blur(10px);
        border: 1px solid rgba(75, 85, 99, 0.3);
        padding: 6px;
        cursor: pointer;
    }

}

/* Mobile controls overlay */
@media screen and (max-width: 1080px) {
    #mobile-controls-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.8);
        z-index: 50;
    }

    #mobile-controls-overlay.hidden {
        display: none !important;
    }

    /* Responsive drawer - mobile behavior */
    body #controls-drawer {
        width: 100vw !important;
        height: 100vh !important;
        min-width: 100vw !important;
        min-height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        border-right: none !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        z-index: 9999 !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s ease !important;
        background: linear-gradient(135deg, #1f2937 0%, #374151 50%, #1f2937 100%) !important;
        color: white !important;
        overflow-y: auto !important;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
        display: block !important;
        visibility: visible !important;
    }

    body #controls-drawer.open {
        transform: translateX(0) !important;
    }

    #mobile-controls-overlay {
        display: none !important;
    }

    /* Mobile controls header */
    #mobile-controls-drawer .flex.items-center.justify-between {
        position: sticky;
        top: 0;
        background: rgba(31, 41, 55, 0.95);
        backdrop-filter: blur(10px);
        border-bottom: 1px solid rgba(75, 85, 99, 0.3);
        z-index: 10;
    }

    /* Mobile controls content */
    #mobile-controls-drawer .p-6 {
        padding: 1.5rem;
        padding-bottom: 2rem;
    }

    /* Mobile provider list */
    #mobile-provider-list {
        max-height: 200px;
        grid-template-columns: 1fr;
    }

    /* Mobile prompt history */
    #mobile-prompt-history {
        max-height: 200px;
        grid-template-columns: 1fr;
    }

    /* Mobile compact view */
    .prompt-output.compact-view .image-wrapper {
        width: 30.55%;
        height: 116px;
        margin: 0 5px 5px 0;
    }
}

/* Hide on desktop */
.desktop-hidden {
    display: none;
}

@media screen and (min-width: 769px) {
    .desktop-hidden {
        display: none !important;
    }
}

/* ==========================================================================
   PERFORMANCE OPTIMIZATIONS
   ========================================================================== */

/* Use transform for better performance */
#controls-drawer {
    will-change: transform;
}

/* Optimize repaints */
.prompt-output {
    contain: layout style paint;
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {

    #controls-drawer,
    #toggle-drawer,
    .drawer-backdrop {
        display: none !important;
    }

    body main {
        margin-left: 0 !important;
        padding-bottom: 0 !important;
    }
}
