/* ============================================================
   GESTIÓN MI CURSO — Design System v2.0
   Paleta: Indigo/Violet oscuro (dashboard) + blanco (contenido)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #4338ca;
  --primary-dark: #3730a3;
  --primary-light: #6366f1;
  --accent: #7c3aed;
  --accent-light: #a855f7;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --sidebar-bg: #0f172a;
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.12);
}

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

body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── SIDEBAR ── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
}

.sidebar-logo span {
  background: linear-gradient(135deg, var(--primary-light), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-user {
  padding: 16px 24px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.sidebar-user-info .name {
  color: #fff;
  font-weight: 600;
  font-size: 13px;
}

.sidebar-user-info .role {
  color: rgba(255,255,255,.5);
  font-size: 11px;
  text-transform: capitalize;
}

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

.nav-section {
  padding: 12px 24px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,.3);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 24px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all .2s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: rgba(99,102,241,.12);
  color: #c7d2fe;
}

.nav-item.active {
  background: rgba(99,102,241,.2);
  color: #fff;
  border-left: 3px solid var(--primary-light);
  padding-left: 21px;
  font-weight: 600;
}

.nav-item .icon { font-size: 16px; }

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,.06);
}

.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255,255,255,.5);
  text-decoration: none;
  font-size: 13px;
  padding: 8px 0;
  transition: color .2s;
}

.sidebar-footer a:hover { color: #fff; }

/* ── TOPBAR ── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  z-index: 90;
  box-shadow: 0 1px 8px rgba(0,0,0,.04);
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.topbar-actions { display: flex; align-items: center; gap: 12px; }

/* ── MAIN CONTENT ── */
.main {
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  min-height: 100vh;
}

.page {
  padding: 28px;
  display: none;
}

.page.active { display: block !important; visibility: visible !important; opacity: 1 !important; }

/* ── CARDS ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.card-body { padding: 24px; }

/* ── STATS GRID ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.blue   { background: #eff6ff; }
.stat-icon.green  { background: #f0fdf4; }
.stat-icon.purple { background: #faf5ff; }
.stat-icon.orange { background: #fff7ed; }
.stat-icon.red    { background: #fef2f2; }

.stat-info .value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-info .label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}

/* ── TABLES ── */
.table-wrap { overflow-x: auto; }

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

thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
}

tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text);
  vertical-align: middle;
}

tbody tr:hover { background: #fafbfc; }

tbody tr:last-child td { border-bottom: none; }

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-gray    { background: #f1f5f9; color: #475569; }
.badge-purple  { background: #f3e8ff; color: #6b21a8; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(67,56,202,.4);
}

.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline {
  background: #fff;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

.btn-icon {
  width: 34px; height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  transition: all .2s;
  text-decoration: none;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon.danger:hover { background: #fee2e2; color: var(--danger); border-color: #fca5a5; }

/* ── FORMS ── */
.form-group { margin-bottom: 18px; }

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

input[type=text], input[type=email], input[type=password],
input[type=number], input[type=date], input[type=time],
input[type=tel], select, textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14.5px;
  color: var(--text);
  background: #fff;
  font-family: inherit;
  transition: border-color .2s, box-shadow .2s, background .2s;
  box-sizing: border-box;
}
input[type=text]:hover, input[type=email]:hover, input[type=password]:hover,
input[type=number]:hover, input[type=date]:hover, input[type=time]:hover,
input[type=tel]:hover, select:hover, textarea:hover {
  border-color: #cbd5e1;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(67,56,202,.1);
}

textarea { resize: vertical; min-height: 100px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open { display: flex; }
/* Cuando hay modal abierto, evitar scroll y ocultar headers móvil */
body.modal-open { overflow: hidden; }
body.modal-open .mobile-header,
body.modal-open .mobile-tabs-wrap { z-index: 1 !important; }

.modal {
  background: var(--card);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 2;
  border-radius: 16px 16px 0 0;
}

.modal-title { font-size: 17px; font-weight: 700; color: var(--text); }

.modal-close {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: none;
  background: var(--bg);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.modal-close:hover { background: #fee2e2; color: var(--danger); }

.modal-body { padding: 22px 24px; }
.modal-body .form-group:last-child { margin-bottom: 0; }
.modal-body label { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.modal-body input::placeholder,
.modal-body textarea::placeholder { color: #9ca3af; opacity: .8; font-style: normal; }

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  position: sticky;
  bottom: 0;
  background: var(--card);
  border-radius: 0 0 16px 16px;
}

/* ── ALERTS ── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 500;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ── PROGRESS ── */
.progress-bar {
  background: #e2e8f0;
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .5s;
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.empty-state p  { font-size: 14px; margin-bottom: 20px; }

/* ── PLAN BADGE ── */
.plan-gratis     { background:#f1f5f9; color:#475569; }
.plan-estandar   { background:#dbeafe; color:#1e40af; }
.plan-anual      { background:#d1fae5; color:#065f46; }
.plan-permanente { background:#f3e8ff; color:#6b21a8; }

/* ── UTILS ── */
.flex  { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mb-4  { margin-bottom: 16px; }
.mb-6  { margin-bottom: 24px; }
.mt-4  { margin-top: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ── ADMIN DARK MODE (super admin panel) ── */
.admin-dark {
  background: #0f172a;
  color: #fff;
  min-height: 100vh;
}

.admin-dark .card {
  background: #1e293b;
  border: 1px solid rgba(255,255,255,.08);
  color: #fff;
}

.admin-dark .card-header {
  border-bottom-color: rgba(255,255,255,.08);
}

.admin-dark thead th {
  background: rgba(99,102,241,.08);
  color: rgba(255,255,255,.5);
  border-bottom-color: rgba(255,255,255,.08);
}

.admin-dark tbody td {
  border-bottom-color: rgba(255,255,255,.04);
  color: rgba(255,255,255,.85);
}

.admin-dark tbody tr:hover { background: rgba(255,255,255,.02); }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .3s; }
  .sidebar.open { transform: translateX(0); }
  .topbar, .main { left: 0; margin-left: 0; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ── LOADING ── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── CALENDAR ── */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.calendar-day {
  background: #fff;
  padding: 8px;
  min-height: 80px;
  font-size: 12px;
}

.calendar-day.today { background: #eff6ff; }
.calendar-day.other-month { background: #fafbfc; color: var(--text-muted); }

.calendar-event {
  background: var(--primary);
  color: #fff;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  margin-top: 2px;
  cursor: pointer;
  truncate: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

/* ── PRINT ── */
@media print {
  .sidebar, .topbar, .btn, .modal-overlay { display: none !important; }
  .main { margin-left: 0; padding-top: 0; }
  .page { display: block !important; }
}

/* ══════════════════════════════════════
   MOBILE RESPONSIVE FIXES
   ══════════════════════════════════════ */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform .3s ease;
    z-index: 200;
    width: 260px !important;
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0 !important; }
  .topbar { left: 0 !important; padding: 0 16px; }
  .topbar-title { font-size: 15px; }

  .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 12px; }
  .stat-card { padding: 14px; }
  .stat-info .value { font-size: 20px; }
  .stat-icon { width: 42px; height: 42px; font-size: 18px; }

  .page { padding: 16px !important; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 480px; }

  .form-row, .form-row-3 { grid-template-columns: 1fr !important; }

  /* ═══════════════════════════════════════════════════
     MODAL MOBILE — Pantalla completa, sin cortes
     ═══════════════════════════════════════════════════ */
  .modal-overlay {
    padding: 0 !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    z-index: 999999 !important;
    background: rgba(0,0,0,.6) !important;
    overflow: hidden !important;
  }
  .modal-overlay.open {
    display: flex !important;
    flex-direction: column !important;
  }
  .modal {
    border-radius: 0 !important;
    max-height: 100% !important;
    max-width: 100% !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    box-shadow: none !important;
  }
  .modal-header {
    padding: 14px 16px !important;
    background: var(--card) !important;
    border-radius: 0 !important;
    border-bottom: 1px solid var(--border) !important;
    flex-shrink: 0 !important;
    position: relative !important;
    top: auto !important;
    z-index: auto !important;
  }
  .modal-title { font-size: 16px !important; font-weight: 700 !important; }
  .modal-close {
    width: 36px !important;
    height: 36px !important;
    font-size: 18px !important;
  }
  .modal-body {
    padding: 18px 16px !important;
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    min-height: 0 !important;
  }
  .modal-footer {
    padding: 12px 16px !important;
    background: var(--card) !important;
    border-top: 1px solid var(--border) !important;
    flex-shrink: 0 !important;
    position: relative !important;
    bottom: auto !important;
    z-index: auto !important;
    box-shadow: 0 -2px 10px rgba(0,0,0,.06) !important;
  }
  .modal-footer .btn { flex: 1 1 auto; }

  .hamburger {
    display: flex !important;
    align-items: center; justify-content: center;
    width: 38px; height: 38px;
    background: none; border: none;
    cursor: pointer; font-size: 22px;
    color: var(--text);
  }

  .sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 150;
    display: none;
  }
  .sidebar-overlay.open { display: block; }
}

@media (min-width: 769px) {
  .hamburger { display: none !important; }
  .sidebar-overlay { display: none !important; }
}
