/**
 * LAYOUT - GOMALOR
 * Sistema de grid, containers y estructura de página
 */

/* ============================================
   CONTAINER
   ============================================ */

.container {
  width: 100%;
  max-width: var(--container-xl);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-md);
  padding-right: var(--space-md);
}

@media (min-width: 640px) {
  .container {
    max-width: var(--container-sm);
  }
}

@media (min-width: 768px) {
  .container {
    max-width: var(--container-md);
    padding-left: var(--space-lg);
    padding-right: var(--space-lg);
  }
}

@media (min-width: 1024px) {
  .container {
    max-width: var(--container-lg);
  }
}

@media (min-width: 1280px) {
  .container {
    max-width: var(--container-xl);
  }
}

@media (min-width: 1536px) {
  .container {
    max-width: var(--container-2xl);
  }
}

/* Container fluid (sin max-width) */
.container-fluid {
  width: 100%;
  padding-left: var(--space-md);
  padding-right: var(--space-md);
}

/* ============================================
   GRID SYSTEM
   ============================================ */

.grid {
  display: grid;
  gap: var(--space-md);
}

/* Grid de 2 columnas */
.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

/* Grid de 3 columnas */
.grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

/* Grid de 4 columnas */
.grid-cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

/* Grid responsive automático */
.grid-auto-fit {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-auto-fill {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

/* Gaps personalizados */
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }

/* ============================================
   FLEXBOX LAYOUTS
   ============================================ */

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-row {
  flex-direction: row;
}

.flex-wrap {
  flex-wrap: wrap;
}

.flex-nowrap {
  flex-wrap: nowrap;
}

/* Justify content */
.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }
.justify-evenly { justify-content: space-evenly; }

/* Align items */
.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.items-stretch { align-items: stretch; }
.items-baseline { align-items: baseline; }

/* Align self */
.self-start { align-self: flex-start; }
.self-center { align-self: center; }
.self-end { align-self: flex-end; }
.self-stretch { align-self: stretch; }

/* Flex grow/shrink */
.flex-1 { flex: 1 1 0%; }
.flex-auto { flex: 1 1 auto; }
.flex-none { flex: none; }

/* ============================================
   RESPONSIVE GRIDS
   ============================================ */

/* Mobile first: 1 columna por defecto */
@media (max-width: 767px) {
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }
  
  .grid-cols-mobile-2 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Tablet: 2 columnas */
@media (min-width: 768px) and (max-width: 1023px) {
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .grid-cols-tablet-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Desktop: columnas completas */
@media (min-width: 1024px) {
  .grid-cols-desktop-4 {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .grid-cols-desktop-5 {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* ============================================
   TWO COLUMN LAYOUTS
   ============================================ */

.two-col {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xl);
  align-items: center;
}

@media (min-width: 768px) {
  .two-col {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* Variante 60/40 */
  .two-col--60-40 {
    grid-template-columns: 60fr 40fr;
  }
  
  /* Variante 40/60 */
  .two-col--40-60 {
    grid-template-columns: 40fr 60fr;
  }
  
  /* Variante 70/30 */
  .two-col--70-30 {
    grid-template-columns: 70fr 30fr;
  }
}

/* ============================================
   ASPECT RATIOS
   ============================================ */

.aspect-ratio {
  position: relative;
  width: 100%;
}

.aspect-ratio::before {
  content: '';
  display: block;
  padding-bottom: var(--aspect-ratio, 100%);
}

.aspect-ratio > * {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Ratios predefinidos */
.aspect-ratio-16-9 { --aspect-ratio: 56.25%; }   /* 9/16 * 100 */
.aspect-ratio-4-3 { --aspect-ratio: 75%; }       /* 3/4 * 100 */
.aspect-ratio-3-2 { --aspect-ratio: 66.666%; }   /* 2/3 * 100 */
.aspect-ratio-1-1 { --aspect-ratio: 100%; }      /* Cuadrado */

/* ============================================
   POSITION UTILITIES
   ============================================ */

.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

/* Posicionamiento absoluto común */
.absolute-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.absolute-top-left {
  position: absolute;
  top: 0;
  left: 0;
}

.absolute-top-right {
  position: absolute;
  top: 0;
  right: 0;
}

.absolute-bottom-left {
  position: absolute;
  bottom: 0;
  left: 0;
}

.absolute-bottom-right {
  position: absolute;
  bottom: 0;
  right: 0;
}

/* Full coverage */
.absolute-full {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ============================================
   OVERFLOW
   ============================================ */

.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-scroll { overflow: scroll; }
.overflow-visible { overflow: visible; }

.overflow-x-hidden { overflow-x: hidden; }
.overflow-y-hidden { overflow-y: hidden; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

/* ============================================
   WIDTH & HEIGHT
   ============================================ */

.w-full { width: 100%; }
.w-auto { width: auto; }
.w-screen { width: 100vw; }

.h-full { height: 100%; }
.h-auto { height: auto; }
.h-screen { height: 100vh; }

.min-h-screen { min-height: 100vh; }
.min-h-full { min-height: 100%; }

.max-w-full { max-width: 100%; }
.max-w-screen { max-width: 100vw; }

/* ============================================
   SPACING (complemento a utilities en base.css)
   ============================================ */

.p-0 { padding: 0; }
.p-1 { padding: var(--space-xs); }
.p-2 { padding: var(--space-sm); }
.p-3 { padding: var(--space-md); }
.p-4 { padding: var(--space-lg); }
.p-5 { padding: var(--space-xl); }

.px-0 { padding-left: 0; padding-right: 0; }
.px-1 { padding-left: var(--space-xs); padding-right: var(--space-xs); }
.px-2 { padding-left: var(--space-sm); padding-right: var(--space-sm); }
.px-3 { padding-left: var(--space-md); padding-right: var(--space-md); }
.px-4 { padding-left: var(--space-lg); padding-right: var(--space-lg); }

.py-0 { padding-top: 0; padding-bottom: 0; }
.py-1 { padding-top: var(--space-xs); padding-bottom: var(--space-xs); }
.py-2 { padding-top: var(--space-sm); padding-bottom: var(--space-sm); }
.py-3 { padding-top: var(--space-md); padding-bottom: var(--space-md); }
.py-4 { padding-top: var(--space-lg); padding-bottom: var(--space-lg); }

/* ============================================
   VISIBILITY
   ============================================ */

.visible { visibility: visible; }
.invisible { visibility: hidden; }

.opacity-0 { opacity: 0; }
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }
.opacity-100 { opacity: 1; }

/* ============================================
   RESPONSIVE UTILITIES
   ============================================ */

/* Ocultar en móvil */
@media (max-width: 767px) {
  .hide-mobile { display: none !important; }
}

/* Ocultar en tablet */
@media (min-width: 768px) and (max-width: 1023px) {
  .hide-tablet { display: none !important; }
}

/* Ocultar en desktop */
@media (min-width: 1024px) {
  .hide-desktop { display: none !important; }
}

/* Mostrar solo en móvil */
.show-mobile {
  display: block;
}

@media (min-width: 768px) {
  .show-mobile {
    display: none !important;
  }
}

/* Mostrar solo en desktop */
.show-desktop {
  display: none;
}

@media (min-width: 1024px) {
  .show-desktop {
    display: block;
  }
}