/* ============================================================
   EduArch — Institutional AI Platform Styles
   ============================================================ */

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --primary-50: #e0e7ff;
  --success: #059669;
  --success-light: #ecfdf5;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

/* ---- LOGIN PAGE ---- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 1rem;
}

.login-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
}

.login-brand {
  text-align: center;
  margin-bottom: 2rem;
}

.login-brand h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.login-brand p {
  color: var(--gray-500);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* ---- FORMS ---- */

.form-group {
  margin-bottom: 1.25rem;
}

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

.form-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-family: var(--font);
  color: var(--gray-800);
  transition: border-color 0.15s, box-shadow 0.15s;
  background: white;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.form-input::placeholder {
  color: var(--gray-400);
}

textarea.form-input {
  resize: vertical;
  min-height: 80px;
}

.form-select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-family: var(--font);
  color: var(--gray-800);
  background: white;
  cursor: pointer;
}

.form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

/* ---- BUTTONS ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

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

.btn-secondary {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--gray-50);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

/* ---- LAYOUT ---- */

.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--gray-900);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand h2 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.sidebar-brand span {
  font-size: 0.75rem;
  color: var(--gray-400);
}

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

.sidebar-section {
  padding: 0 0.75rem;
  margin-bottom: 1.5rem;
}

.sidebar-section-title {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  padding: 0 0.75rem;
  margin-bottom: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius);
  color: var(--gray-300);
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
}

.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.nav-item.active {
  background: var(--primary);
  color: white;
}

.nav-item .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 1rem;
}

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

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

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
}

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

.user-details .name {
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-details .role {
  font-size: 0.75rem;
  color: var(--gray-400);
}

.main-content {
  flex: 1;
  margin-left: 260px;
  min-height: 100vh;
}

.page-header {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-header h1 {
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--gray-900);
}

.page-header .subtitle {
  font-size: 0.8125rem;
  color: var(--gray-500);
  margin-top: 0.125rem;
}

.page-body {
  padding: 1.5rem 2rem;
}

/* ---- CARDS ---- */

.card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.card-body {
  padding: 1.5rem;
}

/* ---- DASHBOARD STATS ---- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
}

.stat-card .stat-label {
  font-size: 0.8125rem;
  color: var(--gray-500);
  font-weight: 500;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-top: 0.25rem;
}

.stat-card .stat-sub {
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-top: 0.25rem;
}

.stat-card.accent-primary { border-left: 4px solid var(--primary); }
.stat-card.accent-success { border-left: 4px solid var(--success); }
.stat-card.accent-warning { border-left: 4px solid var(--warning); }
.stat-card.accent-danger { border-left: 4px solid var(--danger); }

/* ---- DASHBOARD GRID ---- */

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* ---- MODULE CARDS (Dashboard) ---- */

.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.module-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.module-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.module-card .module-icon {
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
}

.module-card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 0.375rem;
}

.module-card p {
  font-size: 0.8125rem;
  color: var(--gray-500);
  line-height: 1.5;
}

/* ---- TEACHING AIDE FORM ---- */

.generator-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.form-card {
  position: sticky;
  top: 90px;
}

/* ---- OUTPUT PANEL ---- */

.output-panel {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-height: 400px;
}

.output-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.output-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.output-body {
  padding: 1.5rem;
}

.output-body .empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--gray-400);
}

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

.empty-state p {
  font-size: 0.9375rem;
}

.output-body .content {
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--gray-700);
}

.output-body .content h1,
.output-body .content h2,
.output-body .content h3 {
  color: var(--gray-900);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.output-body .content h1 { font-size: 1.375rem; }
.output-body .content h2 { font-size: 1.125rem; }
.output-body .content h3 { font-size: 1rem; }

.output-body .content p {
  margin-bottom: 0.75rem;
}

.output-body .content ul,
.output-body .content ol {
  margin-bottom: 0.75rem;
  padding-left: 1.5rem;
}

.output-body .content li {
  margin-bottom: 0.375rem;
}

.output-body .content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.875rem;
}

.output-body .content th,
.output-body .content td {
  border: 1px solid var(--gray-200);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.output-body .content th {
  background: var(--gray-50);
  font-weight: 600;
}

.output-body .content code {
  background: var(--gray-100);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.85em;
}

.output-body .content pre {
  background: var(--gray-900);
  color: var(--gray-100);
  padding: 1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1rem 0;
}

.output-body .content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.output-body .content strong {
  color: var(--gray-900);
}

/* ---- USAGE INFO ---- */

.usage-bar {
  display: flex;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  font-size: 0.8125rem;
  color: var(--gray-500);
}

.usage-bar span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* ---- HISTORY TABLE ---- */

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.history-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: var(--gray-500);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--gray-200);
}

.history-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

.history-table tr:hover td {
  background: var(--gray-50);
}

/* ---- BADGES ---- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }

/* ---- LOADING ---- */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-lg {
  width: 36px;
  height: 36px;
}

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

.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  gap: 1rem;
  color: var(--gray-500);
}

/* ---- ALERT ---- */

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #fecaca;
}

.alert-success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid #a7f3d0;
}

/* ---- RESPONSIVE ---- */

@media (max-width: 1024px) {
  .generator-layout {
    grid-template-columns: 1fr;
  }
  .form-card {
    position: static;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .page-body {
    padding: 1rem;
  }
  .page-header {
    padding: 1rem;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ---- TABS ---- */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  font-family: var(--font);
  transition: all 0.15s;
}

.tab:hover { color: var(--gray-700); }

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ---- COPY BUTTON ---- */

.btn-copy {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  background: white;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  color: var(--gray-600);
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
}

.btn-copy:hover {
  background: var(--gray-50);
}

/* ---- QUICK ACTIONS ---- */

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.875rem;
  border: 1px solid var(--gray-200);
  border-radius: 100px;
  font-size: 0.8125rem;
  color: var(--gray-600);
  background: white;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}

.chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* ---- SCROLLBAR ---- */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
