/* Textbook Modal Overlay */
.textbook-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.textbook-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* Navigation & Colors */
.textbook-overlay[data-group="present"] { --accent: #10b981; --accent-glow: rgba(16, 185, 129, 0.2); }
.textbook-overlay[data-group="past"]    { --accent: #8b5cf6; --accent-glow: rgba(139, 92, 246, 0.2); }
.textbook-overlay[data-group="future"]  { --accent: #3b82f6; --accent-glow: rgba(59, 130, 246, 0.2); }

/* Textbook Container */
.textbook-container {
  width: 90%;
  max-width: 1000px;
  height: 85vh;
  background: var(--card-bg, #1e293b);
  border-radius: 24px;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex; /* Sidebar layout */
  overflow: hidden;
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.textbook-overlay.active .textbook-container {
  transform: translateY(0);
}

/* Sidebar Styling */
.textbook-sidebar {
  width: 240px;
  background: rgba(0, 0, 0, 0.2);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  padding: 1.5rem 1rem; /* Reduced padding */
  display: flex;
  flex-direction: column;
}

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

/* Custom Scrollbar for Sidebar */
.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}
.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.sidebar-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  padding-left: 0.5rem;
  background: linear-gradient(135deg, #fff, rgba(255,255,255,0.5));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-group {
  margin-bottom: 1.5rem;
}

.group-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 0.5rem;
  display: block;
}

.nav-item {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.7);
  text-align: left;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 0.2rem;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.nav-item.active {
  background: var(--accent-glow, rgba(96, 165, 250, 0.1));
  color: var(--accent, #60a5fa);
  font-weight: 600;
}

/* Main Area */
.textbook-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.textbook-header {
  padding: 1.5rem 2rem;
  background: rgba(30, 41, 59, 0.5);
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.textbook-title h2 {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0;
  color: var(--accent, #60a5fa);
  transition: color 0.3s;
}

.textbook-close-btn {
  background: none;
  border: none;
  color: var(--text-muted, #94a3b8);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: all 0.2s;
}

.textbook-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Content Area */
.textbook-content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  scroll-behavior: smooth;
}

/* Grammar Cards */
.grammar-section {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.grammar-section h3 {
  font-size: 1.2rem;
  color: var(--text, #f1f5f9);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Formula Builder */
.formula-box {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  margin-bottom: 1rem;
}

.formula-part {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: bold;
  font-family: monospace;
  font-size: 1.1rem;
}

.formula-part.subject { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; }
.formula-part.verb { background: var(--accent-glow, rgba(16, 185, 129, 0.1)); color: var(--accent, #10b981); transition: all 0.3s; }
.formula-part.aux { background: rgba(59, 130, 246, 0.1); color: #60a5fa; }
.formula-part.s    { background: rgba(245, 158, 11, 0.1); color: #f59e0b; border: 1px dashed #f59e0b; }
.formula-part.ing  { background: rgba(139, 92, 246, 0.1); color: #a78bfa; border: 1px dashed #a78bfa; }

/* Usage Cases */
.usage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.usage-card {
  background: rgba(255, 255, 255, 0.02);
  padding: 1rem;
  border-radius: 12px;
  border-left: 3px solid var(--accent, #3b82f6);
  transition: border-color 0.3s;
}

.usage-card h4 {
  margin: 0 0 0.5rem 0;
  color: #fff;
}

.usage-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted, #94a3b8);
}

/* Trap Zone (Errors) */
.trap-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.1);
}

.trap-wrong {
  color: #f87171;
  text-decoration: line-through;
  margin-right: 0.5rem;
}

.trap-correct {
  color: #4ade80;
  font-weight: bold;
}

/* Action Bar */
.textbook-actions {
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  background: rgba(30, 41, 59, 0.5);
}

/* Responsive */
@media (max-width: 992px) {
  .textbook-sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 250px;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(10px);
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 10px 0 30px rgba(0,0,0,0.5);
    padding: 1.5rem 1rem;
  }

  .textbook-sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar-header, .group-label, .nav-item span:not(.icon) {
    display: block; /* Restore display for sidebar */
  }

  .nav-item {
      text-align: left;
      padding: 0.8rem;
  }

  /* Hamburger Menu Button */
  .textbook-menu-toggle {
    display: block;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    margin-right: 1rem;
  }
}

@media (min-width: 993px) {
  .textbook-menu-toggle {
    display: none;
  }
}

@media (max-width: 768px) {
  .textbook-container {
    width: 100%;
    height: 100%;
    border-radius: 0;
    transform: none;
  }

  .textbook-overlay {
      padding: 0;
      align-items: flex-start; 
  }

  .textbook-header {
      padding: 1rem;
  }

  .textbook-content {
      padding: 1rem;
  }
  
  .mode-toggle-container {
      gap: 5px;
      padding: 3px 6px;
  }
  
  .mode-label {
      font-size: 0.65rem;
      min-width: 30px;
  }
  
  .mode-slider {
      width: 40px;
  }
}

/* Pro Mode Toggle */
.pro-toggle-container {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-right: 1rem;
}

.pro-label {
  color: #fbbf24;
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.3);
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
}

.toggle-input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .4s;
  border-radius: 34px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

.toggle-input:checked + .toggle-slider {
  background-color: #fbbf24;
  border-color: #fbbf24;
}

.toggle-input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* Pro Content Styling */
/* Hidden by default unless pro-mode is active on container */
.usage-card.pro {
  display: none; 
  border-left-color: #fbbf24;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.05), rgba(0,0,0,0));
}

.pro-mode-active .usage-card.pro {
  display: block;
  animation: fadeIn 0.5s ease;
}

.usage-card.pro h4 {
  color: #fbbf24;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.usage-card.pro h4::after {
  content: "PRO";
  font-size: 0.6rem;
  background: #fbbf24;
  color: #000;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 800;
}

/* 3-State Mode Slider */
.mode-toggle-container {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px 6px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.mode-slider {
  -webkit-appearance: none;
  width: 60px;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  outline: none;
  margin: 0 5px;
}

.mode-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #94a3b8; /* Base (Grey) */
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

/* Pro State (Thumb Color) */
.mode-slider.state-pro::-webkit-slider-thumb {
  background: #fbbf24; /* Gold */
  box-shadow: 0 0 15px rgba(251, 191, 36, 0.6);
  transform: scale(1.1);
}

/* Super State (Thumb Color) */
.mode-slider.state-super::-webkit-slider-thumb {
  background: #c084fc; /* Purple */
  box-shadow: 0 0 20px rgba(192, 132, 252, 0.8);
  transform: scale(1.3);
}

.mode-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
  transition: color 0.3s;
  min-width: 45px;
  text-align: center;
}

.mode-label.active-base { color: #94a3b8; }
.mode-label.active-pro { color: #fbbf24; text-shadow: 0 0 10px rgba(251, 191, 36, 0.3); }
.mode-label.active-super { color: #c084fc; text-shadow: 0 0 15px rgba(192, 132, 252, 0.5); }

/* Super Content Styling */
.usage-card.super {
  display: none;
  border-left-color: #c084fc;
  background: linear-gradient(135deg, rgba(192, 132, 252, 0.1), rgba(0,0,0,0));
}

.super-mode-active .usage-card.super {
  display: block;
  animation: fadeIn 0.5s ease;
}

.usage-card.super h4 {
  color: #c084fc;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.usage-card.super h4::after {
  content: "SUPER";
  font-size: 0.6rem;
  background: #c084fc;
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
