/* ============================================================
   SLOVÍČKA – CSS (Mobile-first, iPhone optimalizace)
   ============================================================ */

:root {
  --primary: #4F46E5;
  --primary-dark: #3730A3;
  --primary-light: #EEF2FF;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-400: #9CA3AF;
  --gray-600: #4B5563;
  --gray-800: #1F2937;
  --white: #FFFFFF;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-800);
  font-size: 16px;
  line-height: 1.5;
  overscroll-behavior: none;
}

/* ============================================================
   SCREEN SYSTEM
   ============================================================ */

.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100vh;
}

.screen.active {
  display: flex;
}

.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 10;
  safe-area-inset-top: env(safe-area-inset-top);
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
}

.screen-header h2 {
  flex: 1;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.screen-content {
  flex: 1;
  padding: 20px 16px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

/* ============================================================
   ÚVODNÍ OBRAZOVKA
   ============================================================ */

#screen-user .screen-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  min-height: 100vh;
  padding: 40px 24px;
}

.logo {
  font-size: 72px;
  margin-bottom: 12px;
  line-height: 1;
}

h1 {
  font-size: 36px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
}

.subtitle {
  color: var(--gray-400);
  font-size: 15px;
  margin-bottom: 32px;
}

/* ============================================================
   KARTY
   ============================================================ */

.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--gray-800);
}

.card h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card pre {
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 13px;
  overflow-x: auto;
  font-family: 'Menlo', 'Monaco', monospace;
}

.card code {
  background: var(--gray-100);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Menlo', 'Monaco', monospace;
  font-size: 13px;
}

/* ============================================================
   TLAČÍTKA
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
}

.btn-primary:active {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-800);
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary-light);
}

.btn-full {
  width: 100%;
}

.btn-large {
  padding: 16px;
  font-size: 17px;
  border-radius: var(--radius);
}

.btn-back {
  background: none;
  border: none;
  font-size: 15px;
  color: var(--primary);
  cursor: pointer;
  padding: 6px 0;
  min-width: 60px;
  font-weight: 500;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  color: var(--primary);
  min-width: 40px;
  text-align: center;
}

/* ============================================================
   UŽIVATELÉ
   ============================================================ */

.user-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.user-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--gray-50);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 16px;
  font-weight: 500;
  text-align: left;
}

.user-btn:active, .user-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.divider {
  text-align: center;
  color: var(--gray-400);
  font-size: 13px;
  margin: 12px 0;
  position: relative;
}

.divider::before, .divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--gray-200);
}

.divider::before { left: 0; }
.divider::after { right: 0; }

.input-row {
  display: flex;
  gap: 8px;
}

.input-row input {
  flex: 1;
}

input[type="text"] {
  padding: 12px 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: var(--font);
  transition: border-color 0.15s;
  background: var(--white);
  color: var(--gray-800);
  width: 100%;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
}

/* ============================================================
   UČEBNICE
   ============================================================ */

.book-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.book-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--white);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: var(--shadow);
  text-align: left;
}

.book-btn:active, .book-btn:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.book-icon {
  font-size: 32px;
}

.book-info {
  flex: 1;
}

.book-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--gray-800);
}

.book-meta {
  font-size: 13px;
  color: var(--gray-400);
  margin-top: 2px;
}

.hint {
  color: var(--gray-600);
  font-size: 15px;
  margin-bottom: 12px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-400);
}

.empty-state p {
  margin-bottom: 20px;
  font-size: 15px;
}

/* ============================================================
   UPLOAD
   ============================================================ */

.file-upload-area {
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--gray-400);
  margin-bottom: 16px;
}

.file-upload-area:hover, .file-upload-area.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.file-upload-icon {
  font-size: 40px;
  margin-bottom: 8px;
}

.selected-file {
  background: var(--primary-light);
  color: var(--primary);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 12px;
  font-weight: 500;
}

.status-msg {
  font-size: 14px;
  margin-top: 10px;
  min-height: 20px;
  text-align: center;
}

.status-msg.success { color: var(--success); }
.status-msg.error { color: var(--danger); }

/* ============================================================
   NASTAVENÍ SEZENÍ
   ============================================================ */

.stats-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
}

.stats-card .stat-label { color: rgba(255,255,255,0.8); }
.stats-card .stat-value { color: white; }
.stats-card .stat-value.due { color: #FCD34D; font-size: 20px; }

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
}

.stat-row:last-child { border-bottom: none; }

.stat-label { color: var(--gray-600); font-size: 14px; }
.stat-value { font-weight: 600; font-size: 16px; }
.stat-value.correct { color: var(--success); }
.stat-value.wrong { color: var(--danger); }

.group-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.group-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
}

.group-option:last-child { border-bottom: none; }

.group-option input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
}

.group-option span {
  font-size: 15px;
  font-weight: 500;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
}

.radio-option:last-child { border-bottom: none; }

.radio-option input[type="radio"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.radio-label {
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.radio-icon { font-size: 18px; }

/* ============================================================
   PROCVIČOVÁNÍ
   ============================================================ */

.practice-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
}

.progress-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

#progress-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
}

.progress-bar-wrap {
  width: 100%;
  height: 4px;
  background: var(--gray-200);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

.session-score {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  min-width: 60px;
  text-align: right;
  white-space: nowrap;
}

/* Flashcard */
.flashcard-container {
  perspective: 1000px;
}

.flashcard {
  position: relative;
  width: 100%;
  min-height: 200px;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  user-select: none;
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
  position: absolute;
  width: 100%;
  min-height: 200px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.flashcard-back {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, #F0FDF4, #DCFCE7);
}

.card-direction-hint {
  font-size: 12px;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  font-weight: 600;
}

.card-word {
  font-size: 32px;
  font-weight: 700;
  color: var(--gray-800);
  line-height: 1.2;
  margin-bottom: 10px;
}

.card-group {
  font-size: 13px;
  color: var(--gray-400);
  background: var(--gray-100);
  padding: 4px 12px;
  border-radius: 20px;
}

.card-tap-hint {
  position: absolute;
  bottom: 16px;
  right: 20px;
  font-size: 12px;
  color: var(--gray-400);
}

.card-translation-label {
  font-size: 12px;
  color: #16A34A;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  font-weight: 600;
}

.card-translation {
  font-size: 28px;
  font-weight: 700;
  color: #15803D;
  line-height: 1.2;
  margin-bottom: 8px;
}

.card-word-small {
  font-size: 15px;
  color: #4ADE80;
  font-style: italic;
}

/* Hodnotící tlačítka */
.rating-panel {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.rating-hint {
  font-size: 13px;
  color: var(--gray-400);
  text-align: center;
  margin-bottom: 12px;
  font-weight: 500;
}

.rating-buttons {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.btn-rating {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}

.btn-rating:active {
  transform: scale(0.93);
}

.rating-icon {
  font-size: 22px;
  line-height: 1;
}

.rating-label {
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
}

.btn-rating-0 { background: #FEE2E2; color: #B91C1C; }
.btn-rating-1 { background: #FEF3C7; color: #92400E; }
.btn-rating-2 { background: #FEF9C3; color: #854D0E; }
.btn-rating-3 { background: #DCFCE7; color: #15803D; }
.btn-rating-4 { background: #D1FAE5; color: #065F46; }

.flip-hint {
  /* Tlačítko pro ruční otočení */
}

/* ============================================================
   VÝSLEDKY
   ============================================================ */

.results-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  min-height: 100vh;
  padding: 40px 16px;
}

.results-header {
  text-align: center;
  margin-bottom: 24px;
}

.results-trophy {
  font-size: 64px;
  margin-bottom: 12px;
}

.results-header h2 {
  font-size: 28px;
  font-weight: 700;
}

.results-card {
  width: 100%;
  text-align: center;
}

.result-big {
  font-size: 52px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
}

.result-improvement {
  font-size: 16px;
  font-weight: 500;
  color: var(--success);
  padding: 6px 16px;
  background: #DCFCE7;
  border-radius: 20px;
  display: inline-block;
}

.result-improvement.worse {
  color: var(--danger);
  background: #FEE2E2;
}

.results-buttons {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

/* ============================================================
   DIALOG
   ============================================================ */

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.dialog {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 320px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.dialog h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.dialog p {
  color: var(--gray-600);
  font-size: 14px;
  margin-bottom: 20px;
}

.dialog-buttons {
  display: flex;
  gap: 10px;
}

.dialog-buttons .btn {
  flex: 1;
}

/* ============================================================
   ANIMACE
   ============================================================ */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen.active .card,
.screen.active .book-btn,
.screen.active .user-btn {
  animation: fadeIn 0.25s ease both;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

.flashcard-container {
  animation: slideIn 0.3s ease both;
}

/* ============================================================
   TMAVÝ REŽIM
   ============================================================ */

@media (prefers-color-scheme: dark) {
  :root {
    --gray-50: #1F2937;
    --gray-100: #111827;
    --gray-200: #374151;
    --gray-400: #6B7280;
    --gray-600: #9CA3AF;
    --gray-800: #F9FAFB;
    --white: #1F2937;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
  }

  body {
    background: #111827;
  }

  .flashcard-back {
    background: linear-gradient(135deg, #064E3B, #065F46);
  }

  .card-translation { color: #4ADE80; }
  .card-translation-label { color: #4ADE80; }
  .card-word-small { color: #86EFAC; }
  .card-group { background: #374151; }
}
