/* ============================================
   Estandarizadas11CR — Estilos principales
   ============================================ */

:root {
  --navy:       #0f1f3d;
  --navy2:      #1a3060;
  --navy3:      #243d7a;
  --accent:     #2563eb;
  --accent-light: #e6f1fb;

  --bg:         #f4f6fa;
  --surface:    #ffffff;
  --surface2:   #f0f3f9;
  --border:     rgba(15,31,61,0.12);
  --border2:    rgba(15,31,61,0.22);

  --text:       #0f1f3d;
  --text2:      #4a5568;
  --text3:      #8a94a6;

  --success:    #0f6e56;
  --success-bg: #e1f5ee;
  --warning:    #854f0b;
  --warning-bg: #faeeda;
  --danger:     #a32d2d;
  --danger-bg:  #fcebeb;
  --info:       #185fa5;
  --info-bg:    #e6f1fb;

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  20px;

  --shadow-sm:  0 1px 3px rgba(15,31,61,0.08);
  --shadow-md:  0 4px 16px rgba(15,31,61,0.10);

  --nav-h:      56px;
  --sidebar-w:  220px;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; display: block; }

/* ============================================
   TIPOGRAFÍA
   ============================================ */
h1 { font-size: 1.5rem;  font-weight: 600; line-height: 1.3; }
h2 { font-size: 1.25rem; font-weight: 600; line-height: 1.3; }
h3 { font-size: 1rem;    font-weight: 600; line-height: 1.4; }
h4 { font-size: 0.875rem;font-weight: 600; }
p  { font-size: 0.9375rem; }

.text-sm   { font-size: 0.875rem; }
.text-xs   { font-size: 0.75rem; }
.text-muted { color: var(--text2); }
.text-hint  { color: var(--text3); }
.font-500   { font-weight: 500; }
.font-600   { font-weight: 600; }

/* ============================================
   LOGIN / REGISTRO
   ============================================ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, #0f1f3d 0%, #1a3060 50%, #243d7a 100%);
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 1.75rem;
}

.auth-logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--navy2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
}

.auth-logo-text {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.02em;
}

.auth-tabs {
  display: flex;
  gap: 0;
  border: 0.5px solid var(--border2);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.auth-tab {
  flex: 1;
  padding: 9px;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 500;
  background: transparent;
  border: none;
  color: var(--text3);
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--navy2);
  color: #fff;
}

.auth-section { display: none; }
.auth-section.active { display: block; }

/* ============================================
   FORMULARIOS
   ============================================ */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 5px;
}

.form-control {
  width: 100%;
  padding: 10px 13px;
  border: 0.5px solid var(--border2);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--navy2);
  box-shadow: 0 0 0 3px rgba(26,48,96,0.12);
}

.form-control::placeholder { color: var(--text3); }

.form-hint {
  font-size: 0.75rem;
  color: var(--text3);
  margin-top: 4px;
}

.form-error {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: 4px;
  display: none;
}

.form-error.visible { display: block; }

/* Select personalizado */
select.form-control {
  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='%238a94a6' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

/* ============================================
   BOTONES
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-weight: 500;
  border: none;
  transition: all 0.18s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--navy2);
  color: #fff;
  width: 100%;
  padding: 12px;
}

.btn-primary:hover { background: var(--navy); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 0.5px solid var(--border2);
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8125rem;
}

.btn-icon {
  padding: 8px;
  background: transparent;
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
}

.btn-icon:hover { background: var(--surface2); }

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* ============================================
   APP LAYOUT (post-login)
   ============================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.25s ease;
}

.sidebar-logo {
  padding: 1.25rem 1rem;
  display: flex;
  align-items: center;
  gap: 9px;
  border-bottom: 0.5px solid rgba(255,255,255,0.08);
}

.sidebar-logo-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 0.8125rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.75rem 1rem 0.375rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 1rem;
  color: rgba(255,255,255,0.65);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0;
  transition: all 0.15s;
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item i { font-size: 17px; flex-shrink: 0; }

.nav-item:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
}

.nav-item.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #60a5fa;
  border-radius: 0 2px 2px 0;
}

.nav-item { position: relative; }

.sidebar-footer {
  padding: 1rem;
  border-top: 0.5px solid rgba(255,255,255,0.08);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s;
}

.user-chip:hover { background: rgba(255,255,255,0.07); }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }

.user-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.6875rem;
  color: rgba(255,255,255,0.45);
}

/* Main content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

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

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

.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 22px;
  padding: 4px;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Page content */
.page-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

/* ============================================
   OVERLAY SIDEBAR (mobile)
   ============================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 99;
}

/* ============================================
   CARDS
   ============================================ */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border);
  padding: 1.25rem;
}

.card-sm { padding: 1rem; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

/* ============================================
   STAT CARDS
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text3);
  font-weight: 500;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.stat-sub {
  font-size: 0.75rem;
  color: var(--text3);
}

/* ============================================
   MATERIAS GRID
   ============================================ */
.materias-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 1.5rem;
}

.materia-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  cursor: pointer;
  transition: all 0.18s;
  position: relative;
  text-decoration: none;
  display: block;
}

.materia-card:hover {
  border-color: var(--border2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.materia-card.enfasis {
  border: 2px solid var(--success);
}

.materia-card.bloqueada {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
  background: var(--surface2);
}

.materia-card-header {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
}

.materia-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

.materia-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.badge-enfasis {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--success-bg);
  color: var(--success);
  font-size: 0.625rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-lock {
  position: absolute;
  top: 9px;
  right: 9px;
  color: var(--text3);
  font-size: 14px;
}

.progress-bar-wrap {
  height: 4px;
  background: var(--surface2);
  border-radius: 2px;
  margin-bottom: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

.materia-meta {
  font-size: 0.75rem;
  color: var(--text3);
}

/* ============================================
   ACTIVIDAD RECIENTE
   ============================================ */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.activity-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: var(--radius-md);
}

.activity-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.activity-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.activity-text {
  font-size: 0.875rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-right {
  font-size: 0.75rem;
  color: var(--text3);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ============================================
   BADGES / PILLS
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-gray    { background: var(--surface2);   color: var(--text2); border: 0.5px solid var(--border); }

/* ============================================
   SECCIÓN LABEL
   ============================================ */
.section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 10px;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text3);
}

.empty-state i {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  display: block;
}

/* ============================================
   TOAST / ALERTAS
   ============================================ */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--navy);
  color: #fff;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 9px;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.25s ease;
  pointer-events: auto;
  max-width: 320px;
}

.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); }

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

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

.spinner-dark {
  border-color: rgba(15,31,61,0.15);
  border-top-color: var(--navy2);
}

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

/* ============================================
   MODAL
   ============================================ */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-md);
  animation: modal-in 0.2s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

/* ============================================
   RESPONSIVE — TABLET
   ============================================ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 200px; }
}

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

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

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

  .hamburger {
    display: block;
  }

  .page-content {
    padding: 1rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .materias-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 9px;
  }

  .topbar {
    padding: 0 1rem;
  }

  h1 { font-size: 1.25rem; }
}

@media (max-width: 420px) {
  .materias-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .auth-card {
    padding: 1.5rem;
  }
}
