/* ============================================
   RESPONSIVE - Media queries y ajustes globales
   ============================================ */

/* Pantallas grandes (1200px+) */
@media (min-width: 1201px) {
    .main-content {
        grid-template-columns: 1fr 380px;
    }
}

/* Pantallas medianas (1024px - 1200px) */
@media (max-width: 1200px) {
    :root {
        --sidebar-width: 340px;
    }
    
    .main-content {
        grid-template-columns: 1fr 340px;
        gap: 1.5rem;
    }
    
    .header-stats {
        gap: 1rem;
    }
}

/* Tablets y pantallas pequeñas (768px - 1024px) */
@media (max-width: 1024px) {
    :root {
        --header-height: 70px;
    }
    
    .main-content {
        grid-template-columns: 1fr;
        padding: 0 1.5rem 1.5rem;
    }
    
    .stats-panel {
        position: static;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 1rem;
        order: -1;
    }
    
    .section-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .sort-options {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0.5rem;
    }
    
    .sort-btn {
        flex-shrink: 0;
    }
}

/* Móviles grandes (480px - 768px) */
@media (max-width: 768px) {
    :root {
        font-size: 15px;
    }
    
    .glass-header {
        padding: 0.75rem 1rem;
    }
    
    .header-content {
        grid-template-columns: 40px 1fr 40px;
        gap: 0.3rem;
    }
    
    .icon-button {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }
    
    .logo h1 {
        font-size: 1.4rem;
    }
    
    .logo-image,
    .logo-fallback {
        width: 38px;
        height: 38px;
    }
    
    .logo-badge {
        font-size: 0.6rem;
        padding: 0.15rem 0.4rem;
    }
    
    .header-stats {
        gap: 0.8rem;
    }
    
    .stat-value {
        font-size: 1rem;
    }
    
    .stat-label {
        font-size: 0.6rem;
    }
    
    .stat-divider {
        height: 24px;
    }
    
    .filters-container {
        margin: 1rem auto;
        padding: 0 1rem;
    }
    
    .search-box input {
        padding: 0.8rem 1rem 0.8rem 2.5rem;
        font-size: 0.9rem;
    }
    
    .main-content {
        padding: 0 1rem 1rem;
        gap: 1rem;
    }
    
    .section-title h2 {
        font-size: 1.4rem;
    }
    
    .ai-card {
        padding: 1.2rem;
        border-radius: var(--radius-lg);
    }
    
    .card-rank {
        font-size: 1.6rem;
        min-width: 40px;
    }
    
    .card-info h3 {
        font-size: 1.1rem;
    }
    
    .card-stats {
        gap: 1rem;
    }
    
    .card-stat {
        font-size: 0.8rem;
    }
    
    .panel-card {
        padding: 1.2rem;
    }
    
    .chart-container {
        height: 200px;
    }
}

/* Móviles pequeños (320px - 480px) */
@media (max-width: 480px) {
    :root {
        font-size: 14px;
    }
    
    .glass-header {
        padding: 0.5rem 0.75rem;
    }
    
    .header-content {
        grid-template-columns: 36px 1fr 36px;
    }
    
    .icon-button {
        width: 34px;
        height: 34px;
        font-size: 0.9rem;
    }
    
    .icon-button .btn-tooltip {
        display: none;
    }
    
    .logo h1 {
        font-size: 1.2rem;
    }
    
    .logo-image,
    .logo-fallback {
        width: 32px;
        height: 32px;
        border-radius: 8px;
    }
    
    .logo-badge {
        display: none;
    }
    
    .header-stats {
        gap: 0.5rem;
    }
    
    .stat-value {
        font-size: 0.9rem;
    }
    
    .stat-label {
        font-size: 0.55rem;
    }
    
    .stat-divider {
        height: 20px;
    }
    
    .filters-container {
        margin: 0.75rem auto;
        padding: 0 0.75rem;
        gap: 0.5rem;
    }
    
    .search-box input {
        padding: 0.7rem 0.8rem 0.7rem 2.2rem;
        font-size: 0.85rem;
        border-radius: var(--radius-md);
    }
    
    .search-box i {
        left: 0.8rem;
        font-size: 0.9rem;
    }
    
    .category-filters {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.3rem;
    }
    
    .filter-btn {
        padding: 0.45rem 0.3rem;
        font-size: 0.7rem;
        border-radius: 15px;
    }
    
    .main-content {
        padding: 0 0.75rem 0.75rem;
        gap: 0.75rem;
    }
    
    .section-title h2 {
        font-size: 1.2rem;
    }
    
    .sort-btn {
        padding: 0.4rem 0.7rem;
        font-size: 0.7rem;
    }
    
    .sort-btn span {
        display: none;
    }
    
    .ai-card {
        padding: 1rem;
        border-radius: var(--radius-md);
    }
    
    .card-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 0.5rem;
    }
    
    .card-rank {
        font-size: 1.4rem;
        min-width: auto;
    }
    
    .card-rating {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    
    .card-stats {
        justify-content: center;
        gap: 0.75rem;
    }
    
    .card-stat span {
        font-size: 0.75rem;
    }
    
    .expand-btn {
        font-size: 0.8rem;
        padding: 0.6rem;
    }
    
    .features-list {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
    
    .modal-header h2 {
        font-size: 1.3rem;
    }
    
    .modal-details-grid {
        grid-template-columns: 1fr;
    }
    
    .comment-form {
        padding: 1rem;
    }
    
    .rating-input {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* Móviles muy pequeños (menos de 360px) */
@media (max-width: 360px) {
    .logo h1 {
        font-size: 1.1rem;
    }
    
    .category-filters {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .filter-btn i {
        font-size: 0.8rem;
    }
}

/* Modo landscape en móviles */
@media (max-height: 500px) and (orientation: landscape) {
    .glass-header {
        position: relative;
    }
    
    .stats-panel {
        position: static;
    }
    
    .modal-content {
        max-height: 95vh;
        border-radius: var(--radius-lg);
    }
}

/* Pantallas de alta resolución */
@media (min-width: 1600px) {
    :root {
        --sidebar-width: 420px;
        --max-width: 1500px;
    }
    
    .ai-card {
        padding: 2rem;
    }
    
    .card-rank {
        font-size: 2.5rem;
    }
    
    .chart-container {
        height: 300px;
    }
}

/* Preferencias de reducción de movimiento */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .particles-background {
        display: none;
    }
    
    .logo-badge {
        animation: none;
    }
}

/* Modo oscuro del sistema */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-primary: #0a0a1a;
        --bg-secondary: #12122a;
        --bg-tertiary: #1a1a3e;
        --text-primary: #ffffff;
        --text-secondary: #a0a0b8;
        --text-tertiary: #6a6a8a;
    }
}

/* Soporte para pantallas táctiles */
@media (hover: none) and (pointer: coarse) {
    .ai-card:hover {
        transform: none;
    }
    
    .trending-item:hover {
        transform: none;
    }
    
    .filter-btn:hover {
        transform: none;
    }
    
    .kofi-button:hover {
        transform: none;
    }
}

/* Impresión */
@media print {
    .particles-background,
    .background-gradient,
    .glass-header,
    .update-progress,
    .filters-container,
    .stats-panel,
    .modal-overlay,
    .toast-container,
    .glass-footer,
    .expand-btn,
    .icon-button {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .main-content {
        display: block;
        padding: 0;
    }
    
    .ai-card {
        break-inside: avoid;
        border: 1px solid #ccc;
        background: white;
        margin-bottom: 1rem;
    }
    
    .card-details {
        max-height: none !important;
        opacity: 1 !important;
    }
}