/* ==========================================================================
   Mobile Tool Page Enhancements
   Comprehensive responsive optimizations for individual tool pages
   ========================================================================== */

/* ==========================================================================
   Enhanced Mobile Navigation for Tool Pages
   ========================================================================== */

/* Mobile Navigation Toggle */
.mobile-nav-toggle {
    display: none !important; /* Always hidden by default */
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1001;
    background: rgba(15, 23, 42, 0.9);
    border: none;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    backdrop-filter: blur(12px);
    transition: all 0.2s ease;
    /* Prevent layout breaking */
    pointer-events: auto;
}

.mobile-nav-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: white;
    margin: 3px 0;
    border-radius: 1px;
    transition: all 0.3s ease;
}

.mobile-nav-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-nav-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-nav-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Mobile Navigation Overlay */
.mobile-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    z-index: 1000;
    transform: translateY(-100%);
    opacity: 0;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Prevent accidental visibility */
    visibility: hidden;
    pointer-events: none;
}

.mobile-nav-overlay.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.mobile-nav-menu {
    text-align: center;
    padding: 2rem;
}

.mobile-nav-menu a {
    display: block;
    color: white;
    font-size: 1.5rem;
    font-weight: 600;
    text-decoration: none;
    padding: 1rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

.mobile-nav-menu a:hover {
    color: #4F46E5;
    transform: translateX(10px);
}

/* ==========================================================================
   Mobile-First Responsive Breakpoints
   ========================================================================== */

/* Tablet (768px and below) */
@media (max-width: 768px) {
    /* Header Improvements */
    header .container {
        position: relative;
        padding: 1rem;
    }

    /* Only show mobile nav toggle on actual tool pages, not homepage */
    body:not(.homepage) .mobile-nav-toggle {
        display: block !important;
    }

    nav {
        display: none;
    }

    .logo {
        font-size: 1.5rem;
    }

    /* Tool Section */
    .tool-section {
        padding: 2rem 0;
    }

    .container {
        padding: 0 1rem;
        max-width: 100%;
    }

    /* Tool Header */
    .tool-header h1 {
        font-size: 1.75rem;
        line-height: 1.2;
        margin-bottom: 0.5rem;
    }

    .tool-description {
        font-size: 1rem;
        line-height: 1.5;
        margin-bottom: 1rem;
    }

    .privacy-badge {
        font-size: 0.8rem;
        padding: 0.5rem 1rem;
        margin-bottom: 1.5rem;
    }

    /* Tool Area */
    .tool-area {
        padding: 1.5rem;
        border-radius: 12px;
    }

    /* Upload Areas */
    .upload-area {
        padding: 2rem 1rem;
        border-radius: 12px;
        margin-bottom: 1.5rem;
    }

    .upload-area h3 {
        font-size: 1.25rem;
        margin-bottom: 0.75rem;
    }

    .upload-area p {
        font-size: 0.9rem;
        margin-bottom: 1rem;
    }

    .upload-icon {
        font-size: 2.5rem;
        margin-bottom: 1rem;
    }

    /* Enhanced Buttons */
    .btn-primary, .btn-secondary {
        min-height: 48px;
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
        font-weight: 600;
        border-radius: 10px;
        touch-action: manipulation;
        transition: all 0.2s ease;
    }

    .btn-primary:active, .btn-secondary:active {
        transform: scale(0.98);
    }

    /* Text Areas and Inputs */
    textarea, .tool-textarea {
        min-height: 120px;
        padding: 1rem;
        font-size: 1rem;
        line-height: 1.5;
        border-radius: 10px;
        border: 2px solid var(--border, #E2E8F0);
        resize: vertical;
    }

    textarea:focus, .tool-textarea:focus {
        border-color: var(--primary, #4F46E5);
        box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
        outline: none;
    }

    /* Tool Options */
    .tool-options, .case-buttons {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 0.75rem;
        margin: 1.5rem 0;
    }

    .tool-btn, .case-btn {
        min-height: 44px;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        font-weight: 500;
        border-radius: 8px;
        border: 2px solid var(--border, #E2E8F0);
        background: var(--bg, white);
        color: var(--text, #0F172A);
        cursor: pointer;
        transition: all 0.2s ease;
        touch-action: manipulation;
    }

    .tool-btn:hover, .case-btn:hover {
        border-color: var(--primary, #4F46E5);
        color: var(--primary, #4F46E5);
        transform: translateY(-1px);
    }

    .tool-btn:active, .case-btn:active {
        transform: scale(0.98);
    }

    /* File Management */
    .file-item {
        padding: 1rem;
        margin-bottom: 0.75rem;
        border-radius: 10px;
        border: 2px solid var(--border, #E2E8F0);
        background: var(--surface, #F8FAFC);
    }

    .file-item .handle {
        font-size: 1.25rem;
        padding: 0.5rem;
        cursor: grab;
    }

    .file-item .info .name {
        font-size: 1rem;
        font-weight: 600;
        margin-bottom: 0.25rem;
    }

    .file-item .info .size {
        font-size: 0.85rem;
        color: var(--text-secondary, #64748B);
    }

    .file-item .remove {
        min-width: 44px;
        min-height: 44px;
        padding: 0.5rem;
        font-size: 1.5rem;
        border-radius: 8px;
        background: #FEF2F2;
        color: var(--error, #EF4444);
        border: none;
        cursor: pointer;
        touch-action: manipulation;
    }

    /* Actions Panel */
    .actions {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        margin-top: 1.5rem;
    }

    /* Results Area */
    .results-area {
        padding: 1.5rem;
        margin-top: 1.5rem;
        border-radius: 12px;
        text-align: center;
        background: var(--surface, #F8FAFC);
    }

    /* Progress Bar */
    .progress-bar {
        height: 6px;
        margin-top: 1rem;
        border-radius: 3px;
        background: var(--border, #E2E8F0);
        overflow: hidden;
    }

    .progress-fill {
        height: 100%;
        background: var(--primary, #4F46E5);
        border-radius: 3px;
        transition: width 0.3s ease;
    }
}

/* Mobile (480px and below) */
@media (max-width: 480px) {
    .container {
        padding: 0 0.75rem;
    }

    .tool-header h1 {
        font-size: 1.5rem;
    }

    .tool-area {
        padding: 1rem;
    }

    .upload-area {
        padding: 1.5rem 0.75rem;
    }

    .tool-options, .case-buttons {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .tool-btn, .case-btn {
        font-size: 0.8rem;
        padding: 0.6rem 0.75rem;
        min-height: 40px;
    }

    .actions {
        gap: 0.5rem;
    }

    .btn-primary, .btn-secondary {
        width: 100%;
        justify-content: center;
    }

    /* Smaller text inputs */
    textarea, .tool-textarea {
        min-height: 100px;
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    .file-item {
        padding: 0.75rem;
    }

    .file-item .handle {
        font-size: 1rem;
    }

    .privacy-badge {
        font-size: 0.75rem;
        padding: 0.4rem 0.8rem;
    }
}

/* Small Mobile (360px and below) */
@media (max-width: 360px) {
    .container {
        padding: 0 0.5rem;
    }

    .tool-header h1 {
        font-size: 1.375rem;
        line-height: 1.1;
    }

    .tool-description {
        font-size: 0.9rem;
    }

    .tool-area {
        padding: 0.75rem;
    }

    .upload-area {
        padding: 1rem 0.5rem;
    }

    .upload-area h3 {
        font-size: 1.125rem;
    }

    .upload-area p {
        font-size: 0.8rem;
    }

    .tool-options, .case-buttons {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }

    .privacy-badge {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
    }

    .breadcrumb {
        padding: 0.5rem 0;
        font-size: 0.8rem;
    }
}

/* ==========================================================================
   Touch and Interaction Optimizations
   ========================================================================== */

@media (max-width: 768px) {
    /* Improve touch targets */
    button, input, select, textarea {
        min-height: 44px;
    }

    /* Prevent zoom on input focus */
    input, select, textarea {
        font-size: 16px;
    }

    /* Better click areas */
    .file-item {
        cursor: pointer;
        user-select: none;
    }

    .upload-area {
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .upload-area:active {
        transform: scale(0.99);
        background: var(--primary-light, #EEF2FF);
    }

    /* Smooth scrolling */
    html {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }

    /* Better focus states */
    button:focus, input:focus, select:focus, textarea:focus {
        outline: 3px solid rgba(79, 70, 229, 0.3);
        outline-offset: 2px;
    }
}

/* ==========================================================================
   Landscape Mobile Optimization
   ========================================================================== */

@media (max-height: 500px) and (orientation: landscape) {
    .tool-section {
        padding: 1rem 0;
    }

    .tool-header {
        margin-bottom: 1rem;
    }

    .tool-header h1 {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }

    .tool-description {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
    }

    .privacy-badge {
        margin-bottom: 1rem;
    }

    .upload-area {
        padding: 1.5rem 1rem;
    }

    textarea, .tool-textarea {
        min-height: 80px;
    }
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .mobile-nav-toggle {
        background: rgba(255, 255, 255, 0.1);
    }

    .mobile-nav-overlay {
        background: rgba(0, 0, 0, 0.95);
    }

    .mobile-nav-menu a {
        color: #F1F5F9;
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }

    .mobile-nav-menu a:hover {
        color: #60A5FA;
    }
}

/* ==========================================================================
   Accessibility Improvements
   ========================================================================== */

@media (max-width: 768px) {
    /* Focus management */
    .mobile-nav-toggle:focus {
        outline: 3px solid #60A5FA;
        outline-offset: 2px;
    }

    /* High contrast mode support */
    @media (prefers-contrast: high) {
        .tool-btn, .case-btn {
            border-width: 3px;
        }

        .upload-area {
            border-width: 4px;
        }
    }

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

        .mobile-nav-overlay {
            transition: none;
        }
    }
}