/* Swimming Progress Tracker - Modern + Booklet Inspired */
:root {
  --primary: #0EA5E9;
  --primary-dark: #0284C7;
  --primary-light: #E0F2FE;
  --secondary: #06B6D4;
  --accent: #F59E0B;
  --success: #10B981;
  --danger: #EF4444;
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --text: #0F172A;
  --text-muted: #64748B;
  --border: #E2E8F0;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --radius: 12px;
  --font: 'Segoe UI', 'PingFang TC', 'Microsoft JhengHei', system-ui, sans-serif;
}

[data-theme="dark"] {
  --bg: #0F172A;
  --card: #1E293B;
  --text: #F1F5F9;
  --text-muted: #94A3B8;
  --border: #334155;
  --primary-light: #0C4A6E;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* Header */
.app-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.25rem;
}

.logo svg {
  width: 40px;
  height: 40px;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--primary);
  color: white;
}

.btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.5);
  color: white;
}

.btn-outline:hover {
  background: rgba(255,255,255,0.15);
}

.btn-secondary {
  background: var(--text-muted);
}

.btn-success {
  background: var(--success);
}

.btn-danger {
  background: var(--danger);
}

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  background: var(--card);
  padding: 0.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.nav-tab {
  padding: 0.6rem 1.2rem;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.2s;
}

.nav-tab.active {
  background: var(--primary);
  color: white;
}

.nav-tab:hover:not(.active) {
  background: var(--primary-light);
  color: var(--primary-dark);
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Student Grid */
.student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.student-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
  position: relative;
}

.student-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.student-card.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.student-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.student-name {
  font-weight: 600;
  font-size: 1.1rem;
}

.student-meta {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.progress-bar-wrap {
  margin-top: 0.75rem;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  border-radius: 4px;
  transition: width 0.4s;
}

/* Level List */
.level-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.level-item {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
  display: grid;
  grid-template-columns: 70px 1fr auto;
  gap: 1rem;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s;
  border-left: 4px solid transparent;
}

.level-item:hover {
  transform: translateX(4px);
}

.level-item.completed {
  border-left-color: var(--success);
  background: linear-gradient(90deg, rgba(16,185,129,0.08), transparent);
}

.level-item.in-progress {
  border-left-color: var(--accent);
}

.level-badge {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.level-item.completed .level-badge {
  background: var(--success);
  color: white;
}

.level-info h3 {
  font-size: 1rem;
  margin-bottom: 0.2rem;
}

.level-info p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.level-status {
  text-align: right;
  font-size: 0.85rem;
}

/* Level Detail */
.level-detail-header {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.level-illustration {
  width: 160px;
  height: 120px;
  background: linear-gradient(135deg, #E0F2FE, #BAE6FD);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}

.level-meta {
  flex: 1;
  min-width: 250px;
}

.level-meta h2 {
  font-size: 1.4rem;
  margin-bottom: 0.5rem;
}

.skill-box {
  background: var(--primary-light);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin: 0.75rem 0;
}

.aids-tag {
  display: inline-block;
  background: var(--accent);
  color: white;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.8rem;
  margin-right: 0.4rem;
  margin-top: 0.4rem;
}

/* Progress Table */
.progress-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.progress-table th,
.progress-table td {
  border: 1px solid var(--border);
  padding: 0.5rem;
  text-align: center;
}

.progress-table th {
  background: var(--primary);
  color: white;
  font-weight: 500;
}

.progress-table tr:nth-child(even) {
  background: var(--bg);
}

.progress-table input[type="date"],
.progress-table input[type="text"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem;
  font-size: 0.85rem;
  background: var(--card);
  color: var(--text);
}

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

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--card);
  color: var(--text);
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.modal {
  background: var(--card);
  border-radius: var(--radius);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

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

.modal-header h2 {
  font-size: 1.25rem;
}

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

/* Report */
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.chart-container {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

.chart-container h3 {
  margin-bottom: 1rem;
  font-size: 1rem;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state svg {
  width: 80px;
  height: 80px;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Filters */
.filters {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.filters select,
.filters input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font-size: 0.9rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--text);
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 300;
  animation: slideIn 0.3s ease;
}

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

/* Print */
@media print {
  .app-header, .nav-tabs, .header-actions, .btn, .filters {
    display: none !important;
  }
  .card, .level-item {
    box-shadow: none;
    border: 1px solid #ddd;
  }
  body {
    background: white;
  }
}

.svg-chart svg { width: 100%; height: auto; display: block; color: var(--text); }

/* Responsive */
@media (max-width: 640px) {
  .form-row {
    grid-template-columns: 1fr;
  }
  .level-item {
    grid-template-columns: 50px 1fr;
  }
  .level-status {
    grid-column: 1 / -1;
    text-align: left;
    margin-top: 0.5rem;
  }
  .app-header {
    padding: 0.75rem 1rem;
  }
  .logo {
    font-size: 1rem;
  }
}
