/* ─── IMPORTS ────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

/* ─── VARIABLES ──────────────────────────────────────────────────────────── */
:root {
  /* Colores base */
  --bg:           #FAFAFA;
  --surface:      #FFFFFF;
  --surface-2:    #F4F4F4;
  --border:       #E8E8E8;
  --border-focus: #2D6A4F;

  /* Texto */
  --text:         #111111;
  --text-2:       #555555;
  --text-3:       #999999;

  /* Primario — verde campo */
  --primary:      #2D6A4F;
  --primary-h:    #235540;
  --primary-soft: #EAF2EE;

  /* Semánticos */
  --success:      #16A34A;
  --success-soft: #DCFCE7;
  --danger:       #DC2626;
  --danger-soft:  #FEE2E2;
  --warning:      #D97706;
  --warning-soft: #FEF3C7;
  --info:         #2563EB;
  --info-soft:    #DBEAFE;

  /* Tipografía */
  --font:         'DM Sans', sans-serif;
  --font-mono:    'DM Mono', monospace;

  /* Escala tipográfica */
  --text-xs:      0.6875rem;   /* 11px */
  --text-sm:      0.8125rem;   /* 13px */
  --text-base:    0.9375rem;   /* 15px */
  --text-lg:      1.0625rem;   /* 17px */
  --text-xl:      1.25rem;     /* 20px */
  --text-2xl:     1.5rem;      /* 24px */
  --text-3xl:     1.875rem;    /* 30px */

  /* Espaciado */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Layout */
  --sidebar-w:    240px;
  --topbar-h:     56px;
  --radius:       8px;
  --radius-lg:    12px;
  --radius-full:  9999px;

  /* Sombras */
  --shadow-xs:    0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm:    0 1px 4px rgba(0,0,0,0.07);
  --shadow:       0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.12);

  /* Transiciones */
  --t-fast:  120ms ease;
  --t-base:  200ms ease;
  --t-slow:  320ms ease;
}

/* ─── RESET ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }
ul, ol { list-style: none; }

/* ─── LAYOUT ─────────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--t-slow);
}

.sidebar__brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-5);
  border-bottom: 1px solid var(--border);
}

.sidebar__brand-icon {
  width: 28px; height: 28px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar__brand-icon svg { color: #fff; width: 16px; height: 16px; }

.sidebar__brand-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.sidebar__section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: var(--space-4) var(--space-3) var(--space-2);
}

.sidebar__section-label:first-child { padding-top: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: var(--text-sm);
  font-weight: 450;
  transition: background var(--t-fast), color var(--t-fast);
  cursor: pointer;
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item:hover svg { opacity: 1; }

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 500;
}

.nav-item.active svg { opacity: 1; }

.sidebar__footer {
  padding: var(--space-4) var(--space-3);
  border-top: 1px solid var(--border);
}

.sidebar__user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--t-fast);
}

.sidebar__user:hover { background: var(--surface-2); }

.avatar {
  width: 28px; height: 28px;
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: var(--text-xs);
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

.sidebar__user-info { overflow: hidden; }

.sidebar__user-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__user-rol {
  font-size: var(--text-xs);
  color: var(--text-3);
}

/* MAIN AREA */
.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* TOPBAR */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-8);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar__title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* PAGE CONTENT */
.page-content {
  padding: var(--space-8);
  flex: 1;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-8);
  gap: var(--space-4);
}

.page-header__left { flex: 1; }

.page-header__title {
  font-size: var(--text-2xl);
  font-weight: 650;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.page-header__desc {
  font-size: var(--text-sm);
  color: var(--text-2);
  margin-top: var(--space-1);
}

/* ─── CARD ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.card--flush { padding: 0; overflow: hidden; }

/* STAT CARDS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.stat-card__icon {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
}

.stat-card__icon svg { width: 18px; height: 18px; }

.stat-card__value {
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1;
}

.stat-card__label {
  font-size: var(--text-xs);
  color: var(--text-3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── TABLA ──────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: var(--space-3) var(--space-5);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

tbody td {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  color: var(--text);
  vertical-align: middle;
}

.table-empty {
  text-align: center;
  padding: var(--space-12) var(--space-8);
  color: var(--text-3);
  font-size: var(--text-sm);
}

.table-empty svg {
  width: 40px; height: 40px;
  margin: 0 auto var(--space-3);
  opacity: 0.3;
}

/* ─── BOTONES ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--t-fast);
  white-space: nowrap;
  text-decoration: none;
}

.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn--primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn--primary:hover { background: var(--primary-h); border-color: var(--primary-h); }

.btn--ghost {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border);
}
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }

.btn--danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn--danger:hover { background: var(--danger-soft); }

.btn--sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
}
.btn--sm svg { width: 13px; height: 13px; }

.btn--icon {
  padding: var(--space-2);
  border-radius: var(--radius);
}

/* ─── FORMULARIOS ────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
}

.form-grid--1 { grid-template-columns: 1fr; }
.form-grid--3 { grid-template-columns: 1fr 1fr 1fr; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-group--full { grid-column: 1 / -1; }

label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
}

.label-hint {
  font-size: var(--text-xs);
  color: var(--text-3);
  font-weight: 400;
}

.input, .select, .textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  width: 100%;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.1);
}

.input::placeholder, .textarea::placeholder { color: var(--text-3); }

.textarea { resize: vertical; min-height: 96px; }

.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }

.form-error {
  font-size: var(--text-xs);
  color: var(--danger);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}

/* ─── BADGES ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.badge--admin      { background: #EDE9FE; color: #6D28D9; }
.badge--entrenador { background: var(--info-soft); color: var(--info); }
.badge--jugador    { background: var(--primary-soft); color: var(--primary); }
.badge--success    { background: var(--success-soft); color: var(--success); }
.badge--danger     { background: var(--danger-soft); color: var(--danger); }
.badge--muted      { background: var(--surface-2); color: var(--text-3); }
.badge--warning    { background: var(--warning-soft); color: var(--warning); }

/* ─── TOAST ──────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--text);
  color: #fff;
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: 450;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in var(--t-base) ease forwards;
  max-width: 340px;
}

.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast--success { background: var(--success); }
.toast--danger  { background: var(--danger); }
.toast--warning { background: var(--warning); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(4px); }
}

.toast.removing { animation: toast-out 200ms ease forwards; }

/* ─── MODAL ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fade-in 150ms ease;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  animation: modal-in 200ms ease;
}

.modal__header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.modal__title { font-size: var(--text-base); font-weight: 600; }

.modal__body { padding: var(--space-5) var(--space-6); font-size: var(--text-sm); color: var(--text-2); line-height: 1.6; }

.modal__footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

@keyframes fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: scale(0.96) translateY(-8px); } to { opacity: 1; transform: none; } }

/* ─── BREADCRUMB ─────────────────────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-3);
  margin-bottom: var(--space-6);
}

.breadcrumb a { color: var(--text-3); transition: color var(--t-fast); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb__sep { color: var(--border); }
.breadcrumb__current { color: var(--text); font-weight: 500; }

/* ─── SEARCH BAR ─────────────────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  max-width: 280px;
}

.search-wrap svg {
  position: absolute;
  left: var(--space-3);
  top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--text-3);
  pointer-events: none;
}

.search-wrap .input { padding-left: 34px; }

/* ─── DIVIDER ────────────────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-6) 0;
}

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .main-area {
    margin-left: 0;
  }

  .page-content { padding: var(--space-5); }
  .topbar { padding: 0 var(--space-5); }

  .form-grid { grid-template-columns: 1fr; }
  .form-grid--3 { grid-template-columns: 1fr; }

  .page-header { flex-direction: column; }

  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ─── UTILIDADES ─────────────────────────────────────────────────────────── */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2        { gap: var(--space-2); }
.gap-3        { gap: var(--space-3); }
.gap-4        { gap: var(--space-4); }
.text-sm      { font-size: var(--text-sm); }
.text-xs      { font-size: var(--text-xs); }
.text-muted   { color: var(--text-3); }
.font-medium  { font-weight: 500; }
.font-semibold{ font-weight: 600; }
.mt-4         { margin-top: var(--space-4); }
.mt-6         { margin-top: var(--space-6); }
.mb-4         { margin-bottom: var(--space-4); }
.mb-6         { margin-bottom: var(--space-6); }
.w-full       { width: 100%; }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
