@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #131a2c;
  --bg-tertiary: #1c253d;
  --accent-purple: #8b5cf6;
  --accent-blue: #3b82f6;
  --accent-pink: #ec4899;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: rgba(255, 255, 255, 0.08);
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --glass-bg: rgba(19, 26, 44, 0.6);
  --glass-border: rgba(255, 255, 255, 0.05);
  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --radius: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.6;
  overflow-x: hidden;
  background-image: 
    radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(59, 130, 246, 0.15) 0px, transparent 50%);
  background-attachment: fixed;
}

header {
  padding: 2rem 1.5rem;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  background: rgba(11, 15, 25, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

h1 {
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #fff 30%, var(--accent-purple) 70%, var(--accent-blue) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 2.5rem;
}

main {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

/* Tabs Navigation */
.tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 2rem;
  background: var(--bg-secondary);
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  overflow-x: auto;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  flex: 0 0 auto;
  padding: 12px 24px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
  color: var(--text-main);
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

/* Subject Panel */
.panel {
  display: none;
  animation: fadeIn 0.4s ease;
}

.panel.active {
  display: block;
}

/* Dashboard Summary Card */
.dashboard-card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 2.5rem;
  margin-bottom: 2rem;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
  align-items: center;
}

@media(max-width: 768px) {
  .dashboard-card {
    grid-template-columns: 1fr;
  }
}

.dashboard-card h2 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.dashboard-card p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.stat-item {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.2rem;
  text-align: center;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent-purple);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

/* Quiz Controls */
.quiz-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn {
  padding: 14px 28px;
  border-radius: 10px;
  border: none;
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
  color: var(--text-main);
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(139, 92, 246, 0.5);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-2px);
}

/* Quiz Interface */
.quiz-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 2.5rem;
  margin-top: 1.5rem;
  box-shadow: var(--shadow);
  display: none;
}

.quiz-container.active {
  display: block;
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.2rem;
  margin-bottom: 1.8rem;
}

.question-counter {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 500;
}

.quiz-timer {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error);
  padding: 6px 12px;
  border-radius: 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 6px;
}

.question-text {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 2rem;
  white-space: pre-wrap;
}

.question-text pre {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.2rem;
  margin-top: 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  overflow-x: auto;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.option-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1rem 1.5rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.option-card:hover {
  background: rgba(255, 255, 255, 0.02);
  border-color: var(--accent-purple);
  transform: translateX(4px);
}

.option-card.selected {
  border-color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.1);
}

.option-card.correct {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.15);
  color: #a7f3d0;
}

.option-card.incorrect {
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.option-letter {
  width: 28px;
  height: 28px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
}

.option-card.selected .option-letter {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
}

.option-card.correct .option-letter {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.option-card.incorrect .option-letter {
  background: var(--error);
  color: #fff;
  border-color: var(--error);
}

.explanation-card {
  background: rgba(139, 92, 246, 0.08);
  border-left: 4px solid var(--accent-purple);
  border-radius: 0 8px 8px 0;
  padding: 1.2rem 1.5rem;
  margin-bottom: 2rem;
  display: none;
  animation: slideDown 0.3s ease;
}

.explanation-card.active {
  display: block;
}

.explanation-title {
  font-weight: 700;
  color: var(--accent-purple);
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.quiz-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Results panel */
.results-container {
  display: none;
  text-align: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 3rem;
  margin-top: 1.5rem;
  box-shadow: var(--shadow);
  animation: fadeIn 0.4s ease;
}

.results-container.active {
  display: block;
}

.score-circle {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 8px solid var(--accent-purple);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 2rem;
  background: rgba(139, 92, 246, 0.05);
}

.score-value {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
}

.score-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 4px;
}

.results-title {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.8rem;
}

.results-desc {
  color: var(--text-muted);
  max-width: 500px;
  margin: 0 auto 2rem;
}

/* Fortune's Algorithm Visualizer Card */
.visualizer-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 2rem;
  margin-top: 2rem;
  box-shadow: var(--shadow);
}

.visualizer-header {
  margin-bottom: 1.5rem;
}

.visualizer-desc {
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.visualizer-container {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}

@media(max-width: 900px) {
  .visualizer-container {
    grid-template-columns: 1fr;
  }
}

.canvas-wrapper {
  background: #080c14;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  padding: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

canvas {
  max-width: 100%;
  background: #080c14;
  display: block;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
}

.slider-value {
  color: var(--accent-purple);
  font-family: 'JetBrains Mono', monospace;
}

input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  background: var(--bg-tertiary);
  height: 8px;
  border-radius: 4px;
  outline: none;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-purple);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
}

input[type=range]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.points-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.points-table th, .points-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.points-table th {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
}

.points-table td {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
}

.active-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; max-height: 0; overflow: hidden; }
  to { opacity: 1; max-height: 200px; }
}

/* Custom visual styles for elements */
.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

.badge-purple {
  background: rgba(139, 92, 246, 0.15);
  color: #c084fc;
  border-color: rgba(139, 92, 246, 0.3);
}

.badge-blue {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.3);
}

.badge-pink {
  background: rgba(236, 72, 153, 0.15);
  color: #f472b6;
  border-color: rgba(236, 72, 153, 0.3);
}

/* AI Tutor Chat Sidebar */
.chat-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  box-shadow: -4px 0 30px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: var(--transition);
}

.chat-sidebar.active {
  transform: translateX(0);
}

.chat-header {
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(19, 26, 44, 0.8);
  backdrop-filter: blur(10px);
}

.chat-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff, var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.close-chat-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  transition: var(--transition);
}

.close-chat-btn:hover {
  color: var(--text-main);
  transform: scale(1.1);
}

.api-key-config {
  padding: 1rem 1.5rem;
  background: rgba(11, 15, 25, 0.4);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.api-key-config label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.api-key-config input {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text-main);
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
}

.api-key-config input:focus {
  outline: none;
  border-color: var(--accent-purple);
}

.api-key-status {
  font-size: 0.75rem;
  color: var(--error);
}

.api-key-status.success {
  color: var(--success);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: rgba(8, 12, 20, 0.3);
}

.chat-msg {
  padding: 10px 14px;
  border-radius: 12px;
  max-width: 85%;
  font-size: 0.95rem;
  line-height: 1.4;
  word-break: break-word;
}

.chat-msg.system {
  background: rgba(245, 158, 11, 0.08);
  border-left: 3px solid var(--warning);
  color: #fde047;
  border-radius: 6px;
  font-size: 0.85rem;
  max-width: 100%;
}

.chat-msg.user {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
}

.chat-msg.assistant {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}

.chat-msg pre {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px;
  margin-top: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  overflow-x: auto;
}

.chat-msg code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  background: rgba(255,255,255,0.08);
  padding: 2px 4px;
  border-radius: 4px;
}

.chat-input-area {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  display: flex;
  gap: 10px;
  align-items: center;
}

.chat-input-area textarea {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text-main);
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  resize: none;
}

.chat-input-area textarea:focus {
  outline: none;
  border-color: var(--accent-purple);
}

.btn-send {
  height: 42px;
  padding: 0 16px;
}

.floating-chat-btn {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 99;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
  border: none;
  color: #fff;
  padding: 12px 20px;
  border-radius: 30px;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
}

.floating-chat-btn:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 6px 24px rgba(139, 92, 246, 0.6);
}

/* Rich Question Types styling */
.gap-select, .match-select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 4px 8px;
  border-radius: 6px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition);
  margin: 2px 4px;
}

.gap-select:focus, .match-select:focus {
  border-color: var(--accent-purple);
}

.gap-select.correct, .match-select.correct {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.15);
  color: #a7f3d0;
}

.gap-select.incorrect, .match-select.incorrect {
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.match-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
  width: 100%;
}

.match-item {
  font-weight: 600;
  font-size: 1rem;
}

.match-select {
  width: 60%;
  max-width: 300px;
}

.option-card input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent-blue);
}

.btn-ask-ai {
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: #c084fc;
}

.btn-ask-ai:hover {
  background: rgba(139, 92, 246, 0.2);
  transform: translateY(-2px);
}

/* Study Guide Modal */
.study-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(8, 12, 20, 0.85);
  backdrop-filter: blur(12px);
  z-index: 1100;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.study-modal.active {
  display: flex;
  opacity: 1;
}

.study-modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 100%;
  max-width: 900px;
  max-height: 85vh;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  animation: modalEnter 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.study-modal-header {
  padding: 1.2rem 2rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(19, 26, 44, 0.4);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}

.study-modal-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #fff, var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.close-study-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: 8px;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.close-study-btn:hover {
  background: var(--error);
  border-color: var(--error);
  color: #fff;
  transform: translateY(-1px);
}

.study-modal-body {
  padding: 2.5rem 2rem;
  overflow-y: auto;
  flex: 1;
  color: var(--text-main);
  line-height: 1.7;
}

.study-section h3 {
  font-size: 1.6rem;
  margin-bottom: 1.5rem;
  color: #fff;
  border-bottom: 2px solid rgba(139, 92, 246, 0.3);
  padding-bottom: 8px;
}

.study-section h4 {
  font-size: 1.2rem;
  margin: 1.8rem 0 0.8rem;
  color: var(--accent-blue);
  font-weight: 600;
}

.study-section p {
  margin-bottom: 1rem;
  color: var(--text-muted);
}

.study-section ul, .study-section ol {
  margin-bottom: 1.2rem;
  padding-left: 1.5rem;
}

.study-section li {
  margin-bottom: 0.6rem;
  color: var(--text-muted);
}

.study-section pre {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  overflow-x: auto;
}

.study-section code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  color: #a7f3d0;
  background: rgba(16, 185, 129, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
}

.study-section pre code {
  color: var(--text-main);
  background: transparent;
  padding: 0;
}

.study-section table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}

.study-section table th, .study-section table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}

.study-section table th {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
}

.study-section table td {
  font-size: 0.95rem;
}

/* Layout Shifting on Desktop (min-width: 901px) when Chat is Open */
@media(min-width: 901px) {
  body {
    transition: padding-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  body.chat-active {
    padding-right: 380px;
  }
  header {
    transition: padding-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  body.chat-active header {
    padding-right: 380px;
  }
}

/* Floating Chat Button Animation */
body.chat-active .floating-chat-btn {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

/* Responsive sidebar chat width on mobile */
@media(max-width: 480px) {
  .chat-sidebar {
    width: 100%;
  }
}

/* Responsive Header and Padding Adjustments on Mobile */
@media(max-width: 768px) {
  header {
    padding: 1.2rem 1rem;
  }
  
  .header-container {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
  
  h1 {
    font-size: 1.6rem;
    justify-content: center;
    text-align: center;
  }
  
  .logo-icon {
    font-size: 2rem;
  }
  
  main {
    margin: 1rem auto;
    padding: 0 1rem;
  }

  /* Stack Subject Navigation Tabs Vertically to fit screen without scrolling */
  .tabs {
    flex-direction: column;
    overflow-x: visible;
    white-space: normal;
    gap: 8px;
    padding: 8px;
  }
  
  .tab-btn {
    width: 100%;
    justify-content: flex-start;
    padding: 12px 18px;
    font-size: 0.95rem;
    flex: 1 1 auto;
  }
  
  .dashboard-card {
    padding: 1.5rem;
    gap: 1.2rem;
  }
  
  .dashboard-card h2 {
    font-size: 1.4rem;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }
  
  .quiz-actions {
    flex-direction: column;
    width: 100%;
  }
  
  .quiz-actions .btn {
    width: 100%;
  }

  /* Stack quiz footer buttons vertically (reversed) so Sprawdź / Następne is on top */
  .quiz-footer {
    flex-direction: column-reverse;
    gap: 10px;
    align-items: stretch;
  }

  .quiz-footer .btn {
    width: 100%;
    margin-right: 0;
  }

  .study-modal {
    padding: 0.5rem;
  }
  
  .study-modal-content {
    max-height: 95vh;
  }
  
  .study-modal-header {
    padding: 1rem;
  }
  
  .study-modal-body {
    padding: 1.2rem 1rem;
  }

  .study-section h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
  }

  /* Table responsive styling to prevent horizontal page overflow */
  .points-table, .study-section table {
    display: block;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
  }
}

