/* responsive.css - Responsive styles for Image Editor Pro */

/* ===== Tablet Landscape (1024px and below) ===== */
@media (max-width: 1024px) {

    /* Header adjustments */
    .header {
        padding: 0.75rem 1.5rem;
    }

    .header h1 {
        font-size: 1.25rem;
    }

    /* Stats bar - stack groups vertically */
    .stats-bar {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .stat-divider {
        display: none;
    }

    /* Bottom section - reduce panel widths */
    .actions-panel,
    .history-panel,
    .crop-panel {
        width: 45%;
    }

    /* Smaller action icons */
    .action-icon {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }
}

/* ===== Tablet Portrait (768px and below) ===== */
@media (max-width: 768px) {

    /* Stack layout vertically */
    .bottom-section {
        flex-direction: column;
        min-height: auto;
    }

    /* Full width panels */
    .actions-panel,
    .history-panel,
    .crop-panel {
        width: 100%;
        border-right: none;
        border-bottom: 2px solid #e0e0e0;
    }

    /* Collapsible panels on mobile */
    .panel-header {
        cursor: pointer;
        position: relative;
        padding-right: 3rem;
    }

    .panel-header::after {
        content: '▼';
        position: absolute;
        right: 1.5rem;
        top: 50%;
        transform: translateY(-50%);
        color: #666;
        transition: transform 0.3s;
    }

    .panel-header.collapsed::after {
        transform: translateY(-50%) rotate(-90deg);
    }

    /* Collapsible content */
    .actions-list,
    .history-list,
    .crop-interface {
        max-height: 400px;
        overflow-y: auto;
        transition: max-height 0.3s ease;
    }

    .panel-header.collapsed+.actions-list,
    .panel-header.collapsed+.history-list,
    .panel-header.collapsed+.crop-interface {
        max-height: 0;
        overflow: hidden;
    }

    /* Image comparison adjustments */
    .comparison-wrapper {
        height: 250px;
    }

    .placeholder-image {
        width: 400px;
        height: 225px;
    }

    /* Smaller comparison labels */
    .comparison-label {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }

    /* Upload modal adjustments */
    .upload-modal-content {
        width: 95%;
        margin: 1rem;
    }

    .drop-zone {
        padding: 2rem 1rem;
        margin: 1rem;
    }

    /* Format selector - 2 columns on mobile */
    .format-selector {
        grid-template-columns: repeat(2, 1fr);
    }

    /* History stats - 2 columns */
    .history-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Crop preview adjustments */
    .crop-preview-container {
        min-height: 250px;
    }

    .crop-preview img {
        max-height: 300px;
    }
}

/* ===== Mobile Large (640px and below) ===== */
@media (max-width: 640px) {

    /* Header - stack buttons */
    .header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .header-actions {
        width: 100%;
        justify-content: center;
    }

    /* Smaller buttons */
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }

    /* Single column stats */
    .stat-group {
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
    }

    /* Aspect ratio chips - wrap */
    .aspect-ratio-chips {
        justify-content: center;
    }

    .chip {
        padding: 0.375rem 0.75rem;
        font-size: 0.8125rem;
    }

    /* Action sections */
    .action-header {
        padding: 0.75rem 1rem;
    }

    .action-content {
        padding: 1rem;
    }

    /* Input groups stack vertically */
    .input-group {
        flex-direction: column;
        align-items: stretch;
    }

    .input-group span {
        text-align: center;
        margin: 0.5rem 0;
    }

    /* History items */
    .history-item {
        padding: 1rem;
    }

    .history-header {
        flex-direction: column;
        gap: 0.75rem;
    }

    .history-actions {
        width: 100%;
        justify-content: space-between;
    }

    /* Upload previews - single column */
    .upload-previews {
        grid-template-columns: 1fr;
    }
}

/* ===== Mobile Small (480px and below) ===== */
@media (max-width: 480px) {

    /* Very compact header */
    .header h1 {
        font-size: 1.125rem;
    }

    /* Stack header buttons vertically */
    .header-actions {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .header-actions .btn {
        width: 100%;
    }

    /* Smaller comparison area */
    .comparison-wrapper {
        height: 200px;
    }

    .placeholder-image {
        width: 300px;
        height: 170px;
        font-size: 1rem;
    }

    /* Hide comparison slider labels on very small screens */
    .comparison-labels {
        display: none;
    }

    /* Simplified stats */
    .stats-bar {
        font-size: 0.875rem;
    }

    .stat-value {
        font-size: 1rem;
    }

    /* Control labels above inputs */
    .control-group {
        margin-bottom: 1rem;
    }

    /* Radio options - more compact */
    .radio-option {
        padding: 0.375rem;
        font-size: 0.8125rem;
    }

    /* Format options - single column */
    .format-selector {
        grid-template-columns: 1fr;
    }

    /* History stats - single column */
    .history-stats {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .history-stat {
        display: flex;
        justify-content: space-between;
        text-align: left;
        padding: 0.375rem 0.5rem;
    }

    /* Crop controls */
    .crop-inputs .input-row {
        flex-direction: column;
        gap: 0.5rem;
    }

    .crop-mini-preview canvas {
        max-height: 120px;
    }

    /* Modal adjustments */
    .upload-modal-content {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
    }

    .drop-zone {
        margin: 0.5rem;
        padding: 1.5rem 1rem;
    }

    .drop-zone-icon svg {
        width: 48px;
        height: 48px;
    }

    .drop-zone-text {
        font-size: 1rem;
    }

    /* Full width action buttons */
    .apply-btn {
        font-size: 0.875rem;
        padding: 0.625rem;
    }

    /* Crop actions - stack buttons */
    .crop-actions {
        flex-direction: column-reverse;
        gap: 0.5rem;
    }

    .crop-actions .btn {
        width: 100%;
    }
}

/* ===== Mobile Extra Small (360px and below) ===== */
@media (max-width: 360px) {

    /* Minimum font sizes for readability */
    body {
        font-size: 14px;
    }

    .header h1 {
        font-size: 1rem;
    }

    /* Even more compact panels */
    .panel-header {
        padding: 1rem;
    }

    .panel-header h2 {
        font-size: 1rem;
    }

    .panel-header p {
        font-size: 0.75rem;
    }

    /* Minimal padding */
    .actions-list,
    .history-list {
        padding: 0.5rem;
    }

    /* Smaller control text */
    .control-label {
        font-size: 0.8125rem;
    }

    /* Compact history items */
    .history-number {
        width: 24px;
        height: 24px;
        font-size: 0.75rem;
    }

    .history-btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.6875rem;
    }
}

/* ===== Orientation: Landscape on Mobile ===== */
@media (max-width: 768px) and (orientation: landscape) {

    /* Reduce vertical spacing in landscape */
    .header {
        padding: 0.5rem 1rem;
    }

    .comparison-wrapper {
        height: 180px;
    }

    .stats-bar {
        padding: 0.75rem;
    }

    /* Side-by-side panels in landscape */
    .bottom-section {
        flex-direction: row;
    }

    .actions-panel,
    .history-panel {
        width: 50%;
        max-height: 400px;
        overflow-y: auto;
    }
}

/* ===== High DPI Displays ===== */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {

    /* Sharper borders and shadows for retina displays */
    .comparison-container,
    .action-section,
    .history-item {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    /* Thinner borders */
    .action-section,
    .history-item {
        border-width: 0.5px;
    }
}

/* ===== Print Styles ===== */
@media print {

    /* Hide interactive elements */
    .header-actions,
    .actions-panel,
    .crop-panel,
    .upload-modal,
    .loading-overlay,
    .toast-container {
        display: none !important;
    }

    /* Full width for print */
    .history-panel {
        width: 100%;
        border: none;
    }

    /* Remove backgrounds for print */
    body {
        background: white;
    }

    .stats-bar {
        background: white;
        border: 1px solid #ddd;
    }
}

/* ===== Accessibility - Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }

    .panel-transition,
    .panel-transition-out {
        animation: none;
    }
}

/* ===== Dark Mode Support ===== */
@media (prefers-color-scheme: dark) {
    /* Add dark mode styles here if needed */
}

/* ===== Touch Device Optimizations ===== */
@media (hover: none) and (pointer: coarse) {

    /* Larger touch targets */
    .btn,
    .chip,
    .radio-option,
    .format-option {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Remove hover effects on touch devices */
    .action-header:hover,
    .history-item:hover,
    .chip:hover,
    .format-option:hover {
        background: inherit;
        border-color: inherit;
    }

    /* Larger handles for crop box */
    .crop-handle {
        width: 20px;
        height: 20px;
        border-width: 3px;
    }
}