/* Mobile Responsive Styles for Wplace Color Converter */
/* Preserves PC desktop layout while optimizing for mobile devices */

/* Base Mobile Styles - Only apply on small screens */
@media screen and (max-width: 768px) {
    /* Global Adjustments */
    body {
        overflow-x: hidden;
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }
    
    /* Main Container */
    .main-container {
        padding: 0.5rem;
        max-width: 100vw;
    }
    
    /* Navigation Mobile Optimization - Both navbar and main-nav */
    nav.main-nav,
    .navbar {
        padding: 0.75rem 1rem;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
    }
    
    .navbar {
        background: linear-gradient(135deg, var(--emerald-600) 0%, var(--emerald-700) 100%);
    }
    
    .navbar-inner {
        flex-direction: column;
        padding: 0.5rem;
        gap: 0.75rem;
    }
    
    .nav-brand {
        justify-content: center;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .nav-title {
        font-size: 1.125rem !important;
    }
    
    .nav-menu {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0.25rem;
        padding: 0.5rem 0;
        width: 100%;
    }
    
    .nav-menu::-webkit-scrollbar {
        display: none;
    }
    
    .nav-menu li {
        flex-shrink: 0;
    }
    
    .nav-menu .nav-link {
        font-size: 0.75rem;
        padding: 0.375rem 0.625rem;
        white-space: nowrap;
    }
    
    .nav-menu .nav-link i {
        display: none !important;
    }
    
    .nav-content {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .nav-logo {
        font-size: 1.25rem;
        text-align: center;
        width: 100%;
    }
    
    .nav-links {
        display: flex;
        gap: 0.5rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        width: 100%;
        padding: 0.5rem 0;
    }
    
    .nav-links::-webkit-scrollbar {
        display: none;
    }
    
    .nav-link {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    /* Add padding top to account for fixed nav */
    .converter-section {
        margin-top: 80px;
    }
    
    /* Section Headers */
    .section-header {
        padding: 1rem;
        text-align: center;
    }
    
    .section-title {
        font-size: 1.75rem !important;
        line-height: 1.3;
    }
    
    .section-subtitle {
        font-size: 0.875rem;
        margin-top: 0.5rem;
    }
    
    /* Converter Grid - Stack on mobile */
    .converter-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
        padding: 0 0.5rem;
    }
    
    /* Control Panel */
    .control-panel {
        order: 1;
    }
    
    .control-card {
        padding: 1rem !important;
        margin-bottom: 1rem;
    }
    
    .control-header {
        gap: 0.5rem;
    }
    
    .control-title {
        font-size: 1rem;
    }
    
    /* Upload Zone */
    .upload-zone {
        min-height: 120px;
        padding: 1.5rem 1rem;
    }
    
    .upload-label {
        font-size: 0.875rem;
    }
    
    .upload-label i[data-lucide] {
        width: 36px !important;
        height: 36px !important;
    }
    
    /* Sliders */
    .slider-group {
        gap: 1rem;
    }
    
    .slider-container label {
        font-size: 0.875rem;
    }
    
    .value-display {
        font-size: 0.875rem;
    }
    
    /* Palette Selector */
    .palette-dropdown {
        width: 100%;
        font-size: 0.875rem;
        padding: 0.625rem;
    }
    
    .palette-toggle {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }
    
    /* Color Palette Grid */
    .palette-grid {
        grid-template-columns: repeat(8, 1fr) !important;
        gap: 0.25rem !important;
        padding: 0.75rem;
        max-height: 200px;
        overflow-y: auto;
    }
    
    .color-block {
        width: 100%;
        aspect-ratio: 1;
        min-width: unset;
        min-height: unset;
    }
    
    /* Preview Panel */
    .preview-panel {
        order: 2;
        min-height: 300px;
    }
    
    .preview-card {
        padding: 1rem !important;
    }
    
    .preview-container {
        height: 250px;
        margin: 0.5rem 0;
    }
    
    .preview-container canvas {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
    }
    
    /* Action Buttons */
    .action-buttons {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0 0.5rem;
    }
    
    .action-buttons button {
        width: 100%;
        padding: 0.875rem;
        font-size: 0.9375rem;
    }
    
    /* Content Sections */
    .content-wrapper {
        padding: 1rem 0;
    }
    
    .intro-section,
    .features-section,
    .how-it-works-section {
        padding: 1.5rem 1rem !important;
        margin: 1rem 0.5rem !important;
    }
    
    .features-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    .feature-card {
        padding: 1.25rem !important;
    }
    
    .feature-icon {
        width: 40px;
        height: 40px;
    }
    
    .feature-title {
        font-size: 1.125rem;
    }
    
    /* Footer */
    footer {
        padding: 2rem 1rem 1rem !important;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 2rem;
        text-align: center;
    }
    
    .footer-section {
        width: 100%;
    }
    
    .footer-links {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    /* Share Button Adjustment */
    .share-button-container {
        bottom: 1rem !important;
        right: 1rem !important;
    }
    
    .share-fab {
        width: 48px !important;
        height: 48px !important;
    }
    
    /* Modal/Dialog Optimization */
    .magic-modal,
    .palette-dialog {
        width: calc(100vw - 2rem) !important;
        max-width: none !important;
        margin: 1rem !important;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }
    
    /* Badges and Small Elements */
    .magic-badge {
        font-size: 0.625rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Image Palette Display */
    .image-palette {
        flex-wrap: wrap;
        max-height: 120px;
        overflow-y: auto;
    }
    
    .palette-color-item {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
}

/* Tablet Specific Adjustments */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .main-container {
        padding: 1rem;
    }
    
    .converter-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 1.5rem !important;
    }
    
    .palette-grid {
        grid-template-columns: repeat(8, 1fr) !important;
    }
    
    .features-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    button, 
    a, 
    .nav-link,
    .color-block,
    input[type="range"] {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Remove hover effects on touch devices */
    .magic-button:hover,
    .nav-link:hover,
    .color-block:hover {
        transform: none !important;
    }
    
    /* Improve slider touch area */
    input[type="range"] {
        height: 44px;
        -webkit-appearance: none;
    }
    
    input[type="range"]::-webkit-slider-thumb {
        width: 32px;
        height: 32px;
        -webkit-appearance: none;
    }
    
    /* Improve scroll performance */
    .palette-grid,
    .nav-links,
    .preview-container {
        -webkit-overflow-scrolling: touch;
    }
}

/* Small Mobile Devices (iPhone SE, etc.) */
@media screen and (max-width: 375px) {
    .section-title {
        font-size: 1.5rem !important;
    }
    
    .palette-grid {
        grid-template-columns: repeat(6, 1fr) !important;
    }
    
    .control-card {
        padding: 0.875rem !important;
    }
    
    .upload-zone {
        min-height: 100px;
        padding: 1rem;
    }
}

/* Landscape Mode Adjustments */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .converter-section {
        margin-top: 60px;
    }
    
    nav.main-nav {
        padding: 0.5rem 1rem;
    }
    
    .nav-content {
        flex-direction: row;
    }
    
    .converter-grid {
        grid-template-columns: 1fr 1fr !important;
    }
    
    .preview-container {
        height: 200px;
    }
    
    .palette-grid {
        max-height: 150px;
    }
}

/* High Resolution Displays */
@media screen and (-webkit-min-device-pixel-ratio: 2),
       screen and (min-resolution: 192dpi) {
    /* Ensure crisp borders and shadows */
    .magic-card,
    .control-card,
    .preview-card {
        border-width: 0.5px;
    }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Print Styles */
@media print {
    nav,
    .share-button-container,
    .action-buttons,
    footer {
        display: none !important;
    }
    
    .main-container {
        max-width: 100%;
    }
    
    .converter-grid {
        grid-template-columns: 1fr !important;
    }
}