/**
 * Layout System - Aprender21
 * Sistema de layout moderno sin Bootstrap
 * Reemplaza container, row, col-* con CSS Grid y Flexbox
 */

/* ========== CONTAINERS ========== */

.container {
  width: 100%;
  max-width: var(--max-width-7xl); /* 1280px */
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

.container-fluid {
  width: 100%;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

.container-narrow {
  width: 100%;
  max-width: var(--max-width-4xl); /* 896px */
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

/* Responsive containers */
@media (min-width: 640px) {
  .container,
  .container-narrow {
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }
}

@media (min-width: 1024px) {
  .container,
  .container-narrow {
    padding-left: var(--space-8);
    padding-right: var(--space-8);
  }
}

/* ========== CSS GRID SYSTEM ========== */

.grid {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* Columnas específicas */
.grid-1 { grid-template-columns: 1fr; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }

/* Grid gaps */
.gap-0 { gap: 0; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* Grid responsive */
@media (max-width: 1024px) {
  .grid-4,
  .grid-5,
  .grid-6 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .grid-2,
  .grid-3,
  .grid-4,
  .grid-5,
  .grid-6 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .grid-2,
  .grid-3,
  .grid-4,
  .grid-5,
  .grid-6 {
    grid-template-columns: 1fr;
  }
}

/* Grid para cards de expertos (específico Aprender21) */
.grid-expertos {
  display: grid;
  gap: var(--space-8) var(--space-5);
  grid-template-columns: repeat(auto-fill, minmax(288px, 1fr));
  justify-items: center;
}

@media (max-width: 640px) {
  .grid-expertos {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }
}

/* ========== FLEXBOX SYSTEM ========== */

.flex {
  display: flex;
}

.inline-flex {
  display: inline-flex;
}

/* Dirección */
.flex-row { flex-direction: row; }
.flex-row-reverse { flex-direction: row-reverse; }
.flex-col { flex-direction: column; }
.flex-col-reverse { flex-direction: column-reverse; }

/* Wrap */
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }

/* Justify content (horizontal) */
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }
.justify-evenly { justify-content: space-evenly; }

/* Align items (vertical) */
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.items-center { align-items: center; }
.items-baseline { align-items: baseline; }
.items-stretch { align-items: stretch; }

/* Align self */
.self-auto { align-self: auto; }
.self-start { align-self: flex-start; }
.self-end { align-self: flex-end; }
.self-center { align-self: center; }
.self-stretch { align-self: stretch; }

/* Flex grow/shrink */
.flex-1 { flex: 1 1 0%; }
.flex-auto { flex: 1 1 auto; }
.flex-initial { flex: 0 1 auto; }
.flex-none { flex: none; }

.grow { flex-grow: 1; }
.grow-0 { flex-grow: 0; }
.shrink { flex-shrink: 1; }
.shrink-0 { flex-shrink: 0; }

/* ========== LAYOUT HELPERS ========== */

/* Sidebar + Main layout (para coursesfilter.php) */
.layout-sidebar {
  display: flex;
  gap: var(--space-6);
}

.sidebar {
  flex: 0 0 280px;
}

.main-content {
  flex: 1;
  min-width: 0; /* Evita overflow en flex */
}

@media (max-width: 768px) {
  .layout-sidebar {
    flex-direction: column;
  }
  
  .sidebar {
    flex: 1;
  }
}

/* Centrar contenido */
.center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.center-x {
  display: flex;
  justify-content: center;
}

.center-y {
  display: flex;
  align-items: center;
}

/* ========== ASPECT RATIO ========== */

.aspect-square { aspect-ratio: 1 / 1; }
.aspect-video { aspect-ratio: 16 / 9; }
.aspect-4-3 { aspect-ratio: 4 / 3; }

/* ========== POSITION ========== */

.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

/* Inset helpers */
.inset-0 {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

.top-0 { top: 0; }
.right-0 { right: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }

/* ========== Z-INDEX ========== */

.z-0 { z-index: var(--z-0); }
.z-10 { z-index: var(--z-10); }
.z-20 { z-index: var(--z-20); }
.z-30 { z-index: var(--z-30); }
.z-40 { z-index: var(--z-40); }
.z-50 { z-index: var(--z-50); }

/* ========== OVERFLOW ========== */

.overflow-auto { overflow: auto; }
.overflow-hidden { overflow: hidden; }
.overflow-visible { overflow: visible; }
.overflow-scroll { overflow: scroll; }

.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

/* ========== VISIBILITY ========== */

.visible { visibility: visible; }
.invisible { visibility: hidden; }

/* ========== RESPONSIVE VISIBILITY ========== */

/* Ocultar en móviles */
@media (max-width: 640px) {
  .hidden-mobile { display: none !important; }
}

/* Ocultar en tablets */
@media (min-width: 641px) and (max-width: 1024px) {
  .hidden-tablet { display: none !important; }
}

/* Ocultar en desktop */
@media (min-width: 1025px) {
  .hidden-desktop { display: none !important; }
}

/* Mostrar solo en móviles */
.show-mobile { display: none !important; }
@media (max-width: 640px) {
  .show-mobile { display: block !important; }
}

/* Mostrar solo en desktop */
.show-desktop { display: none !important; }
@media (min-width: 1025px) {
  .show-desktop { display: block !important; }
}

/* ========== SECTION SPACING ========== */

.section {
  padding-top: var(--space-12);
  padding-bottom: var(--space-12);
}

.section-sm {
  padding-top: var(--space-8);
  padding-bottom: var(--space-8);
}

.section-lg {
  padding-top: var(--space-20);
  padding-bottom: var(--space-20);
}

@media (max-width: 768px) {
  .section {
    padding-top: var(--space-8);
    padding-bottom: var(--space-8);
  }
  
  .section-lg {
    padding-top: var(--space-12);
    padding-bottom: var(--space-12);
  }
}

/* ========== MAX WIDTH UTILITIES ========== */

.max-w-xs { max-width: var(--max-width-xs); }
.max-w-sm { max-width: var(--max-width-sm); }
.max-w-md { max-width: var(--max-width-md); }
.max-w-lg { max-width: var(--max-width-lg); }
.max-w-xl { max-width: var(--max-width-xl); }
.max-w-2xl { max-width: var(--max-width-2xl); }
.max-w-3xl { max-width: var(--max-width-3xl); }
.max-w-4xl { max-width: var(--max-width-4xl); }
.max-w-5xl { max-width: var(--max-width-5xl); }
.max-w-6xl { max-width: var(--max-width-6xl); }
.max-w-7xl { max-width: var(--max-width-7xl); }
.max-w-full { max-width: 100%; }

/* ========== WIDTH/HEIGHT ========== */

.w-full { width: 100%; }
.w-auto { width: auto; }
.w-fit { width: fit-content; }

.h-full { height: 100%; }
.h-auto { height: auto; }
.h-screen { height: 100vh; }

.min-h-screen { min-height: 100vh; }

/* ========== OBJECT FIT ========== */

.object-cover { object-fit: cover; }
.object-contain { object-fit: contain; }
.object-fill { object-fit: fill; }
.object-none { object-fit: none; }

/* ========== LEGACY BOOTSTRAP COMPATIBILITY (temporal) ========== */
/* Mantener mientras se migra, luego eliminar */

.row {
  display: flex;
  flex-wrap: wrap;
  margin-left: calc(var(--space-3) * -1);
  margin-right: calc(var(--space-3) * -1);
}

.row > * {
  padding-left: var(--space-3);
  padding-right: var(--space-3);
}

/* Columnas básicas (12-column grid) */
.col-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
.col-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
.col-9 { flex: 0 0 75%; max-width: 75%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }

/* Responsive columns (md = tablet+) */
@media (min-width: 768px) {
  .col-md-3 { flex: 0 0 25%; max-width: 25%; }
  .col-md-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
  .col-md-6 { flex: 0 0 50%; max-width: 50%; }
  .col-md-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
  .col-md-9 { flex: 0 0 75%; max-width: 75%; }
  .col-md-12 { flex: 0 0 100%; max-width: 100%; }
}

@media (max-width: 767px) {
  .col-1,
  .col-2,
  .col-3,
  .col-4,
  .col-6,
  .col-8,
  .col-9,
  .col-12 {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* ========== CLEARFIX (legacy) ========== */

.clearfix::after {
  content: "";
  display: table;
  clear: both;
}

