/* ============================================================
   assets/css/main.css — Sistema de diseño MOBILE-FIRST
   Liga de Basquetbol
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;600;700;900&family=Inter:wght@400;500;600&display=swap');

/* ---- Variables ---- */
:root {
  --orange:       #F57C00;
  --orange-dark:  #E65100;
  --orange-light: #FFF3E0;
  --navy:         #0D1B2A;
  --navy-mid:     #1A2E42;
  --navy-light:   #243B55;
  --white:        #FFFFFF;
  --gray-50:      #F8F9FA;
  --gray-100:     #F1F3F5;
  --gray-200:     #E9ECEF;
  --gray-300:     #DEE2E6;
  --gray-400:     #CED4DA;
  --gray-500:     #ADB5BD;
  --gray-600:     #6C757D;
  --gray-700:     #495057;
  --gray-800:     #343A40;
  --gray-900:     #212529;

  --success:    #2E7D32;
  --success-bg: #E8F5E9;
  --danger:     #C62828;
  --danger-bg:  #FFEBEE;
  --warning:    #F57F17;
  --warning-bg: #FFF8E1;
  --info:       #1565C0;
  --info-bg:    #E3F2FD;

  --font-display: 'Barlow Condensed', sans-serif;
  --font-body:    'Inter', sans-serif;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12);
  --shadow-orange: 0 4px 16px rgba(245,124,0,.30);

  /* Tamaños touch-friendly */
  --touch-min: 44px;

  /* Header móvil */
  --header-h: 56px;

  /* Bottom nav móvil */
  --bottom-nav-h: 64px;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--font-body);
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.6;
  /* Espacio para header fijo + bottom nav en móvil */
  padding-top: var(--header-h);
  padding-bottom: var(--bottom-nav-h);
}
img { max-width: 100%; display: block; }
a   { color: var(--orange); text-decoration: none; }
a:hover { color: var(--orange-dark); }
button, input, select, textarea { font-family: inherit; }

/* ============================================================
   LAYOUT — MÓVIL
   ============================================================ */

.container {
  width: 100%;
  padding: 0 16px;
}

.page-content {
  padding: 16px;
  min-height: calc(100vh - var(--header-h) - var(--bottom-nav-h));
}

/* ============================================================
   HEADER MÓVIL
   ============================================================ */

.top-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}

.top-header .logo {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 20px;
  color: var(--white);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.top-header .logo span { color: var(--orange); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hamburger {
  width: var(--touch-min);
  height: var(--touch-min);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  padding: 8px;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--white);
  border-radius: 2px;
  transition: all .25s ease;
}
.hamburger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ============================================================
   DRAWER (menú lateral deslizable en móvil)
   ============================================================ */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0; left: 0;
  width: 80%;
  max-width: 280px;
  height: 100%;
  background: var(--navy);
  z-index: 201;
  transform: translateX(-100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.drawer.open { transform: translateX(0); }

.drawer-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.drawer-header .logo {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 22px;
  color: var(--white);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.drawer-header .logo span { color: var(--orange); }

.drawer-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}
.drawer-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.drawer-user-info p  { font-size: 13px; font-weight: 500; color: var(--white); }
.drawer-user-info span { font-size: 11px; color: var(--gray-500); text-transform: uppercase; letter-spacing: .06em; }

.drawer-nav { flex: 1; padding: 12px 0; }

.drawer-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--gray-600);
  padding: 12px 20px 4px;
}

.drawer-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--gray-300);
  font-size: 15px;
  font-weight: 500;
  transition: all .15s;
  min-height: var(--touch-min);
  border-left: 3px solid transparent;
}
.drawer-nav a:hover,
.drawer-nav a.active {
  background: rgba(255,255,255,.06);
  color: var(--white);
  border-left-color: var(--orange);
}
.drawer-nav a .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 18px;
  flex-shrink: 0;
}

.drawer-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.drawer-footer a {
  display: flex; align-items: center; gap: 10px;
  color: var(--gray-500);
  font-size: 14px;
  padding: 8px 0;
  min-height: var(--touch-min);
}
.drawer-footer a:hover { color: var(--danger); }

/* ============================================================
   BOTTOM NAV (para páginas de usuario/equipo en móvil)
   ============================================================ */

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: stretch;
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
}

.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--gray-500);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 6px 4px;
  transition: color .15s;
  min-width: 0;
}
.bottom-nav a .bnav-icon { font-size: 22px; line-height: 1; }
.bottom-nav a.active { color: var(--orange); }
.bottom-nav a.active .bnav-icon { transform: scale(1.1); }

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}
.card-body { padding: 16px; }
.card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.card-header h2, .card-header h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
}
.card-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
}

/* Stat cards — fila de 2 en móvil */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-500);
  margin-bottom: 4px;
}
.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
}
.stat-card .stat-sub {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
}
.stat-card.accent { background: var(--orange); border-color: var(--orange-dark); }
.stat-card.accent .stat-label,
.stat-card.accent .stat-sub  { color: rgba(255,255,255,.75); }
.stat-card.accent .stat-value { color: #fff; }

/* ============================================================
   FORMULARIOS MOBILE-FIRST
   ============================================================ */

.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  height: var(--touch-min);
  padding: 0 14px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 16px; /* evita zoom en iOS */
  color: var(--gray-900);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(245,124,0,.15);
}
.form-control::placeholder { color: var(--gray-400); }
textarea.form-control {
  height: auto;
  min-height: 100px;
  padding: 12px 14px;
  resize: vertical;
}
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236C757D' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.form-hint  { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

/* Upload de imagen táctil */
.img-upload-area {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-md);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: var(--gray-50);
}
.img-upload-area:hover,
.img-upload-area.dragover { border-color: var(--orange); background: var(--orange-light); }
.img-upload-area .upload-icon { font-size: 36px; margin-bottom: 8px; }
.img-upload-area p { font-size: 14px; color: var(--gray-600); }
.img-preview {
  width: 80px; height: 80px;
  border-radius: var(--radius-md);
  object-fit: cover;
  margin: 8px auto 0;
}

/* ============================================================
   BOTONES
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--touch-min);
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .15s ease;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn-block { width: 100%; }
.btn-primary  { background: var(--orange); color: #fff; }
.btn-primary:hover,
.btn-primary:active { background: var(--orange-dark); box-shadow: var(--shadow-orange); color: #fff; }
.btn-secondary { background: var(--gray-100); color: var(--gray-800); border: 1px solid var(--gray-300); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #FFCDD2; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-navy     { background: var(--navy); color: #fff; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ============================================================
   TABLAS — scroll horizontal en móvil
   ============================================================ */

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 480px; /* fuerza scroll en pantallas < 480px */
}
thead {
  background: var(--navy);
  color: var(--white);
}
thead th {
  padding: 12px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  text-align: left;
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--gray-100); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }
tbody td { padding: 12px 14px; vertical-align: middle; }
.td-center { text-align: center; }
.td-num { font-family: var(--font-display); font-size: 16px; font-weight: 700; }

/* Tabla de posiciones con highlight */
.standings-table tbody tr:nth-child(1) td:first-child { color: var(--orange); font-weight: 700; }

/* ============================================================
   BADGES Y PILLS
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info    { background: var(--info-bg);    color: var(--info);    }
.badge-gray    { background: var(--gray-100);   color: var(--gray-700); }
.badge-orange  { background: var(--orange-light); color: var(--orange-dark); }

/* Estado de partido */
.estado-programado { background: var(--info-bg);    color: var(--info);    }
.estado-en_curso   { background: var(--warning-bg); color: var(--warning); font-weight: 700; }
.estado-finalizado { background: var(--success-bg); color: var(--success); }
.estado-suspendido { background: var(--gray-100);   color: var(--gray-600); }

/* ============================================================
   LOGO DE EQUIPO
   ============================================================ */

.team-logo {
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: var(--gray-100);
}
.team-logo-sm { width: 32px; height: 32px; }
.team-logo-md { width: 56px; height: 56px; }
.team-logo-lg { width: 90px; height: 90px; }
.team-logo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 900;
  color: var(--white);
  text-transform: uppercase;
}

/* ============================================================
   PARTIDO CARD (para el rol de juegos)
   ============================================================ */

.partido-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}
.partido-card .match-teams {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.partido-card .team-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.partido-card .team-name {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: .02em;
  line-height: 1.2;
}
.partido-card .score-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  min-width: 70px;
}
.partido-card .score {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 900;
  color: var(--navy);
  letter-spacing: .04em;
  line-height: 1;
}
.partido-card .vs {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-400);
}
.partido-card .match-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--gray-100);
  font-size: 12px;
  color: var(--gray-500);
}

/* ============================================================
   JUGADOR ROW (listas de roster)
   ============================================================ */

.jugador-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
}
.jugador-row:last-child { border-bottom: none; }
.jugador-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--gray-200);
  flex-shrink: 0;
}
.jugador-avatar-placeholder {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--navy);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--white);
  flex-shrink: 0;
}
.jugador-num {
  width: 28px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 900;
  color: var(--orange);
  text-align: center;
  flex-shrink: 0;
}
.jugador-info { flex: 1; min-width: 0; }
.jugador-info .name {
  font-weight: 600;
  font-size: 14px;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.jugador-info .pos {
  font-size: 12px;
  color: var(--gray-500);
}

/* ============================================================
   UTILS
   ============================================================ */

.section-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 900;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-bottom: 14px;
}
.text-orange { color: var(--orange) !important; }
.text-navy   { color: var(--navy) !important; }
.text-muted  { color: var(--gray-500) !important; }
.text-center { text-align: center; }
.fw-bold     { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.d-flex      { display: flex; }
.align-center{ align-items: center; }
.justify-between { justify-content: space-between; }
.w-100       { width: 100%; }
.separator   { height: 1px; background: var(--gray-200); margin: 16px 0; }

/* Alertas */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  border-left: 4px solid;
}
.alert-success { background: var(--success-bg); color: var(--success); border-color: var(--success); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning); }
.alert-info    { background: var(--info-bg);    color: var(--info);    border-color: var(--info); }

/* Spinner de carga */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 24px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 24px;
  color: var(--gray-500);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: .5; }
.empty-state p { font-size: 14px; }

/* Toast / notificación */
.toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--gray-900);
  color: var(--white);
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: all .3s ease;
  white-space: nowrap;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }

/* ============================================================
   DESKTOP — a partir de 768px
   ============================================================ */

@media (min-width: 768px) {
  :root {
    --sidebar-w: 240px;
    --header-h:  64px;
    --bottom-nav-h: 0px;
  }

  body {
    padding-top: 0;
    padding-bottom: 0;
  }

  /* Layout con sidebar */
  .layout-admin {
    display: flex;
    min-height: 100vh;
  }

  .sidebar {
    width: var(--sidebar-w);
    background: var(--navy);
    min-height: 100vh;
    position: sticky;
    top: 0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }

  .main-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
  }

  .main-topbar {
    height: var(--header-h);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .main-content { padding: 24px; }

  /* Ocultar elementos móvil-only */
  .top-header  { display: none; }
  .bottom-nav  { display: none; }
  .drawer-overlay, .drawer { display: none; }

  /* Grids más amplios */
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

  table { min-width: unset; }
}

@media (min-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}
