/* =========================
   TERMINAL-X RESPONSIVE
   ========================= */

/* Extra Small Devices (576px and down) */
@media (max-width: 575.98px) {
    body {
        padding-top: 60px;
        padding-bottom: 96px;
    }
    
    .container {
        padding: 0 var(--spacing-sm);
    }
    
    /* Typography */
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
    
    /* Hero Section */
    .hero-section {
        padding: 40px 0;
        margin: 0 calc(-1 * var(--spacing-sm)) 30px;
        text-align: center;
    }
    
    .hero-section h1 {
        font-size: 2rem;
        margin-bottom: var(--spacing-md);
    }
    
    .hero-section .lead {
        font-size: 1rem;
        margin-bottom: var(--spacing-lg);
    }
    
    /* Navigation */
    .navbar-nav {
        text-align: center;
        padding: var(--spacing-md) 0;
    }
    
    .navbar-nav .nav-item {
        margin-bottom: var(--spacing-sm);
    }
    
    /* Cards Grid */
    #ads-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }
    
    .ad-card {
        max-width: 100%;
        min-height: auto;
    }
    
    /* Buttons */
    .btn {
        width: 100%;
        margin-bottom: var(--spacing-sm);
    }
    
    .btn-group .btn {
        width: auto;
    }
    
    /* Forms */
    .form-control,
    .form-select {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    /* Tables */
    .table-responsive {
        font-size: 0.875rem;
    }
    
    /* Modals */
    .modal-dialog {
        margin: var(--spacing-sm);
    }
    
    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    /* Breadcrumb */
    .breadcrumb {
        font-size: 0.875rem;
        padding: var(--spacing-xs) var(--spacing-sm);
    }
}

/* Small Devices (576px and up) */
@media (min-width: 576px) and (max-width: 767.98px) {
    /* Cards Grid */
    #ads-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Hero Section */
    .hero-section {
        padding: 60px 0;
    }
}

/* Medium Devices (768px and up) */
@media (min-width: 768px) and (max-width: 991.98px) {
    /* Cards Grid */
    #ads-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-lg);
    }
    
    /* Sidebar Layout */
    .sidebar-layout {
        grid-template-columns: 1fr 250px;
    }
    
    /* Hero Section */
    .hero-section {
        padding: 80px 0;
    }
    
    /* Navigation */
    .navbar-nav {
        margin-left: auto;
    }
}

/* Large Devices (992px and up) */
@media (min-width: 992px) and (max-width: 1199.98px) {
    /* Cards Grid */
    #ads-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* Sidebar Layout */
    .sidebar-layout {
        grid-template-columns: 1fr 300px;
    }
    
    /* Hero Section */
    .hero-section {
        padding: 100px 0;
    }
}

/* Extra Large Devices (1200px and up) */
@media (min-width: 1200px) {
    /* Cards Grid */
    #ads-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    /* Container */
    .container {
        max-width: var(--container-max-width);
    }
    
    /* Hero Section */
    .hero-section {
        padding: 120px 0;
    }
}

/* Landscape Orientation */
@media (max-height: 500px) and (orientation: landscape) {
    .hero-section {
        padding: 40px 0;
    }
    
    .modal-dialog {
        margin: var(--spacing-xs) auto;
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Optimize images for retina displays */
    .card-img-wrapper img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    /* Custom dark mode styles can be added here */
    /* Variables are already defined in variables.css */
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    /* Disable animations for users who prefer reduced motion */
    .hero-section::before {
        animation: none;
    }
    
    .card:hover {
        transform: none;
    }
    
    .btn:hover {
        transform: none;
    }
}

/* Print Styles */
@media print {
    /* Hide unnecessary elements */
    .navbar,
    .btn,
    .modal,
    footer {
        display: none !important;
    }
    
    /* Optimize content for printing */
    body {
        font-size: 12pt;
        line-height: 1.4;
        color: #000;
        background: #fff;
    }
    
    .card {
        border: 1px solid #000;
        break-inside: avoid;
        margin-bottom: 1rem;
    }
    
    .hero-section {
        background: none;
        color: #000;
        padding: 1rem 0;
    }
    
    /* Ensure links are visible */
    a::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #000;
    }
    
    a[href^="#"]::after {
        content: "";
    }
}

/* Touch Devices */
@media (hover: none) and (pointer: coarse) {
    /* Optimize for touch interfaces */
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .card {
        margin-bottom: var(--spacing-lg);
    }
    
    /* Increase tap targets */
    .nav-link {
        padding: var(--spacing-md) var(--spacing-lg);
    }
    
    /* Disable hover effects */
    .card:hover {
        transform: none;
    }
    
    .btn:hover {
        transform: none;
    }
}
