@import './components/custom-select-grados.css';

/* ==========================================================================
   ESTILOS GENERALES Y DISEÑO DE TARJETAS DE ALUMNOS (TKD PRO MANAGER)
   ========================================================================== */

:root {
  --bg-primary: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-card: #FFFFFF;
  --accent-blue: #2563EB;
  --accent-hover: #1D4ED8;
  --text-main: #0F172A;
  --text-muted: #64748B;
  --border-color: #E2E8F0;
  --danger-color: #EF4444;
  --danger-bg: #FEE2E2;
  --danger-text: #DC2626;
  --badge-bg: #EFF6FF;
  --badge-text: #2563EB;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-main: 0 4px 12px -2px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 10px 24px -4px rgba(37, 99, 235, 0.16);
  --font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.4;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header & Navbar */
.navbar {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-main);
}

.navbar-brand img {
  height: 34px;
  width: auto;
  object-fit: contain;
}

.navbar-brand span {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.navbar-brand span highlight {
  color: var(--accent-blue);
}

/* Layout Container */
.app-container {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem;
}

/* Page Header Title */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.page-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-title img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.page-title h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Pestañas Maestras del Módulo de Alumnos (Estilo Inspiración) */
.alumnos-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid #E2E8F0;
  margin-bottom: 1.25rem;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.75rem 1.25rem;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 0.95rem;
  font-weight: 400;
  color: #64748B;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: -2px;
  font-family: inherit;
}

.tab-btn:hover {
  color: #1D4ED8;
  background-color: #f8fcf8;
  border-radius: 8px 8px 0 0;
  border-bottom: 3px solid transparent;
}

.tab-btn.active {
  color: #1D4ED8;
  border-bottom-color: #1D4ED8;
  font-weight: 600;
}

.tab-icon-img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex-shrink: 0;
}

.tab-badge {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 12px;
  background-color: #E2E8F0;
  color: #475569;
}

.tab-btn.active .tab-badge {
  background-color: #DBEAFE;
  color: #1D4ED8;
}

/* Toolbar de Filtros y Acciones Alineado y Compacto */
.toolbar-wrapper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 1.25rem;
  background-color: #FFFFFF;
  padding: 0.55rem 0.85rem;
  border-radius: 12px;
  border: 1px solid #E2E8F0;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
}

.filter-controls-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}

.search-box-compact {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 170px;
  max-width: 210px;
  flex: 1;
}

.search-icon-img {
  position: absolute;
  left: 8px;
  width: 15px;
  height: 15px;
  object-fit: contain;
  pointer-events: none;
}

.search-box-compact input {
  width: 100%;
  padding: 0.35rem 0.65rem 0.35rem 1.85rem;
  font-size: 0.8rem;
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  outline: none;
  font-family: inherit;
  height: 32px;
  background: #FFFFFF;
  transition: border-color 0.2s ease;
}

.search-box-compact input:focus {
  border-color: #2563EB;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.custom-select-wrapper-compact {
  position: relative;
  min-width: 135px;
  max-width: 165px;
}

.custom-select-trigger-compact {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  background: #FFFFFF;
  cursor: pointer;
  height: 32px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.form-control-compact {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  background-color: #FFFFFF;
  color: #334155;
  outline: none;
  cursor: pointer;
  font-family: inherit;
  height: 32px;
  min-width: 135px;
  max-width: 175px;
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  height: 32px;
  border-radius: 8px;
}

.search-box input:focus {
  border-color: #2563EB;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filter-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.form-control-sm {
  padding: 0.5rem 0.75rem;
  font-size: 0.84rem;
  font-weight: 600;
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  background-color: #FFFFFF;
  color: #334155;
  outline: none;
  cursor: pointer;
  font-family: inherit;
}

/* Tag Filters por Nivel */
.tag-filters-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 1.25rem;
}

.tag-filter {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  user-select: none;
}

.tag-filter:hover {
  background: #F1F5F9;
  color: var(--text-main);
  border-color: #CBD5E1;
}

.tag-filter.active {
  background: var(--accent-blue);
  color: #FFFFFF;
  border-color: var(--accent-blue);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.tag-filter-count {
  background: rgba(0, 0, 0, 0.08);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 800;
}

.tag-filter.active .tag-filter-count {
  background: rgba(255, 255, 255, 0.25);
  color: #FFFFFF;
}

/* Filter Bar */
.filter-bar,
.filters-section {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.search-box {
  position: relative;
  max-width: 280px;
  width: 100%;
}

.search-box input {
  width: 100%;
  height: 36px;
  padding: 0.4rem 0.8rem 0.4rem 2.2rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-box img.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  object-fit: contain;
  pointer-events: none;
}

.filter-select {
  height: 36px;
  padding: 0.4rem 0.75rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 600;
  min-width: 160px;
  transition: all 0.15s ease;
}

.filter-select:hover {
  border-color: var(--accent-blue);
}

/* Fin de reglas de filtros generales (El combo de grados se rige exclusivamente por general.css) */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0.6rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  min-height: 38px;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--accent-blue);
  color: #FFFFFF;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
}

.btn-secondary {
  background-color: var(--bg-primary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--border-color);
}

.btn-danger {
  background-color: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background-color: #FCA5A5;
}

/* Botones con SOLO ÍCONO */
.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  padding: 0;
}

.btn-icon:hover {
  transform: translateY(-2px);
}

.btn-icon-eye {
  background: #EFF6FF;
  color: #2563EB;
  border: 1px solid rgba(37, 99, 235, 0.25);
}

.btn-icon-eye:hover {
  background: #DBEAFE;
}

.btn-icon-edit {
  background: #F1F5F9;
  color: #0F172A;
  border: 1px solid #CBD5E1;
}

.btn-icon-edit:hover {
  background: #E2E8F0;
}

.btn-icon-delete {
  background: #FEE2E2;
  color: #DC2626;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.btn-icon-delete:hover {
  background: #FCA5A5;
}

/* Grid de Tarjetas de Alumnos (Medida Amplia Fija de 170px sin Deformación al Replegar Menú) */
.alumnos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 170px);
  gap: 1rem;
  width: 100%;
  justify-content: flex-start;
}

.alumno-card {
  width: 170px;
  background-color: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  user-select: none;
}

.alumno-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-blue);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}

/* Foto Protagonista (150px de alto) */
.alumno-card-photo-wrapper {
  position: relative;
  width: 100%;
  height: 150px;
  background-color: #E2E8F0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.alumno-card-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
}

.alumno-card-photo-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #F1F5F9 0%, #E2E8F0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.alumno-card-photo-placeholder svg {
  width: 42px;
  height: 42px;
  color: #94A3B8;
  opacity: 0.85;
}

/* Badge de Graduación arriba a la DERECHA */
.alumno-belt-badge-overlay {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 8px;
  min-width: 24px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  font-size: 0.7rem;
  font-weight: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  letter-spacing: -0.01em;
  z-index: 4;
}

/* Insignia / Parche de Instructor Oficial (arriba a la IZQUIERDA) */
.instructor-patch-overlay {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
  z-index: 5;
}

/* Franja Divisora Horizontal del Cinturón 70%/30% */
.alumno-belt-stripe {
  height: 4px;
  width: 100%;
  display: block;
}

/* Overlay Gradiente con Título Honorífico en la Foto (Punta Negra en adelante) */
.alumno-name-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 4px 0px 4px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0) 0%, rgba(15, 23, 42, 0.75) 55%, rgba(15, 23, 42, 0.95) 100%);
  color: #FFFFFF;
  text-align: center;
  z-index: 3;
}

.alumno-titulo-honorifico {
  font-size: 0.68rem;
  font-weight: 400;
  color: #F8FAFC;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Cuerpo de la Tarjeta (Nombre, Apellido e Instructor) */
.alumno-card-info-clean {
  padding: 0.55rem 0.65rem 0.45rem 0.65rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  background-color: #FFFFFF;
}

.alumno-card-name-bold {
  font-size: 0.82rem;
  font-weight: 900;
  color: #0F172A;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.alumno-card-surname-light {
  font-size: 0.7rem;
  font-weight: 700;
  color: #64748B;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  margin-top: 1px;
}

.alumno-card-instructor-subtle {
  font-size: 0.65rem;
  font-weight: 600;
  color: #64748B;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

/* Contenedor Colapsado de Acciones al hacer Click */
.alumno-card-actions-wrapper {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
}

.alumno-card.expanded .alumno-card-actions-wrapper {
  max-height: 45px;
  opacity: 1;
  padding: 0.35rem 0.5rem;
  border-top: 1px dashed var(--border-color);
  background-color: #F8FAFC;
}

/* Fila de Acciones ALINEADA A LA DERECHA (Solo Íconos Compactos) */
.alumno-card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  width: 100%;
}

.btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 0.8rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon-filter:hover {
  background: #F0FDF4;
  border-color: #166534;
  color: #166534;
}

.btn-icon-eye:hover {
  background: #EFF6FF;
  border-color: #2563EB;
  color: #2563EB;
}

.btn-icon-edit:hover {
  background: #FEF3C7;
  border-color: #D97706;
  color: #D97706;
}

.btn-icon-delete:hover {
  background: #FEE2E2;
  border-color: #DC2626;
  color: #DC2626;
}

.btn-icon-eye:hover {
  background: #EFF6FF;
  border-color: #2563EB;
  color: #2563EB;
}

.btn-icon-edit:hover {
  background: #FEF3C7;
  border-color: #D97706;
  color: #D97706;
}

.btn-icon-delete:hover {
  background: #FEE2E2;
  border-color: #DC2626;
  color: #DC2626;
}

/* Form Groups & Inputs */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: 600;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-blue);
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background-color: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  padding: 0;
  box-shadow: 0 20px 35px -10px rgba(0, 0, 0, 0.2);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 0.85rem 1.25rem;
  background-color: #E2E8F0;
  border-bottom: 1px solid #CBD5E1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 10;
  margin-bottom: 0;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #0F172A;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.35rem;
  line-height: 1;
  color: #64748B;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.modal-close:hover {
  color: #EF4444;
  background-color: #FEE2E2;
}

#formAlumno,
.modal-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  margin: 0;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  background-color: #FFFFFF;
}

.modal-footer {
  padding: 0.85rem 1.25rem;
  background-color: #E2E8F0;
  border-top: 1px solid #CBD5E1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-shrink: 0;
  z-index: 10;
}

/* Inputs en el Formulario del Modal */
.modal-body .form-group {
  margin-bottom: 1.1rem;
}

.modal-body .form-group label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: #475569;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Inputs de Texto estilo Underline (Línea Inferior) */
.modal-body input[type="text"].form-control,
.modal-body input[type="email"].form-control {
  width: 100%;
  padding: 0.35rem 0.25rem;
  background-color: transparent;
  border: none;
  border-bottom: 1.5px solid #64748B;
  border-radius: 0;
  color: #0F172A;
  font-size: 0.88rem;
  font-weight: 600;
  transition: border-color 0.2s ease;
}

.modal-body input[type="text"].form-control:focus,
.modal-body input[type="email"].form-control:focus {
  outline: none;
  border-bottom-color: #2563EB;
}

/* Selects estilo Box Redondeado */
.modal-body select.form-control,
.modal-body .custom-select-trigger {
  width: 100%;
  padding: 0.55rem 0.85rem;
  background-color: #FFFFFF;
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  color: #0F172A;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.15s ease;
}

.modal-body select.form-control:focus,
.modal-body .custom-select-trigger:hover {
  border-color: #2563EB;
}

/* Botones en Footer Modal */
.modal-footer .btn-secondary {
  background-color: #FFFFFF;
  color: #0F172A;
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  font-weight: 700;
  padding: 0.5rem 1.25rem;
}

.modal-footer .btn-secondary:hover {
  background-color: #F1F5F9;
}

.modal-footer .btn-primary {
  background-color: #1D4ED8;
  color: #FFFFFF;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  padding: 0.5rem 1.25rem;
}

.modal-footer .btn-primary:hover {
  background-color: #1E40AF;
}