/* --- VARIABLES GLOBALES (Design Tokens) --- */
:root {
  --primary-dark-blue: #004477;
  --primary-dark-green: #52894d;
  --secondary-light-blue: #2c89c5;
  --secondary-light-green: #92bc5f;
  --terciary-orange: #efa441;
  --text-dark: #1f2937;
  --text-medium: #374151;
  --bg-main: #f3f4f6;
  --white: #ffffff;
  --border: #e5e7eb;
  --danger: #dc2626;

  --ev-red:    #BA2422;
  --ev-orange: #EFA441;
  --ev-blue:   #004477;
  --ev-green:  #52894D;

  --success: #10b981;
  --warning: #f59e0b;

  --gradient-mks: linear-gradient(135deg, var(--primary-dark-blue), var(--secondary-light-blue));
  --gradient-header: linear-gradient(to right, var(--primary-dark-green), var(--primary-dark-blue));

  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.4);

  --container-max-width: 1440px;
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;

  --radius-lg: 1rem;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --text-light: #6b7280;
  --radius-md: 0.75rem;
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 0.5rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #ffffff;
  font-size: 0.95rem;
  text-decoration: none;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-mks-primary {
  background-color: var(--primary-dark-green);
  color: var(--white);
  box-shadow: 0 4px 12px rgba(82, 137, 77, 0.35);
}
.btn-mks-primary:hover { background-color: var(--primary-dark-blue); box-shadow: 0 6px 16px rgba(0,68,119,0.4); transform: translateY(-2px); }

.btn-mks-secondary {
  background-color: #52894d;
  box-shadow: 0 4px 14px 0 rgba(82, 137, 77, 0.39);
}
.btn-mks-secondary:hover { background-color: #447240; box-shadow: 0 6px 20px 0 rgba(82,137,77,0.5); transform: translateY(-2px); }

.btn-mks-terciary {
  background-color: var(--terciary-orange);
  color: var(--white);
  box-shadow: 0 4px 12px rgba(239, 164, 65, 0.35);
}
.btn-mks-terciary:hover { filter: brightness(0.9); box-shadow: 0 6px 16px rgba(239,164,65,0.45); transform: translateY(-2px); }

.btn-outline { border: 1px solid var(--border); background: transparent; color: var(--text-medium); }

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; gap: 0.3rem; }
.btn-primary { background-color: var(--primary-dark-blue); color: var(--white); box-shadow: 0 4px 12px rgba(0,68,119,0.3); }
.btn-primary:hover { filter: brightness(0.9); box-shadow: 0 6px 16px rgba(0,68,119,0.4); }
.btn-danger { background-color: var(--danger); color: var(--white); box-shadow: 0 4px 12px rgba(220,38,38,0.25); }
.btn-danger:hover { filter: brightness(0.9); box-shadow: 0 6px 16px rgba(220,38,38,0.4); }

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-medium);
  line-height: 1.5;
  padding: 1rem;
}

.hidden { display: none !important; }

.card {
  background: var(--white);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

.card-icon-container {
  width: 5rem; height: 5rem; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1rem; color: #ffffff; transition: transform 0.3s ease;
}
.card:hover .card-icon-container { transform: scale(1.1) rotate(5deg); }
.card-icon-container svg { width: 2rem !important; height: 2rem !important; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: none; align-items: center; justify-content: center;
  z-index: 2000; backdrop-filter: blur(4px);
}
.modal-content {
  background: white; padding: 2rem; border-radius: var(--radius-md);
  text-align: center; max-width: 400px; width: 90%; box-shadow: var(--shadow-lg);
}

.modern-loader { display: flex; align-items: center; justify-content: center; gap: 0.3rem; }
.modern-loader span {
  width: 10px; height: 10px; background-color: var(--primary-dark-blue);
  border-radius: 50%; animation: pulse-dots 1.4s infinite ease-in-out both;
}
.modern-loader span:nth-child(1) { animation-delay: -0.32s; }
.modern-loader span:nth-child(2) { animation-delay: -0.16s; }
@keyframes pulse-dots {
  0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
  40%           { transform: scale(1); opacity: 1; }
}

.icon-action-btn {
  background: transparent; border: none; padding: 0; cursor: pointer;
  color: var(--secondary-light-blue); transition: color 0.3s ease, transform 0.2s ease;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-action-btn:hover { color: var(--primary-dark-blue); transform: scale(1.15); }
.icon-action-btn svg { width: 1.5rem; height: 1.5rem; }

.activity-header {
  background: linear-gradient(135deg, var(--primary-dark-blue), var(--secondary-light-blue));
  padding: 1.5rem; color: white; border-radius: var(--radius-md);
  margin-bottom: 2rem; display: flex; justify-content: space-between;
  align-items: center; flex-wrap: wrap; gap: 1rem;
}
.activity-header h1 { font-size: 1.8rem; font-weight: 800; margin: 0; color: white; }
.activity-header p { margin: 0.2rem 0 0; opacity: 0.9; font-size: 0.9rem; }
.activity-header-actions { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }

/* MKS Modal */
.mks-modal-overlay {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(17,24,39,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; opacity: 0; visibility: hidden; transition: all 0.3s ease;
}
.mks-modal-overlay.active { opacity: 1; visibility: visible; }
.mks-modal-box {
  background: var(--white); width: 90%; max-width: 400px;
  border-radius: 1rem; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
  transform: scale(0.9); transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
  overflow: hidden; text-align: center;
}
.mks-modal-overlay.active .mks-modal-box { transform: scale(1); }
.mks-modal-header { padding: 1.5rem 1.5rem 0.5rem 1.5rem; }
.mks-modal-icon {
  width: 4rem; height: 4rem; margin: 0 auto 1rem auto;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.mks-modal-icon svg { width: 2rem; height: 2rem; }
.mks-modal-success .mks-modal-icon { background: #dcfce7; color: var(--primary-dark-green); }
.mks-modal-error   .mks-modal-icon { background: #fee2e2; color: #ef4444; }
.mks-modal-warning .mks-modal-icon { background: #fef3c7; color: var(--terciary-orange); }
.mks-modal-info    .mks-modal-icon { background: #e0f2fe; color: var(--primary-dark-blue); }
.mks-modal-title { font-size: 1.25rem; font-weight: 800; color: var(--primary-dark-blue); margin: 0; }
.mks-modal-body { padding: 0.5rem 1.5rem 1.5rem 1.5rem; color: #4b5563; font-size: 0.95rem; line-height: 1.5; }
.mks-modal-footer { padding: 1rem 1.5rem; background: #f9fafb; border-top: 1px solid #e5e7eb; display: flex; gap: 0.75rem; }
.mks-modal-btn { flex: 1; padding: 0.75rem; border-radius: 0.5rem; font-weight: 700; border: none; cursor: pointer; transition: 0.2s; color: white; background: var(--primary-dark-blue); }
.mks-modal-btn:hover { filter: brightness(0.88); }
.mks-modal-success .mks-modal-btn:not(.mks-modal-btn-cancel) { background: var(--primary-dark-green); }
.mks-modal-error   .mks-modal-btn:not(.mks-modal-btn-cancel) { background: #ef4444; }
.mks-modal-warning .mks-modal-btn:not(.mks-modal-btn-cancel) { background: var(--terciary-orange); }
.mks-modal-info    .mks-modal-btn:not(.mks-modal-btn-cancel) { background: var(--secondary-light-blue); }
.mks-modal-btn.mks-modal-btn-cancel { background: #e5e7eb; color: #374151; }
.mks-modal-btn.mks-modal-btn-cancel:hover { background: #d1d5db; filter: none; }

.app-wrapper { max-width: 72rem; margin: 0 auto; }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 768px) { .form-grid { grid-template-columns: repeat(2, 1fr); } }

.modern-form { display: flex; flex-direction: column; }
.form-row {
  display: grid; grid-template-columns: 250px 1fr;
  align-items: center; gap: 1.5rem; padding: 1rem 0; border-bottom: 1px solid var(--border);
}
@media (max-width: 768px) { .form-row { grid-template-columns: 1fr; gap: 0.5rem; } }

.modern-label { font-weight: 600; color: var(--primary-dark-blue); font-size: 0.95rem; }
.modern-input {
  width: 100%; padding: 0.85rem 1rem; border: 1px solid var(--border);
  border-radius: 0.5rem; background-color: var(--bg-main); transition: var(--transition);
}
.modern-input:focus {
  outline: none; border-color: var(--primary-dark-green);
  box-shadow: 0 0 0 3px rgba(82,137,77,0.15); background-color: white;
}
input.modern-input:read-only,
textarea.modern-input:read-only { background-color: #f3f4f6; cursor: not-allowed; opacity: 0.7; }

.data-table { width: 100%; border-collapse: collapse; text-align: left; background: white; border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-md); }
.data-table th { background: var(--primary-dark-blue); color: white; padding: 1rem; font-size: 0.85rem; }
.data-table td { padding: 1rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }

.badge { padding: 0.25rem 0.75rem; border-radius: 1rem; color: white; font-size: 0.75rem; font-weight: bold; }

.app-container {
  width: 100%; max-width: var(--container-max-width);
  margin-left: auto; margin-right: auto;
  padding-left: var(--spacing-md); padding-right: var(--spacing-md);
}
.flex-center { display: flex; align-items: center; justify-content: center; }
.text-center { text-align: center; }
.w-full { width: 100%; }

.grid-responsive {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 300px));
  justify-content: center; gap: var(--spacing-md); width: 100%;
}

.theme-blue { background: linear-gradient(to right, var(--primary-dark-blue), var(--secondary-light-blue)); }
.text-theme-blue { color: var(--primary-dark-blue); }
.theme-green { background: linear-gradient(to right, var(--primary-dark-green), var(--secondary-light-green)); }
.text-theme-green { color: var(--primary-dark-green); }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in-element { animation: fadeIn 0.4s ease-in-out forwards; }

.icon {
  width: 1.5rem; height: 1.5rem; fill: none; stroke: currentColor;
  display: inline-block; vertical-align: middle; flex-shrink: 0;
}
.icon--sm { width: 1rem; height: 1rem; }
.icon--lg { width: 2rem; height: 2rem; }
.icon--xl { width: 3rem; height: 3rem; }
.icon--primary { color: var(--primary-dark-blue); }
.icon--success { color: var(--primary-dark-green); }
.icon--danger  { color: var(--danger); }

/* ── Tarjetas de portal (módulos y actividades) ─────────────────────────── */
.portal-card {
  background: white; border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); cursor: pointer; transition: var(--transition);
  overflow: hidden; flex: 1 1 calc(50% - 1.5rem); max-width: 290px; min-width: 220px;
  display: flex; flex-direction: column; align-items: center;
  padding: 1.5rem 1rem 1.25rem; text-align: center; min-height: 220px;
}
.portal-card:hover { transform: translateY(-4px); box-shadow: 0 20px 40px -10px rgba(0,68,119,0.15); }

/* Tarjeta de módulo (nivel 1) — fondo blanco, logo en imagen */
.module-card .module-logo { width: 60%; height: auto; object-fit: contain; margin-bottom: 1rem; }
.module-card h3 { font-size: 1.05rem; font-weight: 800; color: var(--primary-dark-blue); margin: 0 0 0.4rem; }
.module-card p  { font-size: 0.8rem; color: var(--text-medium); margin: 0; line-height: 1.4; }

/* Tarjeta de actividad (nivel 2) — fondo pastel claro, icono con degradé */
.activity-card {
  color: #1e293b; justify-content: center; align-items: center;
  text-align: center; padding: 1.25rem; gap: 0;
}
.activity-card h3 { font-size: 0.95rem; font-weight: 800; margin: 0 0 0.3rem; color: #1e293b; }
.activity-card p  { font-size: 0.78rem; color: #64748b; margin: 0; line-height: 1.4; }
.activity-card .activity-icon {
  width: 35%; aspect-ratio: 1; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; margin-bottom: 0.85rem; flex-shrink: 0;
}
.activity-card .activity-icon svg { width: 55%; height: 55%; color: white; }

/* ── Autocomplete dropdown ──────────────────────────────────────────────── */
.autocomplete-wrapper { position: relative; }
.autocomplete-dropdown {
  position: absolute; top: 100%; left: 0; right: 0;
  background: white; border: 1px solid var(--border);
  border-radius: 0.5rem; box-shadow: var(--shadow-lg);
  max-height: 250px; overflow-y: auto; z-index: 50;
  display: none;
}
.autocomplete-dropdown.active { display: block; }
.autocomplete-item {
  padding: 0.65rem 0.75rem; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.autocomplete-item:hover { background: #f0fdf4; }
.autocomplete-item--active { background: var(--primary-dark-blue) !important; color: white !important; }
.autocomplete-item--active small { color: rgba(255,255,255,0.75) !important; }

/* ── Breadcrumb ──────────────────────────────────────────────────────────── */
.breadcrumb-nav {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0.1rem;
  list-style: none; margin-bottom: 1.25rem; padding: 0;
}
.breadcrumb-nav li { display: flex; align-items: center; }
.breadcrumb-nav a {
  color: #64748b; text-decoration: none;
  font-size: 0.8rem; font-weight: 500;
  padding: 0.25rem 0.55rem; border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
  cursor: pointer; white-space: nowrap;
}
.breadcrumb-nav a:hover { background: rgba(0, 68, 119, 0.08); color: var(--primary-dark-blue); }
.breadcrumb-nav .sep {
  display: flex; align-items: center;
  color: #cbd5e1; margin: 0 0.05rem; flex-shrink: 0;
}
.breadcrumb-nav .sep svg { width: 12px; height: 12px; stroke-width: 2.5; }
.breadcrumb-nav .active {
  font-size: 0.8rem; font-weight: 700;
  color: var(--primary-dark-blue);
  background: rgba(0, 68, 119, 0.08);
  padding: 0.25rem 0.55rem; border-radius: 6px;
  white-space: nowrap;
}
