/**
 * URLement Design System - Responsive Design
 * 
 * Comprehensive responsive design patterns and utilities.
 * Ensures the application is easily viewable across all devices.
 */

/* ============================================
   BASE RESPONSIVE SETTINGS
   ============================================ */

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    width: 100%;
    overflow-x: hidden;
}

img, video, iframe {
    max-width: 100%;
    height: auto;
}

/* ============================================
   CONTAINER RESPONSIVE PATTERNS
   ============================================ */

.container-fluid {
    width: 100%;
    padding-left: var(--container-padding-mobile);
    padding-right: var(--container-padding-mobile);
}

@media (min-width: 641px) {
    .container-fluid {
        padding-left: var(--container-padding-tablet);
        padding-right: var(--container-padding-tablet);
    }
}

@media (min-width: 1025px) {
    .container-fluid {
        padding-left: var(--container-padding-desktop);
        padding-right: var(--container-padding-desktop);
        max-width: var(--container-max-width);
        margin-left: auto;
        margin-right: auto;
    }
}

/* ============================================
   TYPOGRAPHY RESPONSIVE SCALING
   ============================================ */

/* Base font sizes scale down on mobile */
@media (max-width: 640px) {
    html {
        font-size: 14px; /* Slightly smaller base on mobile */
    }
    
    h1 {
        font-size: var(--font-size-mobile-2xl);
        line-height: var(--line-height-tight);
    }
    
    h2 {
        font-size: var(--font-size-mobile-xl);
        line-height: var(--line-height-tight);
    }
    
    h3 {
        font-size: var(--font-size-mobile-lg);
    }
    
    h4 {
        font-size: var(--font-size-mobile-base);
    }
    
    p, body {
        font-size: var(--font-size-mobile-base);
        line-height: var(--line-height-relaxed);
    }
}

@media (min-width: 641px) {
    html {
        font-size: 16px; /* Standard base */
    }
}

/* ============================================
   NAVIGATION RESPONSIVE
   ============================================ */

@media (max-width: 640px) {
    .main-nav {
        padding: var(--spacing-mobile-base) 0;
    }
    
    .nav-container {
        padding-left: var(--container-padding-mobile);
        padding-right: var(--container-padding-mobile);
    }
    
    .nav-links {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(20px);
        flex-direction: column;
        padding: var(--spacing-mobile-base) var(--container-padding-mobile);
        gap: var(--spacing-mobile-base);
        border-bottom: var(--border-width) solid rgba(0, 0, 0, 0.05);
        z-index: var(--z-dropdown);
        transform: translateY(-100%);
        opacity: 0;
        pointer-events: none;
        transition: all var(--transition-smooth);
    }
    
    .nav-links.nav-open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }
    
    .nav-toggle {
        display: flex;
        min-width: var(--touch-target-min);
        min-height: var(--touch-target-min);
    }
}

/* ============================================
   BUTTONS RESPONSIVE
   ============================================ */

@media (max-width: 640px) {
    .btn,
    .btn-primary,
    .btn-secondary,
    button[type="submit"],
    button[type="button"]:not(.nav-toggle) {
        min-height: var(--touch-target-min);
        min-width: var(--touch-target-min);
        padding: var(--spacing-mobile-base) var(--spacing-mobile-lg);
        font-size: var(--font-size-mobile-base);
    }
    
    /* Full width buttons on mobile for primary actions */
    .btn-primary,
    .cta-button {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================
   FORMS RESPONSIVE
   ============================================ */

@media (max-width: 640px) {
    .input-group {
        flex-direction: column;
        gap: var(--spacing-mobile-base);
    }
    
    input[type="text"],
    input[type="email"],
    input[type="url"],
    input[type="password"],
    textarea,
    select {
        width: 100%;
        min-height: var(--touch-target-min);
        font-size: var(--font-size-mobile-base);
        padding: var(--spacing-mobile-base);
    }
    
    label {
        font-size: var(--font-size-mobile-base);
        margin-bottom: var(--spacing-mobile-sm);
    }
}

/* ============================================
   CARDS RESPONSIVE
   ============================================ */

@media (max-width: 640px) {
    .card {
        padding: var(--spacing-mobile-base);
        margin-bottom: var(--spacing-mobile-base);
    }
    
    .card-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-mobile-base);
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1025px) {
    .card-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================
   TABLES RESPONSIVE
   ============================================ */

@media (max-width: 640px) {
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        -ms-overflow-style: -ms-autohiding-scrollbar;
    }
    
    .table-wrapper table {
        min-width: 600px;
    }
    
    .table-wrapper::-webkit-scrollbar {
        height: 8px;
    }
    
    .table-wrapper::-webkit-scrollbar-track {
        background: var(--color-bg-secondary);
    }
    
    .table-wrapper::-webkit-scrollbar-thumb {
        background: var(--color-border-alt);
        border-radius: var(--radius-sm);
    }
}

/* ============================================
   TABS RESPONSIVE
   ============================================ */

@media (max-width: 640px) {
    .tabs,
    .results-tabs {
        flex-direction: row;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .tabs::-webkit-scrollbar,
    .results-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .tab-button {
        white-space: nowrap;
        min-width: auto;
        padding: var(--spacing-mobile-base) var(--spacing-mobile-lg);
        font-size: var(--font-size-mobile-base);
    }
}

/* ============================================
   GRID LAYOUTS RESPONSIVE
   ============================================ */

/* Auto-responsive grid */
.auto-grid {
    display: grid;
    gap: var(--spacing-base);
    grid-template-columns: 1fr;
}

@media (min-width: 641px) {
    .auto-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1025px) {
    .auto-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1400px) {
    .auto-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ============================================
   SPACING RESPONSIVE
   ============================================ */

@media (max-width: 640px) {
    /* Reduce section margins on mobile */
    section {
        margin-bottom: var(--spacing-mobile-lg);
        padding: var(--spacing-mobile-base) var(--container-padding-mobile);
    }
    
    /* Reduce container padding */
    .container,
    .dashboard-container,
    .results-container {
        padding: var(--spacing-mobile-lg) var(--container-padding-mobile);
    }
}

/* ============================================
   MODALS & OVERLAYS RESPONSIVE
   ============================================ */

@media (max-width: 640px) {
    .modal,
    .overlay {
        padding: var(--spacing-mobile-base);
    }
    
    .modal-content {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
}

/* ============================================
   IMAGES & MEDIA RESPONSIVE
   ============================================ */

img {
    max-width: 100%;
    height: auto;
    display: block;
}

video,
iframe {
    max-width: 100%;
    height: auto;
}

@media (max-width: 640px) {
    .hero-image,
    .feature-image {
        width: 100%;
        margin: var(--spacing-mobile-base) 0;
    }
}

/* ============================================
   UTILITY CLASSES FOR RESPONSIVE
   ============================================ */

/* Hide on mobile, show on larger screens */
.mobile-only {
    display: block;
}

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

/* Show on larger screens, hide on mobile */
.desktop-only {
    display: none;
}

@media (min-width: 641px) {
    .desktop-only {
        display: block;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    * {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    .no-print {
        display: none !important;
    }
    
    a {
        text-decoration: underline;
    }
    
    img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }
}

