/* ============================================
   DASHBOARD & LOGIN - Scoped Styles
   Depends on: base.css, components.css, sections.css, responsive.css
   ============================================ */

/* ---------- Dashboard Design Tokens ---------- */
.login-page,
.dashboard-page {
  --db-primary: var(--accent-color);
  --db-primary-dark: var(--primary-color);
  --db-primary-light: var(--primary-light);
  --db-success: var(--success-color);
  --db-warning: var(--warning-color);
  --db-gray-50: #f9fafb;
  --db-gray-100: #f3f4f6;
  --db-gray-200: #e5e7eb;
  --db-gray-300: #d1d5db;
  --db-gray-400: #9ca3af;
  --db-gray-500: #6b7280;
  --db-gray-600: #4b5563;
  --db-gray-700: #374151;
  --db-gray-800: #1f2937;
  --db-gray-900: #111827;
  --db-radius: 12px;
  --db-radius-sm: 8px;
  --db-radius-lg: 16px;
  --db-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --db-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --db-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --sidebar-width: 260px;
}

.login-page .hidden,
.dashboard-page .hidden {
  display: none !important;
}


/* ============================================
   LOGIN PAGE
   ============================================ */

.login-page {
  background: linear-gradient(135deg, var(--db-primary) 0%, var(--db-primary-dark) 100%);
  padding-top: 80px;
}

.login-container {
  display: flex;
  min-height: calc(100vh - 80px);
}

.login-branding {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: white;
}

.branding-content {
  max-width: 420px;
}

.branding-content h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 1rem 0;
  line-height: 1.2;
}

.branding-content p {
  font-size: 1.125rem;
  opacity: 0.9;
  margin-bottom: 2.5rem;
}

.login-features {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-feature-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1rem;
}

.login-feature-icon {
  width: 24px;
  height: 24px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

.login-form-section {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  background: white;
  border-radius: 24px 0 0 24px;
}

.login-form-container {
  width: 100%;
  max-width: 400px;
}

.login-form-container h2 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--db-gray-900);
  margin-bottom: 0.5rem;
}

.login-subtitle {
  color: var(--db-gray-500);
  margin-bottom: 2rem;
}

.login-page .form-group {
  margin-bottom: 1.5rem;
}

.login-page .form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--db-gray-700);
  margin-bottom: 0.5rem;
}

.login-page .form-group input {
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  border: 1px solid var(--db-gray-300);
  border-radius: var(--db-radius-sm);
  background: var(--db-gray-50);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-page .form-group input:focus {
  outline: none;
  border-color: var(--db-primary-light);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  background: white;
}

.login-page .form-group input::placeholder {
  color: var(--db-gray-400);
}

.login-page .error-message {
  padding: 0.875rem 1rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--db-radius-sm);
  color: #dc2626;
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

/* Login page button override */
.login-page .btn {
  border-radius: var(--db-radius-sm);
  padding: 0.875rem 1.5rem;
  background: var(--db-primary);
  box-shadow: none;
}

.login-page .btn:hover {
  background: var(--db-primary-dark);
}

.login-page .btn-full {
  width: 100%;
}

.login-page .btn-loader .spinner {
  width: 20px;
  height: 20px;
}

.login-footer {
  margin-top: 2rem;
  text-align: center;
  color: var(--db-gray-500);
  font-size: 0.875rem;
}


/* ============================================
   DASHBOARD LAYOUT
   ============================================ */

.dashboard-page {
  padding-top: 80px;
}

.dashboard-layout {
  display: flex;
  min-height: calc(100vh - 80px);
}


/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
  width: var(--sidebar-width);
  background: white;
  border-right: 1px solid var(--db-gray-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 80px;
  left: 0;
  height: calc(100vh - 80px);
  z-index: 100;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--db-gray-100);
}

.sidebar-brand {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--db-primary);
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.5rem;
  color: var(--db-gray-600);
  font-weight: 500;
  transition: all 0.2s;
  position: relative;
  text-decoration: none;
}

.sidebar-nav .nav-item:hover {
  background: var(--db-gray-50);
  color: var(--db-gray-900);
}

.sidebar-nav .nav-item.active {
  background: rgba(37, 99, 235, 0.06);
  color: var(--db-primary-dark);
}

.sidebar-nav .nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 24px;
  background: var(--db-primary);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  font-size: 1.25rem;
  width: 24px;
  text-align: center;
}

.nav-external {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--db-gray-400);
}

.sidebar-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--db-gray-100);
}

.balance-card {
  background: linear-gradient(135deg, var(--db-primary) 0%, var(--db-primary-dark) 100%);
  border-radius: var(--db-radius);
  padding: 1.25rem;
  color: white;
  text-align: center;
}

.balance-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.9;
  margin-bottom: 0.5rem;
}

.balance-value {
  font-size: 2rem;
  font-weight: 700;
}


/* ============================================
   MAIN CONTENT
   ============================================ */

.dashboard-page .main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 2rem;
  max-width: calc(100vw - var(--sidebar-width));
}


/* ============================================
   DASHBOARD HEADER
   ============================================ */

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

.header-left h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--db-gray-900);
}

.header-subtitle {
  color: var(--db-gray-500);
  margin-top: 0.25rem;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--db-gray-200);
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-weight: 600;
  color: var(--db-gray-800);
}

.logout-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--db-gray-500);
  font-size: 0.75rem;
  text-align: left;
}

.logout-btn:hover {
  color: var(--db-primary);
}


/* ============================================
   PROGRESS OVERVIEW
   ============================================ */

.progress-overview {
  margin-bottom: 2rem;
}

.progress-card {
  background: white;
  border-radius: var(--db-radius-lg);
  padding: 1.5rem;
  box-shadow: var(--db-shadow);
}

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

.progress-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--db-gray-700);
}

.progress-percentage {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--db-primary);
}

.progress-bar-container {
  height: 12px;
  background: var(--db-gray-100);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--db-primary-light) 0%, var(--db-success) 100%);
  border-radius: 6px;
  transition: width 0.5s ease-out;
}

.progress-stats {
  display: flex;
  gap: 2rem;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--db-gray-900);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--db-gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}


/* ============================================
   LESSONS SECTION
   ============================================ */

.lessons-section {
  background: white;
  border-radius: var(--db-radius-lg);
  padding: 1.5rem;
  box-shadow: var(--db-shadow);
}

.dashboard-page .section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.dashboard-page .section-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--db-gray-800);
}

.filter-tabs {
  display: flex;
  background: var(--db-gray-100);
  border-radius: var(--db-radius-sm);
  padding: 4px;
}

.filter-tab {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--db-gray-600);
  transition: all 0.2s;
}

.filter-tab:hover {
  color: var(--db-gray-900);
}

.filter-tab.active {
  background: white;
  color: var(--db-gray-900);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}


/* ============================================
   LESSONS GRID
   ============================================ */

.lessons-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.lesson-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--db-gray-50);
  border-radius: var(--db-radius);
  border: 1px solid var(--db-gray-200);
  transition: all 0.2s;
}

.lesson-card:hover {
  background: white;
  border-color: rgba(37, 99, 235, 0.3);
  box-shadow: var(--db-shadow);
}

.lesson-card.completed {
  background: rgba(34, 197, 94, 0.05);
  border-color: rgba(34, 197, 94, 0.15);
}

.lesson-checkbox {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.lesson-checkbox input {
  display: none;
}

.lesson-checkbox .checkmark {
  width: 24px;
  height: 24px;
  border: 2px solid var(--db-gray-300);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
}

.lesson-checkbox .checkmark:hover {
  border-color: var(--db-primary-light);
}

.lesson-checkbox input:checked + .checkmark {
  background: var(--db-success);
  border-color: var(--db-success);
}

.lesson-checkbox .checkmark svg {
  width: 14px;
  height: 14px;
  stroke: white;
  stroke-width: 3;
  fill: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.lesson-checkbox input:checked + .checkmark svg {
  opacity: 1;
}

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

.lesson-title {
  font-weight: 600;
  color: var(--db-gray-800);
  margin-bottom: 0.25rem;
}

.lesson-card.completed .lesson-title {
  color: var(--db-gray-500);
}

.lesson-description {
  font-size: 0.875rem;
  color: var(--db-gray-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lesson-type {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lesson-type.exercise {
  background: rgba(37, 99, 235, 0.1);
  color: var(--db-primary-dark);
}

.lesson-type.revision {
  background: rgba(245, 158, 11, 0.1);
  color: var(--db-warning);
}

.lesson-type.material {
  background: var(--db-gray-100);
  color: var(--db-gray-600);
}

.lesson-link {
  padding: 0.5rem 1rem;
  background: var(--db-primary);
  color: white;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--db-radius-sm);
  transition: all 0.2s;
  white-space: nowrap;
  text-decoration: none;
}

.lesson-link:hover {
  background: var(--db-primary-dark);
  color: white;
}


/* ============================================
   EMPTY STATE
   ============================================ */

.dashboard-page .empty-state {
  text-align: center;
  padding: 4rem 2rem;
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.dashboard-page .empty-state h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--db-gray-800);
  margin-bottom: 0.5rem;
}

.dashboard-page .empty-state p {
  color: var(--db-gray-500);
}


/* ============================================
   LOADING SCREEN
   ============================================ */

.loading-screen {
  position: fixed;
  inset: 0;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-content {
  text-align: center;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--db-gray-200);
  border-top-color: var(--db-primary);
  border-radius: 50%;
  animation: db-spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

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

.loading-content p {
  color: var(--db-gray-500);
  font-size: 0.875rem;
}


/* ============================================
   TOAST NOTIFICATION
   ============================================ */

.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: var(--db-gray-900);
  color: white;
  border-radius: var(--db-radius);
  box-shadow: var(--db-shadow-lg);
  animation: db-slideUp 0.3s ease-out;
  z-index: 1000;
}

@keyframes db-slideUp {
  from { opacity: 0; transform: translateY(1rem); }
  to { opacity: 1; transform: translateY(0); }
}

.toast-icon {
  width: 24px;
  height: 24px;
  background: var(--db-success);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}


/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
  .sidebar {
    width: 80px;
  }

  .sidebar-header .sidebar-brand,
  .sidebar-nav .nav-label,
  .nav-external,
  .balance-label {
    display: none;
  }

  .sidebar-nav .nav-item {
    justify-content: center;
    padding: 1rem;
  }

  .nav-icon {
    font-size: 1.5rem;
  }

  .balance-card {
    padding: 1rem 0.5rem;
  }

  .balance-value {
    font-size: 1.5rem;
  }

  .dashboard-page .main-content {
    margin-left: 80px;
    max-width: calc(100vw - 80px);
  }
}

@media (max-width: 768px) {
  /* Login */
  .login-container {
    flex-direction: column;
  }

  .login-branding {
    display: none;
  }

  .login-form-section {
    border-radius: 0;
    min-height: calc(100vh - 80px);
  }

  /* Dashboard sidebar -> bottom nav */
  .sidebar {
    width: 100%;
    height: auto;
    position: fixed;
    bottom: 0;
    top: auto;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--db-gray-200);
  }

  .sidebar-header,
  .sidebar-footer {
    display: none;
  }

  .sidebar-nav {
    flex-direction: row;
    justify-content: space-around;
    padding: 0.5rem 0;
    width: 100%;
  }

  .sidebar-nav .nav-item {
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem;
    font-size: 0.75rem;
  }

  .sidebar-nav .nav-item.active::before {
    display: none;
  }

  .sidebar-nav .nav-label {
    display: block;
    font-size: 0.625rem;
  }

  .dashboard-page .main-content {
    margin-left: 0;
    margin-bottom: 70px;
    max-width: 100%;
    padding: 1rem;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .progress-stats {
    flex-wrap: wrap;
  }

  .dashboard-page .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .lesson-card {
    flex-wrap: wrap;
  }

  .lesson-info {
    flex: 1 1 100%;
    order: 2;
    margin-top: 0.5rem;
  }

  .lesson-type {
    order: 1;
  }

  .lesson-link {
    order: 3;
    width: 100%;
    text-align: center;
    margin-top: 0.5rem;
  }

  /* Footer clears bottom nav */
  .dashboard-page .footer {
    margin-bottom: 70px;
  }
}
