:root {
  --bg-main: #0b0f19;
  --bg-card: #151d30;
  --bg-card-hover: #1e2942;
  --bg-input: #0d1424;
  --border: #22304d;
  --border-focus: #0ea5e9;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --accent: #0d9488;
  --accent-light: #2dd4bf;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 12px;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}

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

/* NAVBAR */
.navbar {
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}

.brand-icon {
  background: linear-gradient(135deg, #0284c7, #10b981);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  padding: 6px 12px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 600;
}

.btn-nav {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-nav:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--danger);
  color: #fca5a5;
}

/* CONTAINER */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px;
  width: 100%;
  flex: 1;
}

/* SCREEN MANAGEMENT */
.screen {
  display: none;
}
.screen.active {
  display: block;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* LOGIN SCREEN */
.login-wrap {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-card h2 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.profile-btn {
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 14px 10px;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.profile-btn .avatar {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

.icon-avatar {
  display: block;
  width: 44px;
  height: 44px;
  transition: transform 0.2s ease;
}

.profile-btn:hover .icon-avatar {
  transform: scale(1.1);
}

.user-badge .icon-avatar {
  width: 20px;
  height: 20px;
}

.pwd-card-header .icon-avatar {
  width: 24px;
  height: 24px;
}

.profile-btn .name {
  font-size: 0.9rem;
  font-weight: 700;
}

.profile-btn .role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.profile-btn:hover {
  border-color: var(--primary);
  background: rgba(2, 132, 199, 0.1);
}

.profile-btn.selected {
  border-color: var(--accent-light);
  background: rgba(13, 148, 136, 0.2);
  box-shadow: 0 0 15px rgba(45, 212, 191, 0.3);
}

.form-group {
  margin-bottom: 18px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: border 0.2s;
}

.form-group input:focus {
  border-color: var(--border-focus);
}

.login-warning {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 14px;
  text-align: center;
  animation: shake 0.3s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #0284c7, #0d9488);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 13px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-primary:hover {
  opacity: 0.92;
}

/* DASHBOARD */
.welcome-hero {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.hero-text h1 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.hero-text p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.stats-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent-light);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

/* CALENDAR / DAYS GRID */
.days-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  margin-bottom: 30px;
}

.day-badge {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 4px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.day-badge:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.day-badge .num {
  font-size: 1.1rem;
  font-weight: 800;
  display: block;
}

.day-badge .sub {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.day-badge.completed {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.12);
  color: #4ade80;
}

.day-badge.today {
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(2, 132, 199, 0.4);
}

/* PRACTICE SCREEN */
.practice-header {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  position: relative;
}

.back-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  margin-bottom: 12px;
}

.back-btn:hover {
  color: #fff;
}

.practice-title-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.badge-tag {
  background: rgba(13, 148, 136, 0.2);
  color: #2dd4bf;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: inline-block;
  margin-bottom: 6px;
}

/* TIMER WIDGET */
.timer-box {
  background: linear-gradient(135deg, #0f172a, #1e293b);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin: 16px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.timer-box.running {
  border-color: var(--success);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.timer-display {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.timer-digits {
  font-size: 2.2rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.timer-status {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.timer-actions {
  display: flex;
  gap: 10px;
}

.btn-timer {
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-start {
  background: var(--success);
  color: #fff;
}
.btn-start:hover {
  background: #059669;
}

.btn-stop {
  background: var(--danger);
  color: #fff;
}
.btn-stop:hover {
  background: #dc2626;
}

/* BLOCKS */
.block-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  transition: all 0.2s;
}

.block-item.checked {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.05);
}

.block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.block-title {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.block-time {
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  color: var(--accent-light);
}

.block-body {
  font-size: 0.92rem;
  color: #cbd5e1;
  line-height: 1.5;
  margin-bottom: 14px;
}

.block-body strong {
  color: #fff;
}

.video-container {
  margin: 12px 0;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  position: relative;
  aspect-ratio: 16 / 9;
}

.video-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.youtube-direct-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: #38bdf8;
  text-decoration: none;
  font-weight: 600;
  padding: 4px 10px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 6px;
  transition: all 0.2s;
}

.youtube-direct-link:hover {
  background: rgba(56, 189, 248, 0.18);
  color: #7dd3fc;
  border-color: #38bdf8;
}

.video-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: var(--text-muted);
  padding: 20px;
  text-align: center;
  gap: 8px;
}

.video-placeholder .icon {
  font-size: 2.5rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  user-select: none;
}

.checkbox-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--success);
  cursor: pointer;
}

.checkbox-row span {
  font-size: 0.95rem;
  font-weight: 600;
}

/* NOTES AREA */
.notes-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.notes-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.notes-card textarea {
  width: 100%;
  min-height: 90px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  color: #fff;
  font-size: 0.9rem;
  resize: vertical;
  outline: none;
}

.notes-card textarea:focus {
  border-color: var(--border-focus);
}

/* SESSION LOG LIST */
.session-history {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.session-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  margin-right: 6px;
  margin-bottom: 4px;
}

/* ADMIN DASHBOARD */
.admin-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  margin-top: 20px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.admin-table th {
  background: #0f172a;
  padding: 12px 14px;
  color: var(--text-muted);
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

.admin-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}

.admin-table tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.student-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.pill-complete {
  background: rgba(16, 185, 129, 0.15);
  color: #4ade80;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.pill-partial {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ADMIN PASSWORD MANAGER */
.pwd-manager-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 14px;
  width: 100%;
}

.pwd-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0; /* Evita desbordamiento en CSS Grid */
  box-sizing: border-box;
}

.pwd-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.95rem;
}

.pwd-input-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.pwd-input {
  flex: 1;
  min-width: 0; /* Permite que el input se adapte sin romper el contenedor */
  padding: 9px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: #fff;
  font-size: 0.9rem;
  outline: none;
  box-sizing: border-box;
}

.pwd-input:focus {
  border-color: var(--border-focus);
}

.btn-save-pwd {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

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

.pwd-feedback {
  font-size: 0.75rem;
  min-height: 16px;
  color: #4ade80;
  font-weight: 600;
}

/* RESPONSIVE */
@media (max-width: 640px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }
  .pwd-manager-grid {
    grid-template-columns: 1fr;
  }
  .timer-box {
    flex-direction: column;
    align-items: flex-start;
  }
  .stats-bar {
    grid-template-columns: 1fr;
  }
}
