/* Mobile Styles - Applied when screen width <= 768px */

/* Mobile Header */
.mobile-header {
    display: flex !important;
    position: sticky;
    top: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.hamburger-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hamburger-icon {
    width: 24px;
    height: 14px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.hamburger-icon span {
    display: block;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.sidebar.open ~ .mobile-header .hamburger-icon span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.sidebar.open ~ .mobile-header .hamburger-icon span:nth-child(2) {
    opacity: 0;
}

.sidebar.open ~ .mobile-header .hamburger-icon span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.mobile-title {
    flex: 1;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
}

.mobile-actions {
    display: flex;
    gap: 8px;
}

.mobile-icon-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: none;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Sidebar Mobile */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    transform: translateX(-100%);
    width: 280px;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-overlay {
    display: block !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Main Content Mobile */
.main-content {
    margin-top: 0;
}

.desktop-layout {
    flex-direction: column;
}

/* Home View Mobile */
.home-view {
    padding: 24px 16px;
}

.home-header h1 {
    font-size: 28px;
}

.home-header p {
    font-size: 16px;
}

.category-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.category-card {
    padding: 20px 16px;
}

.category-icon {
    font-size: 36px;
    margin-bottom: 12px;
}

.category-name {
    font-size: 16px;
    margin-bottom: 4px;
}

.category-formats {
    font-size: 12px;
}

/* Category View Mobile */
.category-view, .image-converter-view {
    padding: 20px 16px;
}

.view-header, .converter-header {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
}

.view-header h2, .converter-header h2 {
    font-size: 24px;
}

.view-actions, .converter-actions {
    flex-direction: column;
    gap: 8px;
}

.view-actions button, .converter-actions button {
    width: 100%;
    justify-content: center;
}

.converter-controls {
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.mode-switcher {
    width: 100%;
    justify-content: center;
}

#fixed-format {
    width: 100%;
}

/* Upload Area Mobile */
.upload-area, .upload-zone {
    padding: 32px 16px;
}

.upload-area h3, .upload-zone h3 {
    font-size: 18px;
}

/* Image Grid Mobile */
.image-grid {
    grid-template-columns: 1fr;
    gap: 16px;
}

.image-item {
    display: flex;
    border-radius: 8px;
    overflow: visible;
}

.image-preview {
    width: 100px;
    height: 100px;
    flex-shrink: 0;
    border-radius: 8px 0 0 8px;
}

.image-info {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.image-overlay {
    border-radius: 8px 0 0 8px;
    flex-direction: column;
    gap: 4px;
}

.btn-icon {
    width: 28px;
    height: 28px;
    font-size: 14px;
}

/* File Preview Mobile */
.preview-grid {
    grid-template-columns: 1fr;
    gap: 12px;
}

.preview-item, .file-item {
    padding: 12px;
}

/* Modal Mobile */
.modal-content {
    margin: 16px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
}

.modal-content img {
    max-height: 70vh;
}

.modal-close {
    width: 36px;
    height: 36px;
    font-size: 20px;
}

/* Notifications Mobile */
.notification {
    left: 16px;
    right: 16px;
    top: auto;
    bottom: 20px;
}

/* Buttons Mobile */
button {
    padding: 12px 16px;
    font-size: 15px;
}

/* Forms Mobile */
select, input[type="text"], input[type="number"] {
    font-size: 16px; /* Prevents zoom on iOS */
}

/* Touch optimizations */
@media (hover: none) and (pointer: coarse) {
    .nav-item {
        padding: 14px 20px;
    }
    
    button {
        min-height: 44px; /* iOS touch target size */
    }
    
    .format-select {
        min-height: 44px;
        padding: 10px 12px;
    }
}

/* Landscape Mode Adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .mobile-header {
        padding: 8px 16px;
    }
    
    .home-header {
        margin-bottom: 20px;
    }
    
    .home-header h1 {
        font-size: 24px;
    }
    
    .category-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
    
    .upload-area, .upload-zone {
        padding: 24px 16px;
    }
    
    .image-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
}

/* Small phones */
@media (max-width: 375px) {
    .sidebar {
        width: 260px;
    }
    
    .mobile-title {
        font-size: 16px;
    }
    
    .home-header h1 {
        font-size: 24px;
    }
    
    .category-grid {
        grid-template-columns: 1fr;
    }
    
    .view-header h2, .converter-header h2 {
        font-size: 20px;
    }
}