:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --primary: #38bdf8;
  --primary-hover: #0284c7;
  --accent: #818cf8;
  --success: #34d399;
  --warning: #fbbf24;
  --border-color: #334155;
  --radius: 14px;
  --shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f8fafc;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --accent: #6366f1;
  --success: #10b981;
  --warning: #f59e0b;
  --border-color: #e2e8f0;
  --shadow: 0 4px 15px -2px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

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

/* Header */
.header {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(8px);
}

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

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

.logo-icon {
  font-size: 24px;
  background: rgba(56, 189, 248, 0.15);
  padding: 6px 10px;
  border-radius: 12px;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

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

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 1.1rem;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.2s;
}

.icon-btn:active {
  transform: scale(0.92);
}

/* Main */
.main-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
  width: 100%;
  flex: 1;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.group-card {
  border-left: 4px solid var(--primary);
}

.group-select-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.current-group {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 2px 0;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 600;
}

.badge-subtle {
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary);
}

.badge-online {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-offline {
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.3);
}

/* Live Banner */
.live-banner {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-color);
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--success);
  font-weight: 600;
  margin-bottom: 4px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--success);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.5; }
}

.live-lesson-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.live-lesson-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.progress-bar-container {
  background: var(--bg-hover);
  height: 6px;
  border-radius: 3px;
  margin-top: 8px;
  overflow: hidden;
}

.progress-bar {
  background: linear-gradient(90deg, var(--primary), var(--accent));
  height: 100%;
  width: 0%;
  transition: width 0.3s;
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.2s, transform 0.15s;
}

.btn:active {
  transform: scale(0.95);
}

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

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

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

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* Tabs */
.nav-tabs {
  display: flex;
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: none;
}

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

.tab-btn {
  flex: 1;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.3);
}

/* Tab pane */
.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Schedule List */
.day-block {
  margin-bottom: 20px;
}

.day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-left: 4px;
}

.day-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.day-date {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.lessons-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lesson-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  gap: 14px;
  align-items: center;
  transition: border-color 0.2s, transform 0.15s;
}

.lesson-card.active-lesson {
  border: 2px solid var(--primary);
  background: rgba(56, 189, 248, 0.05);
}

.lesson-time-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 65px;
  text-align: center;
  border-right: 1px solid var(--border-color);
  padding-right: 12px;
}

.lesson-number {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
}

.lesson-time-range {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.lesson-info {
  flex: 1;
}

.lesson-subject {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.3;
}

.lesson-teacher {
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-block;
}

.lesson-teacher:hover {
  color: var(--primary);
  text-decoration: underline;
}

.lesson-badge-box {
  text-align: right;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius);
  color: var(--text-muted);
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

/* Search Box */
.search-box {
  margin-bottom: 16px;
}

.search-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
}

.search-input:focus {
  border-color: var(--primary);
}

.teachers-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.teacher-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.teacher-item:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}

.teacher-detail {
  margin-top: 10px;
}

.teacher-name-title {
  margin: 16px 0;
  font-size: 1.3rem;
}

/* Bells Grid */
.bells-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.bell-card h3 {
  margin-bottom: 12px;
  font-size: 1.1rem;
}

.bell-list {
  list-style: none;
}

.bell-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.bell-list li:last-child {
  border-bottom: none;
}

.pair-num {
  font-weight: 600;
  color: var(--primary);
}

.pair-time {
  color: var(--text-secondary);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  padding: 20px;
}

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

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

.course-section {
  margin-bottom: 18px;
}

.course-header {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.groups-btn-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.grp-choice-btn {
  padding: 10px;
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.grp-choice-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.grp-choice-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Install Banner */
.install-banner {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.install-content {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border-color);
  padding: 16px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-meta {
  margin-top: 4px;
}

.hidden {
  display: none !important;
}

/* Spinner */
.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 30px auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
