/**
 * ============================================
 * NATIVE MOBILE STYLES
 * ============================================
 *
 * Estilos CSS para lograr una experiencia nativa en móvil.
 * Incluye: ripple effects, press states, animaciones y transiciones.
 */

/* ============================================
   ANIMACIONES KEYFRAMES
   ============================================ */

/* Ripple effect para botones */
@keyframes ripple {
  from {
    transform: scale(0);
    opacity: 0.5;
  }
  to {
    transform: scale(1);
    opacity: 0;
  }
}

/* Shimmer para skeletons */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Bounce suave para pull-to-refresh */
@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Pulse para elementos de carga */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* 🆕 Parpadeo para solicitudes de día libre pendientes */
@keyframes pending-blink {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
  }
  50% {
    opacity: 0.4;
    box-shadow: 0 0 8px 4px rgba(34, 197, 94, 0.6);
  }
}

/* Clase para celdas de calendario con día libre pendiente */
.shift-pending-approval {
  animation: pending-blink 1.5s ease-in-out infinite !important;
  cursor: pointer !important;
}

/* Cursor pointer en elementos interactivos del header (evita que migraciones/estilos lo sobrescriban) */
header button,
header a,
header [role="button"],
.section-header-gradient button,
.section-header-gradient a {
  cursor: pointer !important;
}

/* Slide in desde la derecha */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Slide out hacia la derecha */
@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Slide up desde abajo */
@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Slide down */
@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Fade in */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Fade out */
@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* Scale in */
@keyframes scaleIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Pop effect para aparición */
@keyframes pop {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Shake para errores */
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-4px);
  }
  20%,
  40%,
  60%,
  80% {
    transform: translateX(4px);
  }
}

/* Check mark animation */
@keyframes checkmark {
  0% {
    stroke-dashoffset: 100;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

/* Spin for loading */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ============================================
   CLASES DE ANIMACIÓN
   ============================================ */

.animate-ripple {
  animation: ripple 0.6s linear forwards;
}

.animate-shimmer {
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.1) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.animate-bounce-soft {
  animation: bounce 1s ease-in-out infinite;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

.animate-slide-in-right {
  animation: slideInRight 0.3s ease-out forwards;
}

.animate-slide-out-right {
  animation: slideOutRight 0.3s ease-in forwards;
}

.animate-slide-up {
  animation: slideUp 0.3s ease-out forwards;
}

.animate-slide-down {
  animation: slideDown 0.3s ease-out forwards;
}

.animate-fade-in {
  animation: fadeIn 0.2s ease-out forwards;
}

/* Entrada de la app tras splash - overlay que se desvanece (el contenido no se anima = scroll táctil OK) */
.animate-app-enter-overlay {
  animation: fadeOut 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  opacity: 1;
}

/* Transición suave splash → app: fade + scale sutil */
@keyframes appContentEnter {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
.animate-app-content-enter {
  animation: appContentEnter 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@media (prefers-reduced-motion: reduce) {
  .animate-app-content-enter {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* Animación sofisticada para transiciones entre vistas - Estilo iOS/Apple */
@keyframes viewTransition {
  0% {
    opacity: 0;
    transform: scale(0.98);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.animate-viewTransition {
  animation: viewTransition 0.22s cubic-bezier(0.22, 1, 0.36, 1) forwards !important;
  will-change: opacity, transform;
}

/* Entrada suave para la primera carga (recarga o acceso inicial) */
@keyframes viewTransitionInitial {
  0% {
    opacity: 0;
    transform: scale(0.99);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.animate-viewTransition-initial {
  animation: viewTransitionInitial 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards !important;
  will-change: opacity, transform;
}

/* Keyframes para overlay de activación Aria */
@keyframes aria-bg-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes aria-bg-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
@keyframes aria-box-in {
  0% {
    opacity: 0;
    transform: scale(0.35) translateY(30px);
    filter: blur(20px);
  }
  50% {
    opacity: 1;
    transform: scale(1.1) translateY(-6px);
    filter: blur(0);
  }
  70% {
    transform: scale(0.96) translateY(3px);
  }
  85% {
    transform: scale(1.02) translateY(-2px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
    filter: blur(0);
  }
}
@keyframes aria-box-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}
@keyframes aria-box-out {
  0% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  30% {
    opacity: 1;
    transform: scale(1.02) translateY(-12vh);
  }
  100% {
    opacity: 0;
    transform: scale(0.8) translateY(-40vh);
  }
}
@keyframes aria-shine {
  0% {
    left: -150%;
  }
  60% {
    left: 150%;
  }
  100% {
    left: 150%;
  }
}
@keyframes aria-mic-bounce {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  25% {
    transform: translateY(-6px) scale(1.12);
  }
  50% {
    transform: translateY(-2px) scale(1.05);
  }
  75% {
    transform: translateY(-5px) scale(1.1);
  }
}
.aria-mic-bounce {
  animation: aria-mic-bounce 1.2s ease-in-out infinite;
}

/* Sombra/brillo animado del header cuando Aria está activa */
@keyframes aria-header-glow {
  0%,
  100% {
    box-shadow:
      0 4px 20px rgba(124, 58, 237, 0.35),
      0 0 30px rgba(124, 58, 237, 0.15);
  }
  50% {
    box-shadow:
      0 4px 28px rgba(124, 58, 237, 0.55),
      0 0 50px rgba(147, 51, 234, 0.35);
  }
}
.aria-header-active {
  position: relative;
  overflow: visible;
  animation: aria-header-glow 2.5s ease-in-out infinite;
}

/* Transición más suave en móvil para evitar sensación brusca al cambiar de hoja */
@media (max-width: 767px) {
  .animate-viewTransition {
    animation: viewTransition 0.28s cubic-bezier(0.22, 1, 0.36, 1) forwards !important;
  }
  .animate-viewTransition-initial {
    animation: viewTransitionInitial 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards !important;
  }
}

.animate-fade-out {
  animation: fadeOut 0.2s ease-in forwards;
}

.animate-scale-in {
  animation: scaleIn 0.2s ease-out forwards;
}

.animate-pop {
  animation: pop 0.3s ease-out forwards;
}

.animate-shake {
  animation: shake 0.5s ease-in-out;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* ============================================
   PRESS STATES Y TOUCH FEEDBACK
   ============================================ */

/* Press scale genérico */
.press-scale {
  transition: transform 0.15s ease-out;
  will-change: transform;
}

.press-scale:active {
  transform: scale(0.97);
}

/* Press scale más pronunciado */
.press-scale-strong {
  transition: transform 0.15s ease-out;
  will-change: transform;
}

.press-scale-strong:active {
  transform: scale(0.94);
}

/* Press con opacity */
.press-opacity {
  transition: opacity 0.15s ease-out;
}

.press-opacity:active {
  opacity: 0.7;
}

/* Press con background */
.press-bg {
  transition: background-color 0.15s ease-out;
}

.press-bg:active {
  background-color: rgba(0, 0, 0, 0.1);
}

/* ============================================
   TOUCH OPTIMIZATIONS
   ============================================ */

/* Eliminar highlight en touch */
.touch-none {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

/* Touch manipulation para mejor respuesta */
.touch-manipulation {
  touch-action: manipulation;
}

/* Touch pan solo vertical */
.touch-pan-y {
  touch-action: pan-y;
}

/* Touch pan solo horizontal */
.touch-pan-x {
  touch-action: pan-x;
}

/* ============================================
   GPU ACCELERATION
   ============================================ */

.gpu-accelerated {
  transform: translateZ(0);
  will-change: transform;
  backface-visibility: hidden;
  perspective: 1000px;
}

/* ============================================
   SKELETON STYLES
   ============================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--skeleton-base, rgba(0, 0, 0, 0.08)) 0%,
    var(--skeleton-highlight, rgba(0, 0, 0, 0.12)) 50%,
    var(--skeleton-base, rgba(0, 0, 0, 0.08)) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
}

.skeleton-text {
  height: 1em;
  border-radius: 4px;
}

.skeleton-circle {
  border-radius: 50%;
}

.skeleton-card {
  border-radius: 12px;
}

/* Dark theme skeletons */
[data-theme="dark"] .skeleton,
.dark .skeleton {
  --skeleton-base: rgba(255, 255, 255, 0.05);
  --skeleton-highlight: rgba(255, 255, 255, 0.1);
}

/* ============================================
   TRANSITIONS SUAVES
   ============================================ */

.transition-fast {
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}

.transition-normal {
  transition-duration: 200ms;
  transition-timing-function: ease-out;
}

.transition-slow {
  transition-duration: 300ms;
  transition-timing-function: ease-out;
}

.transition-spring {
  transition-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================
   SAFE AREAS (for notch and navigation bar)
   ============================================ */

.safe-top {
  padding-top: env(safe-area-inset-top, 0);
}

.safe-bottom {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.safe-left {
  padding-left: env(safe-area-inset-left, 0);
}

.safe-right {
  padding-right: env(safe-area-inset-right, 0);
}

.safe-all {
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

/* Min height accounting for safe areas */
.min-h-safe-screen {
  min-height: calc(100vh - env(safe-area-inset-top, 0) - env(safe-area-inset-bottom, 0));
}

/* ============================================
   REDUCED MOTION
   ============================================ */

@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;
  }

  /* Excepción: overlay de activación Aria mantiene sus animaciones.
     revert devuelve 0s para animation-duration, por eso usamos valor explícito. */
  .aria-activation-overlay,
  .aria-activation-overlay *,
  .aria-activation-overlay *::before,
  .aria-activation-overlay *::after {
    animation-duration: 0.7s !important;
  }

  .animate-shimmer,
  .animate-bounce-soft,
  .animate-pulse,
  .animate-spin {
    animation: none !important;
  }
  .aria-header-active {
    animation: none !important;
    box-shadow: 0 4px 24px rgba(124, 58, 237, 0.4) !important;
  }
}

/* ============================================
   PULL TO REFRESH INDICATOR
   ============================================ */

.pull-refresh-indicator {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(-100%);
  z-index: 9999;
  transition: transform 0.2s ease-out;
}

.pull-refresh-indicator.visible {
  transform: translateX(-50%) translateY(env(safe-area-inset-top, 20px));
}

.pull-refresh-indicator.refreshing {
  animation: bounce-soft 1s ease-in-out infinite;
}

/* ============================================
   SWIPE NAVIGATION HINTS
   ============================================ */

.swipe-hint-left {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 60px;
  background: linear-gradient(to right, rgba(var(--primary-rgb, 59, 130, 246), 0.3), transparent);
  border-radius: 0 4px 4px 0;
  opacity: 0;
  transition: opacity 0.2s ease-out;
  pointer-events: none;
  z-index: 9998;
}

.swipe-hint-left.visible {
  opacity: 1;
}

/* ============================================
   BOTTOM NAVIGATION BAR STYLES
   ============================================ */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--base-100);
  border-top: 1px solid var(--base-200);
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 50;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  color: var(--base-content-secondary, #666);
  transition: color 0.2s ease-out;
}

.bottom-nav-item.active {
  color: var(--primary);
}

.bottom-nav-item:active {
  transform: scale(0.95);
}

/* ============================================
   CARD PRESS EFFECT
   ============================================ */

.card-pressable {
  transition:
    transform 0.15s ease-out,
    box-shadow 0.15s ease-out;
  will-change: transform, box-shadow;
}

.card-pressable:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ============================================
   FLOATING ACTION BUTTON
   ============================================ */

.fab {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom, 0));
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition:
    transform 0.2s ease-out,
    box-shadow 0.2s ease-out;
  z-index: 40;
}

.fab:active {
  transform: scale(0.92);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ============================================
   LIST ITEM STYLES
   ============================================ */

.list-item-interactive {
  position: relative;
  overflow: hidden;
  transition: background-color 0.15s ease-out;
}

.list-item-interactive:active {
  background-color: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .list-item-interactive:active,
.dark .list-item-interactive:active {
  background-color: rgba(255, 255, 255, 0.05);
}

/* ============================================
   MODAL BACKDROP
   ============================================ */

.modal-backdrop {
  background-color: rgba(0, 0, 0, 0.58);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast-enter {
  animation: slideUp 0.3s ease-out forwards;
}

.toast-exit {
  animation: fadeOut 0.2s ease-in forwards;
}

/* ============================================
   LOADING STATES
   ============================================ */

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.92);
  z-index: 10;
}

[data-theme="dark"] .loading-overlay,
.dark .loading-overlay {
  background-color: rgba(0, 0, 0, 0.8);
}

/* ============================================
   TABLET ADAPTIVE HEADER (600-1280px)
   ============================================
   Gaps y padding fluidos para que la barra de
   navegación escale bien en iPad Air, iPad Pro
   y tablets Android (Galaxy Tab S7 FE, etc.).
   Alineado con Tailwind md (600px).
   ============================================ */
@media (min-width: 600px) and (max-width: 1280px) {
  header nav,
  header [class*="gap-"] {
    gap: clamp(0.25rem, 1.2vw, 0.75rem);
  }

  header button.rounded-xl {
    padding: clamp(0.25rem, 0.6vw, 0.5rem);
  }
}

/* ============================================
   LANDSCAPE ORIENTATION STYLES
   ============================================
   Estilos específicos para dispositivos en modo landscape.
   
   Breakpoints:
   - Móvil landscape: altura < 500px
   - Tablet landscape: altura entre 500-800px
   ============================================ */

/* ============================================
   MÓVIL LANDSCAPE (altura < 500px)
   ============================================ */
@media (orientation: landscape) and (max-height: 500px) {
  /* ========================================
     FORZAR GRID 2x2 EN LANDSCAPE MÓVIL
     ======================================== */
  /* Contenedores que usan flex-col en móvil pero grid en desktop */
  .flex.flex-col.md\:grid,
  [class*="flex"][class*="flex-col"][class*="md:grid"] {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    grid-template-rows: repeat(2, 1fr) !important;
    gap: 0.5rem !important;
    overflow: hidden !important;
    height: calc(100vh - 100px) !important;
  }

  /* Cards de las categorías del menú */
  [class*="flex"][class*="flex-col"][class*="md:grid"] > div {
    min-height: 0 !important;
    overflow: hidden !important;
  }

  /* Header principal súper compacto */
  header.sticky,
  header[class*="sticky"] {
    padding-top: 0.15rem !important;
    padding-bottom: 0.15rem !important;
    min-height: 40px !important;
    max-height: 48px !important;
  }

  /* Logo más pequeño en landscape */
  header .h-14,
  header [class*="h-14"] {
    height: 2rem !important;
  }

  /* Ocultar texto "CostePro" en móvil landscape para ganar espacio */
  header .text-xl.font-semibold,
  header span.hidden.md\\:inline-flex {
    display: none !important;
  }

  /* Botón C más pequeño */
  header .h-8.w-8,
  header .h-10.w-10 {
    height: 1.75rem !important;
    width: 1.75rem !important;
    font-size: 0.875rem !important;
  }

  /* Navegación desktop más compacta (attribute selector evita error de minificador con gap-2.5) */
  header [class*="gap-2.5"],
  header [class*="gap-3.5"] {
    gap: 0.25rem !important;
  }

  header button.p-2 {
    padding: 0.25rem !important;
  }

  /* Títulos de vista más pequeños */
  h1.text-2xl,
  .text-2xl {
    font-size: 1rem !important;
    line-height: 1.25rem !important;
  }

  h2.text-xl,
  .text-xl {
    font-size: 0.875rem !important;
    line-height: 1rem !important;
  }

  /* Main content con padding mínimo */
  main.flex-1 {
    padding: 0.25rem !important;
    padding-bottom: 0.5rem !important;
  }

  /* Cards de categorías más compactas */
  .rounded-2xl {
    border-radius: 0.75rem !important;
  }

  /* Gaps reducidos globalmente */
  .gap-3 {
    gap: 0.375rem !important;
  }

  .gap-4 {
    gap: 0.5rem !important;
  }

  /* py-6 del header de la vista */
  .py-6 {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
  }

  /* Header más compacto (clase específica) */
  .landscape-header-compact {
    padding-top: 0.25rem !important;
    padding-bottom: 0.25rem !important;
    min-height: 44px !important;
  }

  .landscape-header-compact h1,
  .landscape-header-compact .text-xl {
    font-size: 1rem !important;
    line-height: 1.25rem !important;
  }

  /* Reducir padding general */
  .landscape-compact {
    padding: 0.25rem !important;
  }

  .landscape-compact-x {
    padding-left: 0.25rem !important;
    padding-right: 0.25rem !important;
  }

  .landscape-compact-y {
    padding-top: 0.25rem !important;
    padding-bottom: 0.25rem !important;
  }

  /* Drawer más estrecho en landscape */
  .landscape-drawer {
    max-width: 60vw !important;
  }

  /* Grids más anchos (más columnas) */
  .landscape-grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }

  .landscape-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  .landscape-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  /* Cards más compactas */
  .landscape-card-compact {
    padding: 0.5rem !important;
  }

  .landscape-card-compact .text-lg {
    font-size: 0.875rem !important;
  }

  /* Modales adaptados */
  .landscape-modal {
    max-height: 90vh !important;
    max-width: 90vw !important;
    width: 90vw !important;
  }

  .landscape-modal-content {
    max-height: calc(90vh - 60px) !important;
    overflow-y: auto !important;
  }

  /* Layout de dos columnas para modales */
  .landscape-modal-2col {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 1rem !important;
  }

  /* FAB reposicionado */
  .landscape-fab {
    bottom: 8px !important;
    right: 8px !important;
    width: 48px !important;
    height: 48px !important;
  }

  /* Safe areas laterales para landscape */
  .landscape-safe-x {
    padding-left: max(0.5rem, env(safe-area-inset-left)) !important;
    padding-right: max(0.5rem, env(safe-area-inset-right)) !important;
  }

  /* Scroll horizontal para tablas */
  .landscape-scroll-x {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Textos más pequeños */
  .landscape-text-sm {
    font-size: 0.75rem !important;
    line-height: 1rem !important;
  }

  /* Botones más compactos */
  .landscape-btn-compact {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.75rem !important;
    min-height: 32px !important;
  }

  /* Ocultar elementos en landscape móvil */
  .landscape-mobile-hidden {
    display: none !important;
  }

  /* Mostrar solo en landscape móvil */
  .landscape-mobile-only {
    display: block !important;
  }

  /* Flex en landscape */
  .landscape-flex-row {
    flex-direction: row !important;
  }

  .landscape-flex-nowrap {
    flex-wrap: nowrap !important;
  }

  /* Gap reducido */
  .landscape-gap-1 {
    gap: 0.25rem !important;
  }

  .landscape-gap-2 {
    gap: 0.5rem !important;
  }

  /* Altura máxima para listas */
  .landscape-max-h-full {
    max-height: calc(100vh - 60px) !important;
  }
}

/* ============================================
   TABLET LANDSCAPE (altura entre 500-800px)
   ============================================ */
@media (orientation: landscape) and (min-height: 501px) and (max-height: 800px) {
  /* Header ligeramente más compacto */
  .landscape-tablet-header {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
  }

  /* Drawer ancho moderado */
  .landscape-tablet-drawer {
    max-width: 50vw !important;
  }

  /* Grids optimizados para tablet landscape */
  .landscape-tablet-grid-5 {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  }

  .landscape-tablet-grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }

  .landscape-tablet-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  /* Modales más anchos */
  .landscape-tablet-modal {
    max-width: 80vw !important;
    width: 80vw !important;
  }

  /* Layout de dos columnas */
  .landscape-tablet-2col {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 1rem !important;
  }

  /* Safe areas */
  .landscape-tablet-safe-x {
    padding-left: max(1rem, env(safe-area-inset-left)) !important;
    padding-right: max(1rem, env(safe-area-inset-right)) !important;
  }

  /* Ocultar en tablet landscape */
  .landscape-tablet-hidden {
    display: none !important;
  }

  /* Mostrar solo en tablet landscape */
  .landscape-tablet-only {
    display: block !important;
  }
}

/* ============================================
   CLASES GENERALES PARA CUALQUIER LANDSCAPE
   ============================================ */
@media (orientation: landscape) {
  /* Clases visibles solo en landscape */
  .portrait-only {
    display: none !important;
  }

  .landscape-only {
    display: block !important;
  }

  .landscape-flex {
    display: flex !important;
  }

  .landscape-grid {
    display: grid !important;
  }

  .landscape-hidden {
    display: none !important;
  }

  /* Safe areas para landscape (notch lateral) */
  .landscape-safe-all {
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
}

/* ============================================
   CLASES PARA PORTRAIT
   ============================================ */
@media (orientation: portrait) {
  .landscape-only {
    display: none !important;
  }

  .portrait-only {
    display: block !important;
  }

  .portrait-flex {
    display: flex !important;
  }

  .portrait-grid {
    display: grid !important;
  }

  .portrait-hidden {
    display: none !important;
  }
}

/* ============================================
   INICIALIZADORES (ocultar por defecto)
   ============================================ */
.landscape-mobile-only,
.landscape-tablet-only {
  display: none;
}

/* ============================================
   AUTO-RESPONSIVE GRIDS PARA LANDSCAPE
   ============================================
   Clases que modifican automáticamente los grids
   para aprovechar el espacio horizontal en landscape
   ============================================ */

/* En móvil landscape, los grids de 2 columnas pasan a 3 */
@media (orientation: landscape) and (max-height: 500px) {
  .auto-grid-landscape {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  /* Grids de cards con más columnas */
  .grid.grid-cols-2:not(.no-landscape-adapt) {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  /* Flex columns se convierten en rows */
  .flex.flex-col.md\\:grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    grid-template-rows: repeat(2, 1fr) !important;
  }

  /* Header principal más compacto */
  header.sticky {
    padding-top: 0.25rem !important;
    padding-bottom: 0.25rem !important;
  }

  /* Logo más pequeño */
  header .h-14 {
    height: 2.5rem !important;
  }

  /* Títulos de sección más pequeños */
  h1,
  .text-2xl,
  .text-xl {
    font-size: 1rem !important;
    line-height: 1.25rem !important;
  }

  /* Cards de categorías más compactas */
  .rounded-2xl,
  .rounded-xl {
    padding: 0.5rem !important;
  }

  /* Reducir gaps */
  .gap-3,
  .gap-4 {
    gap: 0.5rem !important;
  }

  /* Main content con menos padding */
  main {
    padding: 0.25rem !important;
  }

  /* Modales y contenedores con altura máxima */
  .modal-box,
  .modal-content,
  [class*="modal"] {
    max-height: 85vh !important;
  }

  /* Listas virtualizadas con filas más compactas */
  .list-row-compact {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
  }
}

/* En tablet landscape, grids de 2 pasan a 4 */
@media (orientation: landscape) and (min-height: 501px) and (max-height: 800px) {
  .auto-grid-landscape {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }

  .grid.grid-cols-2:not(.no-landscape-adapt) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .grid.grid-cols-4:not(.no-landscape-adapt) {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

/* ============================================
   PANTALLAS ESTRECHAS (< 400px de ancho)
   ============================================
   Optimizaciones para dispositivos con pantallas 
   muy estrechas como Huawei P40 Pro (~360px),
   iPhone SE, y otros dispositivos compactos.
   ============================================ */

/* Pantallas muy estrechas (< 380px) - ej: iPhone SE, dispositivos compactos */
@media (max-width: 379px) {
  /* ========================================
     PADDING Y MARGIN REDUCIDOS
     ======================================== */
  .p-4 {
    padding: 0.75rem !important;
  }
  .p-5 {
    padding: 1rem !important;
  }
  .p-6 {
    padding: 1.25rem !important;
  }
  .px-4 {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
  .px-5 {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
  .px-6 {
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
  }
  .py-4 {
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
  }
  .py-6 {
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
  }

  .m-4 {
    margin: 0.75rem !important;
  }
  .mx-4 {
    margin-left: 0.75rem !important;
    margin-right: 0.75rem !important;
  }

  /* Gaps reducidos */
  .gap-4 {
    gap: 0.75rem !important;
  }
  .gap-5 {
    gap: 1rem !important;
  }
  .gap-6 {
    gap: 1.25rem !important;
  }

  /* ========================================
     TIPOGRAFÍA COMPACTA
     ======================================== */
  .text-xl {
    font-size: 1rem !important;
    line-height: 1.375rem !important;
  }
  .text-2xl {
    font-size: 1.125rem !important;
    line-height: 1.5rem !important;
  }
  .text-3xl {
    font-size: 1.25rem !important;
    line-height: 1.625rem !important;
  }
  .text-4xl {
    font-size: 1.5rem !important;
    line-height: 1.875rem !important;
  }

  /* El titular de la landing (.cine-h1) tiene su propio tamaño: sin esta excepción encogía
     de golpe al cargar esta hoja en móviles de < 380 px. */
  h1:not(.cine-h1) {
    font-size: 1.25rem !important;
  }
  h2 {
    font-size: 1.125rem !important;
  }
  h3 {
    font-size: 1rem !important;
  }

  /* ========================================
     GRIDS ADAPTATIVOS
     ======================================== */
  /* Grids de 2 columnas pasan a 1 columna */
  .grid-cols-2:not(.narrow-keep-cols) {
    grid-template-columns: 1fr !important;
  }

  /* Grids de 3+ columnas pasan a 2 */
  .grid-cols-3:not(.narrow-keep-cols),
  .grid-cols-4:not(.narrow-keep-cols) {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* ========================================
     MODALES FULL-WIDTH
     ======================================== */
  .modal-box,
  [class*="max-w-sm"],
  [class*="max-w-md"],
  [class*="max-w-lg"],
  [class*="max-w-xl"],
  [class*="max-w-2xl"],
  [class*="max-w-3xl"],
  [class*="max-w-4xl"],
  [class*="max-w-5xl"],
  [class*="max-w-6xl"] {
    max-width: calc(100% - 1rem) !important;
    width: calc(100% - 1rem) !important;
    margin-left: 0.5rem !important;
    margin-right: 0.5rem !important;
  }

  /* ========================================
     BOTONES MÁS COMPACTOS
     ======================================== */
  /* Los de solo icono (círculo/cuadrado) no llevan relleno: con él el icono se encoge. */
  .btn:not(.btn-circle):not(.btn-square) {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  .btn-lg {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    min-height: 2.75rem !important;
  }

  /* ========================================
     TABLAS CON SCROLL HORIZONTAL
     ======================================== */
  table {
    display: block !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  /* ========================================
     FORMULARIOS FULL-WIDTH
     ======================================== */
  input,
  select,
  textarea {
    max-width: 100% !important;
  }

  .input,
  .select,
  .textarea {
    width: 100% !important;
  }

  /* ========================================
     HEADER COMPACTO
     ======================================== */
  header {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }

  header .gap-2,
  header .gap-3 {
    gap: 0.375rem !important;
  }

  /* ========================================
     CARDS COMPACTAS
     ======================================== */
  .card {
    padding: 0.75rem !important;
  }

  .card-body {
    padding: 0.75rem !important;
  }

  /* ========================================
     NAVEGACIÓN BOTTOM
     ======================================== */
  .bottom-nav-item {
    padding: 6px 8px !important;
  }

  .bottom-nav-item svg,
  .bottom-nav-item .w-6 {
    width: 1.25rem !important;
    height: 1.25rem !important;
  }

  /* ========================================
     FAB REPOSICIONADO
     ======================================== */
  .fab {
    width: 48px !important;
    height: 48px !important;
    right: 12px !important;
  }
}

/* Pantallas estrechas (380-479px) - ej: Huawei P40 Pro, muchos Android */
@media (min-width: 380px) and (max-width: 479px) {
  /* ========================================
     PADDING LIGERAMENTE REDUCIDO
     ======================================== */
  .p-5 {
    padding: 1rem !important;
  }
  .p-6 {
    padding: 1.25rem !important;
  }
  .px-5 {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
  .px-6 {
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
  }

  /* ========================================
     TIPOGRAFÍA AJUSTADA
     ======================================== */
  .text-2xl {
    font-size: 1.25rem !important;
    line-height: 1.625rem !important;
  }
  .text-3xl {
    font-size: 1.5rem !important;
    line-height: 1.875rem !important;
  }

  /* ========================================
     GRIDS ADAPTATIVOS
     ======================================== */
  /* Grids de 3+ columnas se reducen */
  .grid-cols-3:not(.narrow-keep-cols) {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .grid-cols-4:not(.narrow-keep-cols) {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* ========================================
     MODALES ADAPTADOS
     ======================================== */
  [class*="max-w-3xl"],
  [class*="max-w-4xl"] {
    max-width: calc(100% - 1.5rem) !important;
    width: calc(100% - 1.5rem) !important;
  }
}

/* ============================================
   CLASES DE UTILIDAD PARA PANTALLAS ESTRECHAS
   ============================================ */

/* Ocultar en pantallas estrechas */
@media (max-width: 479px) {
  .narrow-hidden {
    display: none !important;
  }

  .narrow-visible {
    display: block !important;
  }

  .narrow-flex {
    display: flex !important;
  }

  /* Columnas en pantallas estrechas */
  .narrow-flex-col {
    flex-direction: column !important;
  }

  /* Full width en pantallas estrechas */
  .narrow-w-full {
    width: 100% !important;
  }

  /* Texto más pequeño */
  .narrow-text-sm {
    font-size: 0.875rem !important;
    line-height: 1.25rem !important;
  }

  .narrow-text-xs {
    font-size: 0.75rem !important;
    line-height: 1rem !important;
  }

  /* Padding reducido */
  .narrow-p-2 {
    padding: 0.5rem !important;
  }

  .narrow-p-3 {
    padding: 0.75rem !important;
  }

  .narrow-px-2 {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }

  .narrow-px-3 {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  /* Gap reducido */
  .narrow-gap-2 {
    gap: 0.5rem !important;
  }

  .narrow-gap-3 {
    gap: 0.75rem !important;
  }

  /* Scroll horizontal para contenido ancho */
  .narrow-scroll-x {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Truncar texto */
  .narrow-truncate {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  /* Grid a 1 columna */
  .narrow-grid-cols-1 {
    grid-template-columns: 1fr !important;
  }

  /* Centrado */
  .narrow-text-center {
    text-align: center !important;
  }

  /* Iconos más pequeños */
  .narrow-icon-sm svg,
  .narrow-icon-sm .w-6,
  .narrow-icon-sm .h-6 {
    width: 1.25rem !important;
    height: 1.25rem !important;
  }

  /* Botones apilados */
  .narrow-btn-stack {
    flex-direction: column !important;
    gap: 0.5rem !important;
  }

  .narrow-btn-stack > button,
  .narrow-btn-stack > a {
    width: 100% !important;
  }
}

/* Clases que mantienen comportamiento en pantallas estrechas */
.narrow-keep-cols {
  /* Esta clase previene la adaptación automática de columnas */
}

/* ============================================
   LIGHT MODE - MOBILE NATIVE STYLES
   ============================================
   Estilos para componentes nativos móviles en modo claro.
   Añade tonalidades verdes CostePro para dar identidad visual.
   ============================================ */

/* Light mode: Press states con tinte verde */
.light .press-bg:active {
  background-color: rgba(42, 157, 143, 0.08) !important;
}

/* Light mode: Card press con sombra verde */
.light .card-pressable {
  border: 1px solid rgba(42, 157, 143, 0.08);
}
.light .card-pressable:active {
  box-shadow: 0 2px 8px rgba(15, 57, 51, 0.1) !important;
  border-color: rgba(42, 157, 143, 0.15) !important;
}

/* Light mode: List items con hover verde */
.light .list-item-interactive:active {
  background-color: rgba(42, 157, 143, 0.06) !important;
}

/* Light mode: FAB con sombra verde */
.light .fab {
  box-shadow:
    0 4px 16px rgba(15, 57, 51, 0.15),
    0 2px 6px rgba(15, 57, 51, 0.08) !important;
}
.light .fab:active {
  box-shadow: 0 2px 8px rgba(15, 57, 51, 0.2) !important;
}

/* Light mode: Bottom nav con borde verde sutil */
.light .bottom-nav {
  background: linear-gradient(180deg, #ffffff 0%, #f8fcfb 100%) !important;
  border-top: 1px solid rgba(42, 157, 143, 0.12) !important;
  box-shadow: 0 -2px 12px rgba(15, 57, 51, 0.06) !important;
}
.light .bottom-nav-item.active {
  color: #0f3933 !important;
}

/* Light mode: Modal backdrop con tinte verde */
.light .modal-backdrop {
  background-color: rgba(15, 57, 51, 0.3) !important;
}

/* Light mode: Loading overlay con fondo verde sutil */
.light .loading-overlay {
  background-color: rgba(240, 247, 246, 0.92) !important;
}

/* Light mode: Toast con borde verde */
.light .toast-enter {
  border: 1px solid rgba(42, 157, 143, 0.15) !important;
  box-shadow: 0 8px 24px rgba(15, 57, 51, 0.12) !important;
}

/* Light mode: Skeleton con tinte verde */
.light .skeleton {
  --skeleton-base: rgba(42, 157, 143, 0.05);
  --skeleton-highlight: rgba(42, 157, 143, 0.1);
}

/* Light mode: Shimmer con tinte verde */
.light .animate-shimmer {
  background: linear-gradient(90deg, transparent 0%, rgba(42, 157, 143, 0.08) 50%, transparent 100%) !important;
  background-size: 200% 100%;
}

/* Light mode: Swipe hint con verde CostePro */
.light .swipe-hint-left {
  background: linear-gradient(to right, rgba(42, 157, 143, 0.3), transparent) !important;
}

/* Light mode: Pull refresh con verde */
.light .pull-refresh-indicator {
  color: #2a9d8f !important;
}

/* ============================================
   MEJORAS DE SCROLL PARA MÓVIL
   ============================================ */
@media (max-width: 767px) {
  /* Scroll suave para contenedores */
  .mobile-scroll-smooth {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
  }

  /* Ocultar scrollbar pero mantener funcionalidad */
  .mobile-scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }

  .mobile-scrollbar-hide::-webkit-scrollbar {
    display: none;
  }

  /* Scroll horizontal con indicadores */
  .mobile-scroll-x {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
  }

  .mobile-scroll-x > * {
    scroll-snap-align: start;
  }

  /* Contenedor de tabla responsiva */
  .mobile-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-left: -0.75rem;
    margin-right: -0.75rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  /* Indicador de scroll horizontal */
  .mobile-scroll-indicator {
    position: relative;
  }

  .mobile-scroll-indicator::after {
    content: "";
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(to right, transparent, var(--base-100, #fff));
    pointer-events: none;
    opacity: 0.8;
  }
}
