/**
 * Mobile Responsiveness Improvements
 * Fixes for tool pages on small screens (320px-768px)
 */

/* ========== Touch-Friendly Upload Areas ========== */
@media (max-width: 768px) {
    .dropzone {
        min-height: 200px !important;
        padding: 2rem 1rem !important;
    }

    .dropzone .dz-message {
        font-size: 0.9rem;
    }

    .dropzone .dz-message i {
        font-size: 2rem !important;
    }

    /* Larger touch targets for remove buttons */
    .dropzone .dz-remove {
        padding: 0.5rem 1rem;
        font-size: 1rem;
    }
}

/* ========== Compression Option Cards ========== */
@media (max-width: 767px) {
    /* Stack compression cards vertically on mobile */
    .compression-option-card {
        margin-bottom: 1rem;
    }

    .compression-option-card label {
        padding: 1.5rem 1rem !important;
    }

    .compression-option-card small {
        font-size: 0.85rem;
    }
}

/* ========== Progress Bar Enhancements ========== */
@media (max-width: 576px) {
    #upload-progress .row {
        row-gap: 0.75rem;
    }

    #upload-progress .progress {
        height: 25px !important;
    }

    #upload-progress #progress-percentage {
        font-size: 0.85rem;
    }

    #file-info-row .col-md-4 {
        width: 100%;
        text-align: left !important;
    }

    #file-info-row .justify-content-md-end {
        justify-content: flex-start !important;
    }
}

/* ========== File Management Card ========== */
@media (max-width: 768px) {
    #file-management-card .card-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }

    #file-management-card .card-header h5 {
        margin-bottom: 0.25rem;
    }

    #file-list .list-group-item {
        padding: 1rem 0.75rem;
    }
}

/* ========== Button Groups ========== */
@media (max-width: 576px) {
    .btn-group {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    .btn-group .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .btn-group .btn:last-child {
        margin-bottom: 0;
    }

    /* Process/Upload buttons */
    #process-button,
    #upload-button {
        width: 100%;
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }
}

/* ========== Tool Options Cards ========== */
@media (max-width: 768px) {
    .card.shadow-lg {
        margin-bottom: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    .card-header h5 {
        font-size: 1rem;
    }
}

/* ========== Hero Section ========== */
@media (max-width: 768px) {
    .hero .display-5 {
        font-size: 1.75rem;
    }

    .hero .lead {
        font-size: 1rem;
    }

    .min-vh-75 {
        min-height: auto !important;
        padding: 2rem 0;
    }
}

/* ========== Form Inputs ========== */
@media (max-width: 576px) {
    .form-control,
    .form-select {
        font-size: 16px !important; /* Prevents iOS zoom on focus */
    }

    input[type="text"],
    input[type="number"],
    input[type="email"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* ========== Alerts and Messages ========== */
@media (max-width: 768px) {
    .alert {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    .alert h6 {
        font-size: 1rem;
    }

    .alert ul {
        padding-left: 1.25rem;
    }

    .alert .btn {
        margin-top: 0.5rem;
        width: 100%;
    }
}

/* ========== Download Results Section ========== */
@media (max-width: 768px) {
    #result-section .btn-lg {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    #result-section .d-flex {
        flex-direction: column;
    }
}

/* ========== Navigation (if needed) ========== */
@media (max-width: 768px) {
    .navbar-nav {
        padding: 1rem 0;
    }

    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
    }
}

/* ========== Modals ========== */
@media (max-width: 576px) {
    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-content {
        border-radius: 0.5rem;
    }

    .modal-body {
        padding: 1rem;
    }
}

/* ========== Tables (for dashboard/admin) ========== */
@media (max-width: 768px) {
    .table-responsive {
        border: 0;
    }

    table {
        font-size: 0.875rem;
    }

    table th,
    table td {
        padding: 0.5rem;
    }
}

/* ========== Landscape Orientation ========== */
@media (max-width: 768px) and (orientation: landscape) {
    .hero {
        padding: 1rem 0;
    }

    .card.shadow-lg {
        margin-bottom: 0.75rem;
    }

    .dropzone {
        min-height: 150px !important;
    }
}

/* ========== Very Small Screens (320px) ========== */
@media (max-width: 375px) {
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .card-body {
        padding: 0.75rem;
    }

    .btn {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }

    .display-5 {
        font-size: 1.5rem;
    }

    .lead {
        font-size: 0.95rem;
    }
}

/* ========== Accessibility Improvements ========== */
@media (max-width: 768px) {
    /* Larger tap targets */
    button,
    .btn,
    a.btn {
        min-height: 44px;
        min-width: 44px;
    }

    /* Better focus indicators for mobile */
    button:focus,
    .btn:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 3px solid rgba(13, 110, 253, 0.5);
        outline-offset: 2px;
    }
}

/* ========== Loading Spinners ========== */
@media (max-width: 576px) {
    #preloader .loader {
        width: 50px;
        height: 50px;
    }

    .spinner-border {
        width: 1.5rem;
        height: 1.5rem;
    }
}

/* ========== Scroll Top Button ========== */
@media (max-width: 768px) {
    #scroll-top {
        width: 40px;
        height: 40px;
        right: 15px;
        bottom: 15px;
    }
}

/* ========== Fix iOS Safari Issues ========== */
@supports (-webkit-touch-callout: none) {
    /* iOS specific fixes */
    .form-control {
        font-size: 16px !important; /* Prevents zoom on focus */
    }

    /* Fix position: fixed on iOS */
    .position-fixed {
        position: -webkit-sticky;
        position: sticky;
    }
}

/* ========== Dark Mode Support (if enabled) ========== */
@media (prefers-color-scheme: dark) {
    @media (max-width: 768px) {
        .dropzone {
            border-color: rgba(255, 255, 255, 0.2);
        }

        .card {
            background-color: #1a1a1a;
            border-color: rgba(255, 255, 255, 0.1);
        }
    }
}

/* ========== Performance: Reduce Animations on Mobile ========== */
@media (max-width: 768px) and (prefers-reduced-motion: no-preference) {
    * {
        animation-duration: 0.3s !important;
        transition-duration: 0.2s !important;
    }
}
