/* --- Design Tokens & Variables --- */
:root {
  --font-family-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-family-display: 'Outfit', sans-serif;

  /* Color Palette */
  --bg-main: #0B0F19;
  --bg-surface: rgba(17, 24, 39, 0.7);
  --bg-surface-solid: #111827;
  --bg-card: rgba(31, 41, 55, 0.4);
  --bg-card-hover: rgba(31, 41, 55, 0.6);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-focus: rgba(255, 255, 255, 0.2);

  --text-primary: #F9FAFB;
  --text-secondary: #9CA3AF;
  --text-muted: #6B7280;

  /* Branch Theme Accents (Dynamically overridden via class names on body/root) */
  --accent-gradient: linear-gradient(135deg, #8B5CF6 0%, #6366F1 100%);
  --accent-color: #8B5CF6;
  --accent-color-glow: rgba(139, 92, 246, 0.15);

  --success-color: #10B981;
  --success-gradient: linear-gradient(135deg, #34D399 0%, #059669 100%);
  --warning-color: #F59E0B;
  --error-color: #EF4444;

  /* Layout */
  --max-width: 1280px;
  --header-height: 70px;
  --border-radius-sm: 8px;
  --border-radius-md: 16px;
  --border-radius-lg: 24px;
}

/* Branch specific overrides */
.theme-cse {
  --accent-gradient: linear-gradient(135deg, #a78bfa 0%, #6366f1 100%);
  --accent-color: #8B5CF6;
  --accent-color-glow: rgba(139, 92, 246, 0.2);
}

.theme-aiml {
  --accent-gradient: linear-gradient(135deg, #2dd4bf 0%, #059669 100%);
  --accent-color: #10B981;
  --accent-color-glow: rgba(16, 185, 129, 0.2);
}

.theme-ds {
  --accent-gradient: linear-gradient(135deg, #fbbf24 0%, #f43f5e 100%);
  --accent-color: #F59E0B;
  --accent-color-glow: rgba(245, 158, 11, 0.2);
}

/* --- Base & Reset --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(at 0% 0%, rgba(17, 24, 39, 0.9) 0, transparent 50%),
    radial-gradient(at 50% 0%, var(--accent-color-glow) 0, transparent 50%),
    radial-gradient(at 100% 100%, rgba(17, 24, 39, 0.8) 0, transparent 50%);
  background-attachment: fixed;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family-display);
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

button, input, select {
  font-family: inherit;
  color: inherit;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 10px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: #1F2937;
  border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
  background: #374151;
}

/* --- Layout Components --- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

.main-content {
  padding-top: calc(var(--header-height) + 2rem);
  padding-bottom: 5rem;
  min-height: calc(100vh - var(--header-height));
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

/* Glassmorphism Classes */
.glass-panel {
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
}

.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card:hover {
  transform: translateY(-4px);
  background: var(--bg-card-hover);
  border-color: var(--border-color-focus);
  box-shadow: 0 12px 30px -10px var(--accent-color-glow);
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 15px var(--accent-color-glow); }
  50% { box-shadow: 0 0 25px rgba(255,255,255,0.05); }
}

.anim-fade-in {
  animation: fadeIn 0.5s ease-out forwards;
}

.anim-slide-up {
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* --- UI Patterns --- */

/* Header / Navbar */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  z-index: 100;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  background: rgba(11, 15, 25, 0.8);
  backdrop-filter: blur(12px);
}

.navbar-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.5rem;
  font-family: var(--font-family-display);
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo svg {
  stroke: var(--accent-color);
}

.navbar-stats {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.875rem;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.4rem 0.8rem;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.stat-value {
  color: var(--text-primary);
  font-weight: 600;
}

/* Hero Section */
.hero-section {
  padding: 3rem 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  position: relative;
  overflow: hidden;
}

.hero-tag {
  background: var(--accent-color-glow);
  color: var(--accent-color);
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid rgba(255,255,255,0.05);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.hero-title {
  font-size: 3rem;
  line-height: 1.1;
  background: linear-gradient(180deg, #FFFFFF 0%, #A3A3A3 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  max-width: 800px;
}

.hero-subtitle {
  color: var(--text-secondary);
  font-size: 1.125rem;
  max-width: 600px;
  line-height: 1.6;
}

/* Search Bar */
.search-container {
  position: relative;
  width: 100%;
  max-width: 500px;
  margin-top: 1rem;
}

.search-input {
  width: 100%;
  padding: 1rem 1.25rem 1rem 3rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  font-size: 1rem;
  color: var(--text-primary);
  transition: all 0.3s;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 20px var(--accent-color-glow);
  background: rgba(255, 255, 255, 0.05);
}

.search-icon {
  position: absolute;
  left: 1.125rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.3s;
}

.search-input:focus + .search-icon {
  color: var(--accent-color);
}

/* Filters Grid */
.filters-panel {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.filter-label {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Button & Toggles */
.btn-toggle {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-color-focus);
}

.btn-toggle.active {
  background: var(--accent-gradient);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 15px var(--accent-color-glow);
}

/* Main Workspace Grid */
.workspace-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 2rem;
  align-items: start;
}

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

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem;
}

.subject-card {
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: relative;
  overflow: hidden;
}

.subject-badge {
  align-self: flex-start;
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.subject-code {
  font-family: var(--font-family-display);
  font-size: 0.875rem;
  color: var(--accent-color);
  font-weight: 600;
}

.subject-title {
  font-size: 1.35rem;
  line-height: 1.25;
}

.subject-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  flex-grow: 1;
}

.subject-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.btn-action {
  flex: 1;
  padding: 0.65rem;
  text-align: center;
  border-radius: var(--border-radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn-action-primary {
  background: var(--accent-gradient);
  border: 1px solid transparent;
  color: #fff;
}

.btn-action-primary:hover {
  box-shadow: 0 4px 15px var(--accent-color-glow);
  opacity: 0.95;
}

.btn-action-secondary {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
}

.btn-action-secondary:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-color-focus);
}

/* Sidebar Info Card */
.sidebar-panel {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar-title {
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sidebar-item {
  display: flex;
  gap: 0.75rem;
}

.sidebar-bullet {
  width: 6px;
  height: 6px;
  background: var(--accent-color);
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
  box-shadow: 0 0 8px var(--accent-color);
}

.sidebar-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* Progress Tracker Dashboard Widget */
.progress-panel {
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.progress-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.progress-title {
  font-size: 1rem;
  font-weight: 600;
}

.progress-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.progress-bar-container {
  width: 150px;
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 9999px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent-gradient);
  transition: width 0.4s ease;
}

/* --- Paper Simulator Modal --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(5, 7, 12, 0.85);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.25s ease-out;
}

.modal-container {
  width: 100%;
  max-width: 850px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-header {
  padding: 1.25rem 1.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  background: rgba(17, 24, 39, 0.9);
}

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

.btn-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color 0.2s;
  padding: 0.25rem;
}

.btn-close:hover {
  color: var(--text-primary);
}

.modal-body-scrollable {
  flex-grow: 1;
  overflow-y: auto;
  padding: 2rem;
  background: var(--bg-surface-solid);
}

/* RGPV Exam Paper Theme Styling */
.rgpv-paper {
  background: #FFF;
  color: #111827;
  padding: 2.5rem;
  border-radius: var(--border-radius-sm);
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
  font-family: 'Times New Roman', Times, serif;
  position: relative;
  overflow: hidden;
  border: 1px solid #D1D5DB;
}

/* RGPV Paper watermark */
.rgpv-paper::before {
  content: "R G P V";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-45deg);
  font-size: 8rem;
  font-weight: 800;
  color: rgba(17, 24, 39, 0.03);
  pointer-events: none;
  user-select: none;
  letter-spacing: 1.5rem;
  z-index: 0;
}

.rgpv-header {
  text-align: center;
  border-bottom: 2px solid #000;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  position: relative;
  z-index: 1;
}

.rgpv-univ-name {
  font-size: 1.5rem;
  font-weight: bold;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.rgpv-exam-details {
  font-size: 1.1rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.rgpv-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 1rem;
  font-weight: bold;
}

.rgpv-roll-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.rgpv-roll-cell {
  width: 25px;
  height: 25px;
  border: 1.5px solid #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
}

.rgpv-instructions {
  border: 1.5px solid #000;
  padding: 0.75rem 1rem;
  margin-bottom: 2rem;
  font-size: 0.9rem;
  line-height: 1.4;
  position: relative;
  z-index: 1;
}

.rgpv-instructions-title {
  font-weight: bold;
  margin-bottom: 0.35rem;
}

.rgpv-question-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: relative;
  z-index: 1;
}

.rgpv-q-block {
  border-bottom: 1px dashed #9CA3AF;
  padding-bottom: 1.25rem;
}

.rgpv-q-block:last-child {
  border-bottom: none;
}

.rgpv-q-title {
  display: flex;
  justify-content: space-between;
  font-weight: bold;
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

.rgpv-parts-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-left: 1.5rem;
}

.rgpv-part-item {
  display: flex;
  justify-content: space-between;
  font-size: 1rem;
}

.rgpv-or-divider {
  text-align: center;
  font-weight: bold;
  font-size: 1.1rem;
  margin: 1rem 0;
  text-transform: uppercase;
  color: #000;
  position: relative;
}

.rgpv-or-divider::before,
.rgpv-or-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 45%;
  height: 1.5px;
  background: #000;
}

.rgpv-or-divider::before { left: 0; }
.rgpv-or-divider::after { right: 0; }

/* Interactive Solved Mode Toggles */
.practice-mode-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  background: rgba(139, 92, 246, 0.1);
  color: var(--accent-color);
  font-weight: 600;
  margin-top: 0.5rem;
}

.practice-check-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  background: #E5E7EB;
  border: 1px solid #D1D5DB;
  color: #374151;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-family-sans);
}

.practice-check-btn:hover {
  background: #D1D5DB;
}

.practice-check-btn.checked {
  background: #D1FAE5;
  border-color: #A7F3D0;
  color: #065F46;
}

.rgpv-answer-box {
  background: #F8FAFC;
  border-left: 4px solid var(--accent-color);
  border-right: 1px solid #E2E8F0;
  border-top: 1px solid #E2E8F0;
  border-bottom: 1px solid #E2E8F0;
  padding: 1.25rem;
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: #334155;
  border-radius: 8px;
  font-family: var(--font-family-sans);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
  transition: all 0.2s ease-in-out;
}

.rgpv-answer-box:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.rgpv-answer-section {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px dashed #E2E8F0;
}

.rgpv-answer-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.rgpv-answer-label {
  font-weight: 700;
  color: #0F172A;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.075em;
  margin-bottom: 0.5rem;
}

.rgpv-formula-display {
  font-family: 'Consolas', 'Courier New', Courier, monospace;
  color: #059669;
  background: #ECFDF5;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid #A7F3D0;
  display: inline-block;
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 0.25rem;
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: break-word;
}

.rgpv-step-item {
  line-height: 1.6;
  color: #334155;
  margin-bottom: 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
}

.rgpv-step-item:last-child {
  margin-bottom: 0;
}

/* --- Responsive Layout & Print --- */
@media print {
  body {
    background: #FFF !important;
    color: #000 !important;
  }
  .modal-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: auto !important;
    background: #FFF !important;
    padding: 0 !important;
  }
  .modal-container {
    max-height: none !important;
    box-shadow: none !important;
    width: 100% !important;
  }
  .modal-header, .navbar, .filters-panel, .sidebar-panel, .practice-check-btn, .progress-panel, .hero-section {
    display: none !important;
  }
  .rgpv-paper {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  .rgpv-univ-name, .rgpv-exam-details, .rgpv-row {
    color: #000 !important;
  }
  .rgpv-answer-box {
    background: #FFF !important;
    border: 1.5px solid #000 !important;
    border-left-width: 5px !important;
    box-shadow: none !important;
    color: #000 !important;
    font-family: 'Times New Roman', Times, serif !important;
    padding: 0.75rem !important;
    margin-top: 0.5rem !important;
    margin-bottom: 0.5rem !important;
  }
  .rgpv-formula-display {
    background: #FFF !important;
    border: 1px dashed #000 !important;
    color: #000 !important;
    font-family: 'Times New Roman', Times, serif !important;
    padding: 0.25rem 0.5rem !important;
  }
  .rgpv-answer-section {
    border-bottom: 1px dashed #000 !important;
    margin-bottom: 0.5rem !important;
    padding-bottom: 0.5rem !important;
  }
  .rgpv-step-item {
    color: #000 !important;
    white-space: pre-wrap !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
  }
}
