/* ==========================================================================
   Python AI Tutor - Modern & Elegant Stylesheet
   Theme: Purple Edge Glow & Glassmorphism
   ========================================================================== */

:root {
  --primary: #9c51e0;
  --primary-hover: #8636cf;
  --primary-rgb: 156, 81, 224;
  --primary-gradient: linear-gradient(135deg, #9c51e0 0%, #6366f1 50%, #ec4899 100%);
  --secondary-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  
  --bg-main: #0a0d14;
  --bg-surface: #111726;
  --bg-surface-hover: #172033;
  --bg-card: rgba(17, 23, 38, 0.75);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(156, 81, 224, 0.25);
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  
  --easy: #10b981;
  --easy-bg: rgba(16, 185, 129, 0.12);
  --medium: #f59e0b;
  --medium-bg: rgba(245, 158, 11, 0.12);
  --hard: #f43f5e;
  --hard-bg: rgba(244, 63, 94, 0.12);
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 25px rgba(156, 81, 224, 0.25);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.85);
  --border-color: rgba(0, 0, 0, 0.08);
  --border-glow: rgba(156, 81, 224, 0.3);
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
}

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

body {
  font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: 
    radial-gradient(at 0% 0%, rgba(156, 81, 224, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(99, 102, 241, 0.1) 0px, transparent 50%);
  background-attachment: fixed;
}

a {
  color: inherit;
  text-decoration: none;
}

code, pre {
  font-family: 'Fira Code', 'JetBrains Mono', Consolas, Monaco, monospace;
}

/* Layout */
.app-container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

/* Header & Nav */
header.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(10, 13, 20, 0.8);
  border-bottom: 1px solid var(--border-color);
}

[data-theme="light"] header.app-header {
  background: rgba(248, 250, 252, 0.85);
}

.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.brand-logo img {
  height: 36px;
  width: auto;
  filter: drop-shadow(0 0 8px rgba(156, 81, 224, 0.4));
  transition: transform 0.3s ease;
}

.brand-logo:hover img {
  transform: rotate(-5deg) scale(1.05);
}

.logo-text {
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
}

.logo-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.45rem;
  background: rgba(156, 81, 224, 0.15);
  color: var(--primary);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  list-style: none;
}

.nav-link {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: var(--transition);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
}

.nav-link:hover, .nav-link.active {
  color: var(--text-main);
  background: var(--bg-surface);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* User Avatar & Menu */
.user-menu {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 0.9rem;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.btn-primary {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(156, 81, 224, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(156, 81, 224, 0.45);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-glow);
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.85rem 1.75rem;
  font-size: 1.05rem;
  border-radius: var(--radius-lg);
}

.btn-icon {
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

.btn-icon:hover {
  color: var(--text-main);
  border-color: var(--border-glow);
}

/* Hero Section */
.hero {
  padding: 5rem 0 4rem;
  text-align: center;
  position: relative;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  background: rgba(156, 81, 224, 0.12);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 1.5rem;
  animation: pulse-glow 3s infinite;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 15px rgba(156, 81, 224, 0.2); }
  50% { box-shadow: 0 0 25px rgba(156, 81, 224, 0.4); }
}

.hero-title {
  font-size: 3.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 1.25rem;
}

.gradient-text {
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--text-muted);
  max-width: 680px;
  margin: 0 auto 2.5rem;
}

.hero-ctas {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Cards & Grid */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.glass-card:hover {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

/* Challenge Cards */
.challenge-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

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

.challenge-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.challenge-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.challenge-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

/* Badges */
.badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-easy { background: var(--easy-bg); color: var(--easy); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-medium { background: var(--medium-bg); color: var(--medium); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-hard { background: var(--hard-bg); color: var(--hard); border: 1px solid rgba(244, 63, 94, 0.3); }
.badge-category { background: rgba(255, 255, 255, 0.05); color: var(--text-muted); border: 1px solid var(--border-color); }
.badge-solved { background: rgba(16, 185, 129, 0.2); color: var(--easy); border: 1px solid var(--easy); }

/* Split Workspace for Challenge Detail */
.workspace-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 1.5rem 0 3rem;
  min-height: calc(100vh - 180px);
}

@media (max-width: 960px) {
  .workspace-layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.panel-header {
  padding: 1rem 1.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-title {
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

/* Markdown Description */
.prose {
  color: var(--text-main);
  line-height: 1.7;
}

.prose h1, .prose h2, .prose h3 {
  margin: 1.25rem 0 0.5rem;
  font-weight: 700;
}

.prose p {
  margin-bottom: 1rem;
}

.prose pre {
  background: rgba(0, 0, 0, 0.4);
  padding: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  overflow-x: auto;
  margin: 1rem 0;
}

/* CodeMirror Container */
.editor-container {
  flex: 1;
  min-height: 250px;
  position: relative;
  font-size: 14px;
}

.cm-editor {
  height: 100%;
  font-family: 'Fira Code', Consolas, Monaco, monospace;
}

/* Test Results & AI Hint Card */
.result-box {
  margin-top: 1rem;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  animation: fadeIn 0.3s ease;
}

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

.result-box.pass {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.result-box.fail {
  background: rgba(244, 63, 94, 0.08);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.ai-hint-card {
  margin-top: 1rem;
  padding: 1.25rem;
  background: linear-gradient(135deg, rgba(156, 81, 224, 0.12) 0%, rgba(99, 102, 241, 0.08) 100%);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-md);
  position: relative;
}

.ai-hint-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: #c084fc;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.ai-hint-text {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-main);
}

/* Streak & Stats Widgets */
.streak-flame {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #f97316;
  font-weight: 700;
  font-size: 0.95rem;
}

/* Spinner indicator for HTMX */
.htmx-indicator {
  display: none;
}
.htmx-request .htmx-indicator {
  display: inline-flex;
}
.htmx-request.htmx-indicator {
  display: inline-flex;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Footer */
footer.app-footer {
  margin-top: auto;
  padding: 2rem 0;
  border-top: 1px solid var(--border-color);
  text-align: left;
  font-size: 0.9rem;
  color: var(--text-dim);
}
