/* ==================== GLOBAL RESPONSIVE STYLES ==================== */
/* Optimizaciones globales para consolas portátiles y móviles */

/* ==================== BASE RESPONSIVE IMPROVEMENTS ==================== */

/* Sidebar responsive */
@media (max-width: 1024px) {
  .sidebar {
    width: 240px;
  }

  .sidebar.collapsed {
    width: 70px;
  }

  .sidebar-item {
    padding: 12px 16px;
  }

  .sidebar-icon {
    font-size: 1.25rem;
  }
}

@media (max-width: 768px) {
  /* Sidebar overlay en móviles */
  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    height: 100vh;
    width: 280px;
    z-index: 1000;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar.collapsed {
    left: -100%;
  }

  /* Main content ocupa todo el ancho */
  .main-content {
    margin-left: 0 !important;
    width: 100%;
  }

  /* Botón hamburguesa */
  .mobile-menu-btn {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 999;
    width: 44px;
    height: 44px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.5rem;
  }

  /* Overlay para cerrar sidebar */
  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
  }

  .sidebar-overlay.active {
    display: block;
  }
}

/* Header responsive */
@media (max-width: 1024px) {
  .header {
    padding: 12px 16px;
  }

  .search-container {
    max-width: 400px;
  }

  .header-actions {
    gap: 10px;
  }
}

@media (max-width: 768px) {
  .header {
    padding: 10px 12px;
    margin-left: 0;
  }

  .search-container {
    max-width: 100%;
    flex: 1;
  }

  .search-input {
    font-size: 0.9rem;
  }

  .header-actions {
    gap: 8px;
  }

  .header-btn {
    padding: 8px 12px;
    font-size: 0.85rem;
  }

  .user-avatar {
    width: 36px;
    height: 36px;
  }
}

@media (max-width: 480px) {
  .header {
    flex-wrap: wrap;
    gap: 10px;
  }

  .search-container {
    order: 3;
    width: 100%;
    margin-top: 8px;
  }

  .header-actions {
    order: 2;
  }

  .header-btn span:not(.icon) {
    display: none; /* Ocultar texto en móviles */
  }

  .header-btn {
    padding: 8px;
    min-width: 40px;
  }
}

/* Platform Grid responsive */
@media (max-width: 1280px) {
  .platform-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
  }

  .platform-card {
    padding: 20px;
  }
}

@media (max-width: 1024px) {
  .platform-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
  }

  .platform-card {
    padding: 18px;
  }

  .platform-icon {
    font-size: 2.5rem;
  }

  .platform-name {
    font-size: 1rem;
  }

  .platform-count {
    font-size: 0.85rem;
  }
}

@media (max-width: 768px) {
  .platform-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }

  .platform-card {
    padding: 16px;
  }

  .platform-icon {
    font-size: 2.25rem;
  }

  .platform-name {
    font-size: 0.95rem;
  }
}

@media (max-width: 480px) {
  .platform-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .platform-card {
    padding: 14px;
    min-height: 120px;
  }

  .platform-icon {
    font-size: 2rem;
    margin-bottom: 8px;
  }

  .platform-name {
    font-size: 0.875rem;
  }

  .platform-count {
    font-size: 0.75rem;
  }
}

/* Games Grid responsive */
@media (max-width: 1280px) {
  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
  }

  .game-item {
    padding: 14px;
  }
}

@media (max-width: 1024px) {
  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
  }

  .game-item {
    padding: 12px;
  }

  .game-name {
    font-size: 0.95rem;
  }
}

@media (max-width: 768px) {
  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }

  .game-item {
    padding: 10px;
  }

  .game-icon {
    font-size: 1.75rem;
  }

  .game-name {
    font-size: 0.9rem;
  }

  .game-size {
    font-size: 0.75rem;
  }
}

@media (max-width: 480px) {
  .games-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .game-item {
    padding: 10px;
  }

  .game-icon {
    font-size: 1.5rem;
  }

  .game-name {
    font-size: 0.85rem;
    line-height: 1.3;
  }

  .game-size {
    font-size: 0.7rem;
  }
}

/* Modals responsive */
@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    max-width: 95%;
    margin: 20px auto;
    max-height: calc(100vh - 40px);
  }

  .modal-header {
    padding: 16px;
  }

  .modal-title {
    font-size: 1.25rem;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-footer {
    padding: 12px 16px;
    flex-direction: column;
    gap: 10px;
  }

  .modal-footer button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .modal-content {
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
  }

  .modal-header {
    padding: 14px;
  }

  .modal-title {
    font-size: 1.125rem;
  }

  .modal-body {
    padding: 14px;
  }
}

/* Download Queue responsive */
@media (max-width: 1024px) {
  .queue-container {
    padding: 16px;
  }

  .queue-item {
    padding: 14px;
  }
}

@media (max-width: 768px) {
  .queue-container {
    padding: 14px;
  }

  .queue-item {
    padding: 12px;
    flex-direction: column;
    align-items: flex-start;
  }

  .queue-item-info {
    width: 100%;
    margin-bottom: 10px;
  }

  .queue-item-actions {
    width: 100%;
    justify-content: space-between;
  }

  .progress-bar {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .queue-item-name {
    font-size: 0.9rem;
  }

  .queue-item-size {
    font-size: 0.8rem;
  }

  .queue-item-actions button {
    padding: 6px 12px;
    font-size: 0.85rem;
  }
}

/* Notifications responsive */
@media (max-width: 768px) {
  .notification {
    width: calc(100% - 32px);
    max-width: 400px;
    margin: 0 16px;
  }
}

@media (max-width: 480px) {
  .notification {
    width: calc(100% - 20px);
    margin: 0 10px;
    padding: 12px;
  }

  .notification-message {
    font-size: 0.875rem;
  }
}

/* Buttons responsive - Áreas táctiles más grandes */
@media (max-width: 768px) {
  button,
  .btn,
  .button {
    min-height: 44px;
    padding: 12px 20px;
  }

  .btn-sm,
  .button-sm {
    min-height: 36px;
    padding: 8px 16px;
  }
}

/* Forms responsive */
@media (max-width: 768px) {
  .form-group {
    margin-bottom: 16px;
  }

  input,
  select,
  textarea {
    font-size: 16px; /* Evita zoom en iOS */
    padding: 12px;
    min-height: 44px;
  }

  label {
    font-size: 0.9rem;
    margin-bottom: 6px;
  }
}

/* Loading states responsive */
@media (max-width: 480px) {
  .loading-spinner {
    width: 40px;
    height: 40px;
  }

  .loading-text {
    font-size: 0.9rem;
  }
}

/* Scrollbar responsive */
@media (max-width: 768px) {
  ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }

  ::-webkit-scrollbar-thumb {
    border-radius: 3px;
  }
}

/* Touch improvements para consolas */
@media (hover: none) and (pointer: coarse) {
  /* Feedback táctil */
  button:active,
  .btn:active,
  .platform-card:active,
  .game-item:active {
    transform: scale(0.98);
    opacity: 0.9;
  }

  /* Eliminar hover states */
  button:hover,
  .btn:hover,
  .platform-card:hover,
  .game-item:hover {
    transform: none;
  }

  /* Scroll suave */
  * {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
  }
}

/* Safe area para dispositivos con notch */
@supports (padding: env(safe-area-inset-bottom)) {
  .header {
    padding-top: env(safe-area-inset-top);
  }

  .sidebar {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .main-content {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* Landscape mode para consolas */
@media (max-height: 600px) and (orientation: landscape) {
  .sidebar {
    padding: 12px 8px;
  }

  .sidebar-item {
    padding: 10px 12px;
  }

  .platform-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

/* High DPI optimization */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  body,
  button,
  input {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* Performance optimizations */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}