/* styles.css - Main CSS entry point with mobile-responsive design */

/* Import all CSS modules */
@import url('./css/base.css?v2');
@import url('./css/header.css'); /* Updated with mobile styles */
@import url('./css/sidebar.css'); /* Updated with mobile styles */
@import url('./css/controls.css'); /* Updated with mobile styles */
@import url('./css/gallery.css');
@import url('./css/popups.css');
@import url('./css/autocomplete.css');
@import url('./css/img2img.css');
@import url('./css/upscale.css');
@import url('./css/interrogate.css');
@import url('./css/notifications.css');
@import url('./css/lora-display.css');
@import url('./css/prompt-tags.css');

/* Mobile-specific global styles */
body.mobile-mode {
    overflow-x: hidden;
}

/* Mobile burger menu styles - additional rules */
.mobile-menu-btn {
    position: relative;
    z-index: 1002;
}

/* Mobile view toggle styles - additional rules */
.mobile-view-toggle {
    position: relative;
    z-index: 1002;
}

/* Mobile sidebar overlay */
.mobile-sidebar-overlay {
    display: none;
}

@media (max-width: 768px) {
    .mobile-sidebar-overlay {
        display: block;
    }
}

/* Main content mobile layout adjustments */
@media (max-width: 768px) {
    .main-content {
        position: relative;
        overflow: hidden;
    }
    
    /* Mobile view transitions */
    .controls-panel,
    .output-panel {
        transition: opacity 0.3s ease, transform 0.3s ease;
    }
    
    /* Prompt view state */
    .main-content:not(.mobile-output-view) .controls-panel {
        display: block;
        opacity: 1;
        transform: translateX(0);
    }
    
    .main-content:not(.mobile-output-view) .output-panel {
        display: none;
        opacity: 0;
        transform: translateX(20px);
    }
    
    /* Output view state */
    .main-content.mobile-output-view .controls-panel {
        display: none;
        opacity: 0;
        transform: translateX(-20px);
    }
    
    .main-content.mobile-output-view .output-panel {
        display: flex;
        opacity: 1;
        transform: translateX(0);
        position: relative;
        z-index: 10;
    }
}

/* Enhanced mobile responsiveness for form elements */
@media (max-width: 768px) {
    /* Larger touch targets */
    input[type="range"] {
        height: 8px;
        -webkit-appearance: none;
        appearance: none;
        background: #333;
        border-radius: 4px;
    }
    
    input[type="range"]::-webkit-slider-thumb {
        -webkit-appearance: none;
        appearance: none;
        width: 24px;
        height: 24px;
        border-radius: 50%;
        background: #4ecdc4;
        cursor: pointer;
        border: 2px solid #1a1a1a;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }
    
    input[type="range"]::-moz-range-thumb {
        width: 24px;
        height: 24px;
        border-radius: 50%;
        background: #4ecdc4;
        cursor: pointer;
        border: 2px solid #1a1a1a;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }
    
    /* Better mobile select styling */
    select {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ccc' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: right 8px center;
        background-size: 16px;
        padding-right: 32px;
    }
    
    /* Mobile-optimized textareas */
    textarea {
        resize: vertical;
        min-height: 80px;
    }
    
    /* Touch-friendly checkboxes and radios */
    input[type="checkbox"],
    input[type="radio"] {
        width: 20px;
        height: 20px;
        margin-right: 8px;
    }
}

/* Mobile keyboard handling */
@media (max-width: 768px) {
    /* Prevent zoom on input focus for iOS */
    input[type="text"],
    input[type="number"],
    input[type="url"],
    textarea,
    select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Adjust viewport when virtual keyboard is open */
    .form-group:focus-within {
        scroll-margin-top: 20px;
    }
}

/* Enhanced popup mobile responsiveness */
@media (max-width: 768px) {
    .popup-overlay {
        padding: 10px;
    }
    
    .popup-content {
        max-height: 90vh;
        margin: 0;
        border-radius: 8px;
    }
    
    .tag-browser-content {
        width: 95vw;
        height: 90vh;
        border-radius: 8px;
    }
    
    .tag-browser-body {
        flex-direction: column;
    }
    
    .tag-browser-sidebar {
        width: 100%;
        height: 200px;
        border-right: none;
        border-bottom: 1px solid #444;
    }
}

/* Mobile gallery optimizations */
@media (max-width: 768px) {
    .gallery-view {
        position: relative;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 8px;
        padding: 10px;
    }
    
    .gallery-item {
        border-radius: 6px;
    }
    
    .gallery-actions {
        padding: 8px;
        gap: 6px;
    }
    
    .gallery-action-btn {
        padding: 6px;
        font-size: 12px;
        min-width: 32px;
        min-height: 32px;
    }
}

/* Mobile notification adjustments */
@media (max-width: 768px) {
    .notification {
        margin: 8px;
        border-radius: 6px;
        font-size: 14px;
    }
    
    .notification-close {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }
}

/* Mobile fullscreen image viewer */
@media (max-width: 768px) {
    .image-fullscreen {
        padding: 10px;
    }
    
    .image-fullscreen img {
        max-width: 100%;
        max-height: calc(100% - 100px);
    }
    
    .image-fullscreen-close {
        top: 10px;
        right: 10px;
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
    
    .fullscreen-nav-btn {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
    
    .fullscreen-info-overlay {
        position: fixed;
        bottom: 10px;
        left: 10px;
        right: 10px;
        top: auto;
        width: auto;
        max-height: 200px;
        border-radius: 8px;
    }
}

/* Mobile stream overlay adjustments */
@media (max-width: 768px) {
    .stream-fullscreen-header {
        flex-direction: column;
        gap: 8px;
        padding: 10px;
        height: auto;
        min-height: 80px;
    }
    
    .stream-fullscreen-content {
        height: calc(100vh - 140px);
        padding: 10px;
    }
    
    .stream-fullscreen-footer {
        flex-direction: column;
        gap: 8px;
        padding: 8px 15px;
        text-align: center;
        height: auto;
        min-height: 60px;
    }
    
    .stream-fullscreen-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}

/* Performance optimizations for mobile */
@media (max-width: 768px) {
    /* Reduce animations on mobile for better performance */
    .model-item,
    .lora-item,
    .gallery-item {
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    
    /* Optimize image loading */
    img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
    
    /* Reduce backdrop blur for better performance */
    .popup-overlay,
    .mobile-sidebar-overlay {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

/* PWA and mobile app styling */
@media (display-mode: standalone) {
    /* Styles for when app is installed as PWA */
    .header {
        padding-top: max(15px, env(safe-area-inset-top));
    }
    
    .container {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height */
    }
}

/* Mobile safe area handling (notches, etc.) */
@media (max-width: 768px) {
    .header {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }
    
    .sidebar {
        padding-left: max(15px, env(safe-area-inset-left));
    }
    
    .controls-panel,
    .output-panel {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
        padding-bottom: max(15px, env(safe-area-inset-bottom));
    }
}

/* Dark mode mobile optimizations */
@media (prefers-color-scheme: dark) and (max-width: 768px) {
    .mobile-menu-btn {
        background: #1a1a1a;
        border-color: #333;
    }
    
    .mobile-view-toggle {
        background: #0a0a0a;
    }
    
    .sidebar {
        background: #1a1a1a;
        border-right-color: #333;
    }
}

/* High contrast mobile support */
@media (prefers-contrast: high) and (max-width: 768px) {
    .mobile-menu-btn,
    .mobile-view-btn,
    .sidebar-close-btn {
        border-width: 2px;
    }
    
    .mobile-menu-btn.active {
        border-color: #4ecdc4;
        background: #4ecdc4;
    }
    
    .sidebar {
        border-right-width: 3px;
    }
}

/* Reduced motion mobile support */
@media (prefers-reduced-motion: reduce) and (max-width: 768px) {
    .controls-panel,
    .output-panel,
    .sidebar,
    .mobile-sidebar-overlay {
        transition: none;
    }
    
    .main-content.mobile-output-view .controls-panel,
    .main-content:not(.mobile-output-view) .output-panel {
        transform: none;
    }
}

/* Touch device specific styles */
@media (hover: none) and (pointer: coarse) {
    /* Ensure all interactive elements meet minimum touch target size */
    button,
    input[type="button"],
    input[type="submit"],
    .clickable,
    .tab-btn,
    .view-toggle-btn,
    .batch-nav-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Remove hover effects that don't work on touch */
    .model-item:hover,
    .lora-item:hover,
    .gallery-item:hover {
        transform: none;
    }
    
    /* Improve scrolling performance */
    .tab-content,
    .gallery-container,
    .output-container {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
}

/* Landscape mobile specific adjustments */
@media (max-width: 896px) and (orientation: landscape) {
    .header {
        padding: 8px 15px;
    }
    
    .header-info h1 {
        font-size: 1.2rem;
    }
    
    .header-info p {
        display: none;
    }
    
    .controls-panel,
    .output-panel {
        padding: 12px 15px;
    }
    
    .sidebar {
        width: 60%;
        max-width: 350px;
    }
    
    .modal-content,
    .popup-content {
        max-height: 85vh;
    }
}

/* Ultra-wide mobile support (foldable phones, etc.) */
@media (min-width: 769px) and (max-width: 1024px) and (orientation: landscape) {
    .main-content {
        grid-template-columns: 300px 1fr 1fr;
    }
    
    .sidebar {
        position: relative;
        width: auto;
        height: auto;
    }
    
    .mobile-menu-btn,
    .mobile-view-toggle {
        display: none;
    }
}

/* Print styles for mobile */
@media print {
    .mobile-menu-btn,
    .mobile-view-toggle,
    .mobile-sidebar-overlay,
    .sidebar-header {
        display: none !important;
    }
    
    .sidebar {
        position: static !important;
        transform: none !important;
    }
    
    .controls-panel,
    .output-panel {
        display: block !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* Accessibility improvements for mobile */
@media (max-width: 768px) {
    /* Screen reader only content */
    .sr-only {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
    
    /* Focus indicators */
    .mobile-menu-btn:focus,
    .mobile-view-btn:focus,
    .sidebar-close-btn:focus {
        outline: 3px solid #4ecdc4;
        outline-offset: 2px;
    }
    
    /* High contrast focus indicators */
    @media (prefers-contrast: high) {
        .mobile-menu-btn:focus,
        .mobile-view-btn:focus,
        .sidebar-close-btn:focus {
            outline-width: 4px;
        }
    }
}

/* Custom scrollbar styles for mobile webkit browsers */
@media (max-width: 768px) {
    .tab-content::-webkit-scrollbar,
    .output-container::-webkit-scrollbar {
        width: 4px;
    }
    
    .tab-content::-webkit-scrollbar-track,
    .output-container::-webkit-scrollbar-track {
        background: transparent;
    }
    
    .tab-content::-webkit-scrollbar-thumb,
    .output-container::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.3);
        border-radius: 2px;
    }
}