/* Mobile-First Responsive Design for All Tools */

/* Universal Mobile Improvements */
@media (max-width: 768px) {
    /* Ensure all content is properly sized */
    * {
        box-sizing: border-box;
    }
    
    /* Prevent horizontal scrolling */
    html, body {
        overflow-x: hidden;
        width: 100%;
    }
    
    /* Improve touch targets */
    button, .btn, a.button, input[type="button"], input[type="submit"] {
        min-height: 44px;
        min-width: 44px;
        padding: 1rem 1.5rem;
        font-size: 1.1rem;
        margin: 0.5rem 0;
        border-radius: 8px;
        width: 100%;
        max-width: 100%;
    }
    
    /* Form elements */
    input, textarea, select {
        width: 100%;
        padding: 1rem;
        font-size: 1.1rem;
        border-radius: 8px;
        margin-bottom: 1rem;
        min-height: 44px;
    }
    
    /* Text areas specifically */
    textarea {
        min-height: 150px;
        resize: vertical;
    }
    
    /* Result areas */
    [id$="Result"], .result, .output {
        padding: 1.2rem;
        font-size: 1.2rem;
        line-height: 1.5;
        word-break: break-word;
        overflow-wrap: break-word;
    }
    
    /* Button containers */
    .buttons, .controls, .actions, [class$="-buttons"] {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        margin: 1rem 0;
    }
    
    /* Two-column layouts become single column */
    .two-column, .split-layout, .side-by-side {
        flex-direction: column;
    }
    
    /* Improve spacing */
    section, .section {
        padding: 1rem 0.5rem;
    }
    
    /* Headers and titles */
    h1 {
        font-size: 1.8rem;
        line-height: 1.3;
        margin: 1rem 0;
    }
    
    h2 {
        font-size: 1.5rem;
        line-height: 1.3;
        margin: 0.8rem 0;
    }
    
    h3 {
        font-size: 1.3rem;
        line-height: 1.3;
        margin: 0.6rem 0;
    }
    
    /* Code blocks and pre-formatted text */
    pre, code {
        font-size: 0.9rem;
        overflow-x: auto;
        word-break: break-all;
        white-space: pre-wrap;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    /* Even more touch-friendly */
    button, .btn, a.button, input[type="button"], input[type="submit"] {
        padding: 1.2rem 1.5rem;
        font-size: 1.2rem;
        margin: 0.8rem 0;
    }
    
    input, textarea, select {
        padding: 1.2rem;
        font-size: 1.2rem;
    }
    
    /* Reduce margins for small screens */
    section, .section {
        padding: 0.8rem 0.3rem;
    }
    
    /* Smaller headers */
    h1 {
        font-size: 1.6rem;
    }
    
    h2 {
        font-size: 1.4rem;
    }
    
    h3 {
        font-size: 1.2rem;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 900px) and (orientation: landscape) {
    /* Optimize for landscape mobile */
    textarea {
        min-height: 120px;
    }
    
    .buttons, .controls, .actions, [class$="-buttons"] {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .buttons button, .controls button, .actions button, [class$="-buttons"] button {
        flex: 1;
        min-width: 120px;
        width: auto;
    }
}

/* Touch-specific improvements */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects for touch devices */
    button:hover, .btn:hover, a:hover {
        transform: none;
    }
    
    /* Increase tap targets */
    a, button, input, select, textarea {
        min-height: 48px;
    }
    
    /* Improve focus states for accessibility */
    button:focus, input:focus, textarea:focus, select:focus {
        outline: 3px solid #3d8a59;
        outline-offset: 2px;
    }
}

/* Fix for iOS Safari viewport issues */
@supports (-webkit-touch-callout: none) {
    .main-content, .container {
        min-height: -webkit-fill-available;
    }
}

/* Utility classes for mobile */
.mobile-hidden {
    display: none;
}

.mobile-only {
    display: block;
}

@media (min-width: 769px) {
    .mobile-hidden {
        display: block;
    }
    
    .mobile-only {
        display: none;
    }
}

/* Loading states for mobile */
.loading {
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    margin: auto;
    border: 2px solid transparent;
    border-top: 2px solid #3d8a59;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
