/* ============================================================
   Learn English App - Modern Responsive Theme
   Optimized for Azure Static Web Apps
   ============================================================ */
:root {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  --primary-dark: #075985;
  --secondary: #10b981;
  --secondary-light: #d1fae5;
  --accent: #f59e0b;
  --accent-light: #fef3c7;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-focus: #38bdf8;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg-main: #090d16;
  --bg-card: #131b2e;
  --bg-card-subtle: #1e293b;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --primary-light: #0c4a6e;
  --secondary-light: #064e3b;
  --accent-light: #78350f;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
}

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

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  transition: var(--transition);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}

.header-container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: var(--shadow-sm);
}

.brand-title h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.brand-title p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.nav-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.nav-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.theme-toggle-btn {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: var(--transition);
}

.theme-toggle-btn:hover {
  background: var(--primary-light);
}

/* Audio Controls Bar */
.audio-bar {
  background: var(--bg-card-subtle);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
  padding: 6px 20px;
}

.audio-bar-inner {
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.audio-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.audio-status .pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--secondary);
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.audio-settings {
  display: flex;
  align-items: center;
  gap: 14px;
}

.audio-settings label {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.audio-settings select {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.82rem;
}

/* Main Container */
.main-wrapper {
  max-width: 1300px;
  width: 100%;
  margin: 20px auto;
  padding: 0 20px;
  flex: 1;
}

/* Week Days Tabs */
.days-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 20px;
  scrollbar-width: thin;
}

.day-tab {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  min-width: 140px;
  transition: var(--transition);
  text-align: left;
  position: relative;
}

.day-tab:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.day-tab.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-color: var(--primary-dark);
  box-shadow: var(--shadow-md);
}

.day-tab .tab-date {
  font-size: 0.75rem;
  font-weight: 700;
  opacity: 0.85;
}

.day-tab .tab-day {
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.day-tab .tab-topic {
  font-size: 0.76rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.9;
}

.day-tab.active .tab-topic {
  color: #e0f2fe;
}

/* Search Box */
.search-container {
  margin-bottom: 20px;
}

.search-input-wrap {
  position: relative;
  max-width: 600px;
}

.search-input-wrap input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.search-input-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.search-input-wrap .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

/* Lesson Hero */
.lesson-hero {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 20px;
}

.hero-content {
  flex: 1;
  min-width: 280px;
}

.hero-badge-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-green { background: var(--secondary-light); color: var(--secondary); }
.badge-orange { background: var(--accent-light); color: #b45309; }

.lesson-hero h2 {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
}

.lesson-hero .hero-sub {
  font-size: 1.05rem;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 10px;
}

.lesson-hero .hero-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 220px;
}

.btn-pdf {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 9px 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: var(--transition);
  cursor: pointer;
}

.btn-pdf:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-pdf .icon {
  font-size: 1.1rem;
}

/* Grid Sections */
.lesson-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 24px;
}

.col-8 { grid-column: span 8; }
.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }
.col-12 { grid-column: span 12; }

@media (max-width: 960px) {
  .col-8, .col-4, .col-6 { grid-column: span 12; }
}

/* Card Component */
.content-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  transition: var(--transition);
}

.content-card:hover {
  box-shadow: var(--shadow-md);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}

.card-title .title-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.title-icon {
  font-size: 1.25rem;
}

/* Pronunciation Trainer */
.pron-box-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 600px) {
  .pron-box-wrap { grid-template-columns: 1fr; }
}

.sound-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
}

.sound-card .ipa-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.word-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.word-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.word-pill:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  transform: scale(1.04);
}

.sound-tip {
  background: var(--primary-light);
  color: var(--text-main);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  border-left: 4px solid var(--primary);
}

/* Dialogue Box */
.dialogue-timeline {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

.chat-bubble {
  display: flex;
  gap: 12px;
  max-width: 90%;
}

.chat-bubble.speaker-a {
  align-self: flex-start;
}

.chat-bubble.speaker-b {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.bubble-content {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 10px 14px;
  position: relative;
}

.speaker-a .bubble-content {
  border-top-left-radius: 2px;
}

.speaker-b .bubble-content {
  background: var(--primary-light);
  border-color: rgba(2, 132, 199, 0.2);
  border-top-right-radius: 2px;
}

.bubble-speaker {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.bubble-text {
  font-size: 0.92rem;
  color: var(--text-main);
}

.bubble-actions {
  margin-top: 4px;
  display: flex;
  justify-content: flex-end;
}

.btn-speak-mini {
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: var(--transition);
}

.btn-speak-mini:hover {
  background: rgba(2, 132, 199, 0.15);
}

.dialogue-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

.btn-play-all {
  background: var(--secondary);
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}

.btn-play-all:hover {
  background: #059669;
  transform: translateY(-1px);
}

/* Vocabulary Table */
.vocab-table-wrap {
  overflow-x: auto;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.custom-table th {
  background: var(--bg-card-subtle);
  color: var(--text-muted);
  font-weight: 700;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border-color);
}

.custom-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
}

.custom-table tr:hover td {
  background: var(--bg-card-subtle);
}

.vocab-word-cell {
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.vocab-ipa {
  font-family: monospace;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.example-sentence {
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.84rem;
  margin-top: 2px;
}

/* Sentence Patterns & Collocations */
.pattern-item {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: var(--transition);
}

.pattern-item:hover {
  border-color: var(--primary);
}

.pattern-en {
  font-weight: 600;
  font-size: 0.94rem;
  color: var(--text-main);
}

.pattern-vi {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Objectives & Warmup list */
.bullet-list {
  list-style: none;
}

.bullet-list li {
  position: relative;
  padding-left: 24px;
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.bullet-list li::before {
  content: "✔";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--secondary);
  font-weight: bold;
}

.warmup-list li::before {
  content: "❓";
}

.discussion-list li::before {
  content: "💡";
}

/* Week 30 Review Page */
.review-card {
  border-left: 4px solid var(--primary);
  margin-bottom: 20px;
}

/* PDF Modal */
.modal-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  padding: 20px;
}

.modal-backdrop.active {
  display: flex;
}

.modal-window {
  background: var(--bg-card);
  width: 100%;
  max-width: 1000px;
  height: 85vh;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

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

.modal-body {
  flex: 1;
  background: #2d3748;
}

.modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Footer */
.app-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 20px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 40px;
}

.footer-links {
  margin-top: 6px;
  display: flex;
  justify-content: center;
  gap: 16px;
}

.footer-links a {
  color: var(--primary);
  text-decoration: none;
}

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

.fade-in {
  animation: fadeIn 0.3s ease-in-out;
}
