/* FlashVocab — Mobile-first responsive design */
:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --warning: #f59e0b;
  --border: #475569;
  --radius: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Navigation */
nav {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

nav .brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  margin-right: auto;
  display: flex;
  align-items: center;
}

.brand-icon {
  width: 1.4rem;
  height: 1.4rem;
  margin-right: 0.35rem;
  flex-shrink: 0;
}

.login-logo {
  display: block;
  width: 4rem;
  height: 4rem;
  margin: 0 auto 1rem;
}

nav a {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
}

nav a:hover, nav a.active {
  color: var(--text);
  background: var(--bg-input);
  text-decoration: none;
}

/* Container */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

/* Forms */
label {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

input, textarea, select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
}

textarea { resize: vertical; min-height: 60px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #16a34a; }
.btn-warning { background: var(--warning); color: #1e293b; }
.btn-warning:hover { background: #d97706; }
.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg-input); color: var(--text); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

/* Review card */
.review-card {
  text-align: center;
  padding: 2rem 1.5rem;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: transform 0.2s;
}

.review-card:hover { transform: scale(1.01); }

.review-word {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.review-translation {
  font-size: 1.5rem;
  color: var(--success);
  margin-bottom: 0.75rem;
}

.review-example {
  font-size: 1rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 0.25rem;
}

.review-hidden { display: none; }

.grade-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-top: 1rem;
}

.grade-btn {
  padding: 0.75rem 0.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.grade-btn:active { transform: scale(0.95); }
.grade-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.grade-btn.again { background: var(--danger); color: white; }
.grade-btn.hard { background: var(--warning); color: #1e293b; }
.grade-btn.good { background: var(--success); color: white; }
.grade-btn.easy { background: var(--primary); color: white; }

.grade-interval {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  opacity: 0.8;
}

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  margin-bottom: 1rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

td { font-size: 0.9rem; }

tr:hover { background: rgba(59, 130, 246, 0.05); }

/* Stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}

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

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

/* Chart placeholder */
.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.chart-container h3 {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 120px;
}

.bar-chart .bar {
  flex: 1;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  position: relative;
  transition: height 0.3s;
}

.bar-chart .bar:hover { opacity: 0.8; }

.bar-chart .bar .bar-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.7rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  white-space: nowrap;
}

.bar-chart .bar:hover .bar-tooltip { display: block; }

/* Forecast calendar strip */
.forecast-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
}

.forecast-day {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.25rem;
  text-align: center;
}

.forecast-day-today {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.15);
}

.forecast-day-zero {
  opacity: 0.45;
}

.forecast-day-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.forecast-day-count {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--warning);
  margin: 0.2rem 0;
}

.forecast-day-zero .forecast-day-count {
  color: var(--text-muted);
}

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

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

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 {
  margin-bottom: 1rem;
  font-size: 1.2rem;
}

/* Search bar */
.search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.search-bar input {
  flex: 1;
  min-width: 200px;
  margin-bottom: 0;
}

/* Messages */
.message {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.message-error { background: rgba(239,68,68,0.15); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }
.message-success { background: rgba(34,197,94,0.15); color: #86efac; border: 1px solid rgba(34,197,94,0.3); }

.hidden { display: none !important; }

/* Session info */
.session-info {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-align: center;
}

/* Login page */
.login-container {
  max-width: 400px;
  margin: 4rem auto;
  padding: 0 1rem;
}

.login-container h1 {
  text-align: center;
  margin-bottom: 0.5rem;
  color: var(--primary);
}

.login-container p {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* Responsive */
@media (max-width: 600px) {
  .review-word { font-size: 1.5rem; }
  .review-translation { font-size: 1.2rem; }
  .grade-buttons { grid-template-columns: repeat(2, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .forecast-strip { gap: 0.25rem; }
  .forecast-day { padding: 0.4rem 0.15rem; }
  .forecast-day-count { font-size: 1.1rem; }
}

/* Tag chips */
.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: var(--bg-input);
  border-radius: 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-right: 0.25rem;
}

.tag-clickable { cursor: pointer; }
.tag-clickable:hover { background: var(--primary); color: white; }

/* Legend dots */
.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
}

/* State badges */
.state-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.state-new { background: rgba(59,130,246,0.2); color: #93c5fd; }
.state-learning { background: rgba(245,158,11,0.2); color: #fcd34d; }
.state-review { background: rgba(34,197,94,0.2); color: #86efac; }
.state-relearning { background: rgba(239,68,68,0.2); color: #fca5a5; }

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

.empty-state h2 {
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

/* API key display */
.api-key-display {
  font-family: monospace;
  background: var(--bg-input);
  padding: 0.75rem;
  border-radius: var(--radius);
  word-break: break-all;
  margin: 0.75rem 0;
  border: 1px solid var(--success);
}

/* Settings sections */
.settings-section {
  margin-bottom: 2rem;
}

.settings-section h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.pagination button {
  padding: 0.4rem 0.75rem;
}

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

.deck-card {
  display: flex;
  flex-direction: column;
}

.deck-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

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

.deck-card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.deck-card-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.deck-due-badge {
  color: var(--warning);
  font-weight: 600;
}

/* Deck selector in nav */
#deck-selector {
  max-width: 200px;
}

/* Nav user display */
.nav-user {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
}

/* Shared deck badge */
.shared-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
}

/* Status badges for admin */
.status-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.status-active { background: rgba(34,197,94,0.2); color: #86efac; }
.status-locked { background: rgba(245,158,11,0.2); color: #fcd34d; }
.status-inactive { background: rgba(148,163,184,0.2); color: #94a3b8; }
