/* ==========================================================================
   Örtmenim Duolingo-Style Gamified Learning Platform - Core Design System
   ========================================================================== */

:root {
  --font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  
  /* Brand Palette (Duolingo Vibrant Colors) */
  --color-green: #58cc02;
  --color-green-dark: #46a302;
  --color-blue: #1cb0f6;
  --color-blue-dark: #1899d6;
  --color-purple: #ce82ff;
  --color-purple-dark: #af67db;
  --color-orange: #ff9600;
  --color-orange-dark: #e08400;
  --color-red: #ff4b4b;
  --color-red-dark: #ea2b2b;
  --color-yellow: #ffc800;
  --color-gray: #e5e5e5;
  --color-gray-dark: #afafaf;
  --color-dark: #3c3c3c;
  
  /* League Tier Colors */
  --league-bronz: #cd7f32;
  --league-gumus: #c0c0c0;
  --league-altin: #ffd700;
  --league-safir: #0f52ba;
  --league-yakut: #e0115f;
  --league-elmas: #b9f2ff;

  /* Theme Colors */
  --bg-primary: #f7f9fa;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --text-main: #3c3c3c;
  --text-muted: #777777;
  --border-color: #e5e5e5;
  
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  
  --shadow-3d-green: 0 4px 0 var(--color-green-dark);
  --shadow-3d-blue: 0 4px 0 var(--color-blue-dark);
  --shadow-3d-gray: 0 4px 0 #cecece;
}

[data-theme="dark"] {
  --bg-primary: #131923;
  --bg-card: #1f2937;
  --bg-sidebar: #1f2937;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --border-color: #374151;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* App Layout */
#app {
  display: flex;
  flex: 1;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 250px;
  background-color: var(--bg-sidebar);
  border-right: 2px solid var(--border-color);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  margin-bottom: 32px;
  padding-left: 8px;
}

.brand-logo .logo-img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-green);
  animation: bounce 2s infinite ease-in-out;
}

.brand-logo .logo-text {
  font-size: 26px;
  font-weight: 800;
  color: var(--color-green);
  letter-spacing: -0.5px;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  list-style: none;
}

.nav-item button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.nav-item button:hover {
  background-color: rgba(88, 204, 2, 0.08);
  color: var(--color-green);
}

.nav-item button.active {
  background-color: rgba(88, 204, 2, 0.15);
  border-color: var(--color-green);
  color: var(--color-green);
}

.nav-item button .nav-icon {
  font-size: 22px;
}

/* Main Content Area */
.main-wrapper {
  margin-left: 250px;
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: calc(100vw - 250px);
}

/* Topbar */
.topbar {
  height: 70px;
  background-color: var(--bg-sidebar);
  border-bottom: 2px solid var(--border-color);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
}

.grade-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.2s;
  color: var(--text-main);
}

.grade-selector:hover {
  transform: scale(1.03);
}

.stats-bar {
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 15px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
}

.stat-chip.streak { color: var(--color-orange); }
.stat-chip.gems { color: var(--color-blue); }
.stat-chip.hearts { color: var(--color-red); }
.stat-chip.xp { color: var(--color-purple); }
.stat-chip.league { color: var(--league-altin); }

.icon-btn {
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.2s ease;
  color: var(--text-main);
}

.icon-btn:hover {
  transform: scale(1.1);
}

.user-action-btn {
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: none;
  font-weight: 800;
  cursor: pointer;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.15s ease;
}

.btn-primary {
  background-color: var(--color-green);
  color: white;
  box-shadow: var(--shadow-3d-green);
}

.btn-primary:active {
  transform: translateY(4px);
  box-shadow: none;
}

.btn-secondary {
  background-color: var(--color-blue);
  color: white;
  box-shadow: var(--shadow-3d-blue);
}

.btn-secondary:active {
  transform: translateY(4px);
  box-shadow: none;
}

/* View Sections */
.view-container {
  padding: 32px;
  display: flex;
  justify-content: center;
  flex: 1;
}

.path-view {
  width: 100%;
  max-width: 800px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* 3D Flashcards Flip Component */
.flashcard-3d-container {
  perspective: 1000px;
  width: 100%;
  height: 240px;
  cursor: pointer;
}

.flashcard-3d {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.flashcard-3d.flipped {
  transform: rotateY(180deg);
}

.flashcard-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  padding: 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  border: 2px solid var(--border-color);
  background: var(--bg-card);
}

.flashcard-front {
  background: linear-gradient(135deg, rgba(28,176,246,0.1), rgba(88,204,2,0.1));
}

.flashcard-back {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, rgba(206,130,255,0.15), rgba(255,150,0,0.15));
}

/* Badge Showcase Grid */
.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.badge-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 10px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  text-align: center;
  transition: all 0.2s ease;
}

.badge-card.unlocked {
  border-color: var(--color-yellow);
  box-shadow: 0 4px 12px rgba(255, 200, 0, 0.3);
}

.badge-card.locked {
  filter: grayscale(1);
  opacity: 0.5;
}

.badge-icon {
  font-size: 36px;
  margin-bottom: 6px;
}

.badge-title {
  font-size: 13px;
  font-weight: 800;
}

/* Streak Reminder Banner */
.streak-banner {
  background: linear-gradient(135deg, #ff9600, #ea580c);
  color: white;
  padding: 16px 24px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 800;
  box-shadow: 0 6px 12px rgba(234,88,12,0.3);
}

/* Subject Tabs */
.subject-tabs {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
  scrollbar-width: none;
}

.subject-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  color: var(--text-main);
}

.subject-tab.active {
  border-color: var(--tab-color, var(--color-green));
  background-color: rgba(88, 204, 2, 0.1);
  color: var(--tab-color, var(--color-green));
}

/* Unit Banner */
.unit-card {
  background: linear-gradient(135deg, var(--unit-color, var(--color-green)), #2e7d32);
  color: white;
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 8px 16px rgba(0,0,0,0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.unit-info h3 {
  font-size: 24px;
  margin-bottom: 6px;
}

/* Nodes & Visual Path Connector Lines */
.path-nodes {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  margin: 20px 0 60px;
  position: relative;
}

.path-connector-line {
  position: absolute;
  top: 40px;
  width: 2px;
  height: calc(100% - 80px);
  border-left: 3px dashed var(--border-color);
  z-index: 1;
}

.node-btn {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: none;
  background-color: var(--node-color, var(--color-green));
  box-shadow: 0 8px 0 var(--node-dark-color, var(--color-green-dark));
  color: white;
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  z-index: 2;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.node-btn:hover:not(:disabled) {
  transform: scale(1.08);
}

.node-btn.locked {
  background-color: #e5e5e5;
  box-shadow: 0 8px 0 #afafaf;
  color: #afafaf;
  cursor: not-allowed;
}

.node-btn.completed::after {
  content: '✓';
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: var(--color-yellow);
  color: #3c3c3c;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 16px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--bg-card);
}

.node-pos-0 { transform: translateX(0px); }
.node-pos-1 { transform: translateX(50px); }
.node-pos-2 { transform: translateX(80px); }
.node-pos-3 { transform: translateX(50px); }
.node-pos-4 { transform: translateX(0px); }
.node-pos-5 { transform: translateX(-50px); }
.node-pos-6 { transform: translateX(-80px); }
.node-pos-7 { transform: translateX(-50px); }

/* Weekly XP Bar Chart */
.weekly-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 150px;
  padding: 20px 10px 0;
  gap: 12px;
  border-bottom: 2px solid var(--border-color);
}

.bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.bar-fill {
  width: 100%;
  background: linear-gradient(180deg, var(--color-purple), #8b5cf6);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  min-height: 10px;
  transition: height 0.5s ease;
}

.bar-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

/* Lesson & Question Screen */
.lesson-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: var(--bg-card);
  z-index: 500;
  display: flex;
  flex-direction: column;
}

.lesson-header {
  padding: 20px 40px;
  display: flex;
  align-items: center;
  gap: 24px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.close-lesson-btn {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-muted);
  cursor: pointer;
}

.progress-bar-container {
  flex: 1;
  height: 16px;
  background-color: var(--border-color);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background-color: var(--color-green);
  width: 0%;
  transition: width 0.3s ease;
  border-radius: var(--radius-full);
}

.lesson-body {
  flex: 1;
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.question-prompt {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 24px;
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-main);
}

.tts-btn {
  background: rgba(28, 176, 246, 0.15);
  border: 2px solid var(--color-blue);
  color: var(--color-blue);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.option-card {
  border: 2px solid var(--border-color);
  box-shadow: 0 4px 0 var(--border-color);
  padding: 18px 24px;
  border-radius: var(--radius-md);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  background: var(--bg-card);
  color: var(--text-main);
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.option-card:hover {
  background-color: rgba(28, 176, 246, 0.05);
  border-color: var(--color-blue);
}

.option-card.selected {
  border-color: var(--color-blue);
  background-color: rgba(28, 176, 246, 0.15);
  box-shadow: 0 4px 0 var(--color-blue-dark);
}

.lesson-footer {
  border-top: 2px solid var(--border-color);
  padding: 24px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-card);
}

.lesson-footer.correct {
  background-color: #d7ffb8;
  border-top-color: #58cc02;
  color: #2e7d32;
}

.lesson-footer.incorrect {
  background-color: #ffdfe0;
  border-top-color: #ff4b4b;
  color: #ea2b2b;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 460px;
  padding: 32px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  transform: translateY(20px);
  transition: transform 0.25s ease;
  color: var(--text-main);
}

.modal-backdrop.active .modal-card {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-header h3 {
  font-size: 22px;
  font-weight: 800;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display.block;
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 14px;
}

.form-control {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 16px;
  outline: none;
  background: var(--bg-primary);
  color: var(--text-main);
}

.form-control:focus {
  border-color: var(--color-blue);
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: 60px;
    bottom: 0;
    top: auto;
    flex-direction: row;
    padding: 0;
    border-right: none;
    border-top: 2px solid var(--border-color);
    justify-content: space-around;
  }
  .brand-logo { display: none; }
  .nav-menu { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav-item button { flex-direction: column; gap: 4px; padding: 8px; font-size: 11px; }
  .main-wrapper { margin-left: 0; max-width: 100vw; padding-bottom: 70px; }
  .topbar { padding: 0 16px; }
}
