/* Base CSS - layout + structure */

* {
  box-sizing: border-box;
}

/* Ensure buttons inherit font and basic styling */
button {
  font-family: inherit;
  font-size: inherit;
  /* Zajistit, aby se theme styly správně aplikovały */
  padding: 11px 18px;
  border-radius: 12px;
  border: none;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.15s ease;

}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: "Segoe UI", system-ui, sans-serif;
}

input,
select {
  font-family: inherit;
  font-size: 15px;
  box-sizing: border-box;
}

.row > div > label,
.range > label,
.order-mode > label {
  display: inline-block;
  margin-bottom: 15px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.06em;
/*  text-transform: uppercase; */
  color: var(--text-muted);
}

.opt label {
  text-transform: none;
  letter-spacing: normal;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.45;
}

.range label {
  margin-bottom: 12px;
}

.range-inputs {
  display: flex;
  align-items: center;
  gap: 12px;
}

.range-inputs input {
  width: 120px;
  flex-shrink: 0;
}

.order-mode {
  margin-top: 18px;
}

.order-mode > label {
  margin-bottom: 12px;
}

.order-mode .custom-select {
  margin-top: 0;
}

.range-sep {
  color: var(--text-muted);
  font-weight: 700;
  margin-top: -2px;
}

.question-image {
  text-align: center;
  margin: 20px 0;
}

.question-image img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.card {
  width: 100%;
  max-width: 900px;
  padding: 32px 36px;
  border-radius: 18px;
}

.row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.muted {
  font-size: 14px;
}

/* ===== HEADINGS ===== */

h1 {
  font-size: 1.75rem;
  font-weight: 600;
  text-align: center;
  margin: 0 0 20px;
  line-height: 1.3;
  letter-spacing: -0.01em;
  
  /* Fallback color for older browsers */
  color: var(--accent);
  
  /* Gradient text for modern browsers */
  background: var(--h1-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  
  /* Support for Firefox */
  background-size: 100%;
  background-repeat: no-repeat;
}

/* Fallback for browsers without background-clip support */
@supports not (-webkit-background-clip: text) {
  h1 {
    color: var(--accent);
    -webkit-text-fill-color: unset;
  }
}

h2 {
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
  margin: 8px 0 24px;
  color: var(--h2-color);
  letter-spacing: -0.01em;
  opacity: 0.9;
}

@media (max-width: 640px) {
  h1 {
    font-size: 1.5rem;
  }
  
  h2 {
    font-size: 1.25rem;
  }
}

.progress-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.progress {
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  margin: 0;
  padding: 0;
}

.question {
  margin: 22px 0 16px;
  font-size: 19px;
  line-height: 1.45;
}

.options {
  display: grid;
  gap: 14px;
  margin: 18px 0 26px;
}

.opt {
  position: relative;
}

.opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.qimage {
  margin: 16px 0 22px;
  text-align: center;
}

.qimage img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 14px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
}

.stats {
  margin-left: auto;
  display: flex;
  gap: 12px;
  font-size: 14px;
  font-weight: 600;
}

/* Mobile portrait orientation - wrap stats below buttons */
@media (max-width: 768px) and (orientation: portrait), (max-width: 640px) {
  .toolbar {
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
  }
  
  .stats {
    margin-left: 0;
    flex-basis: 100%;
    justify-content: center;
    margin-top: 8px;
    flex-wrap: wrap;
  }
  
  /* Ensure buttons stay together */
  .toolbar > button {
    flex-grow: 0;
    flex-shrink: 0;
  }
}

/* Very small screens - additional optimizations */
@media (max-width: 480px) {
  .stats {
    gap: 8px;
    font-size: 13px;
  }
  
  .stat {
    padding: 5px 10px;
    font-size: 13px;
  }
  
  .stat.time {
    min-width: 75px;
  }
  
  .toolbar {
    gap: 10px;
  }
  
  .toolbar > button {
    padding: 8px 14px;
    font-size: 14px;
  }
  
  /* Progress container responsive */
  .progress-container {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  
  .progress {
    font-size: 16px;
  }
  
  .question-number {
    font-size: 14px;
  }
}

@media (max-width: 640px) {
  .row {
    flex-direction: column;
  }
}

.stat {
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 600;
  background: var(--stat-bg, rgba(255,255,255,0.06));
}

.stat.ok {
  color: var(--green, #22c55e);
  border: 1px solid var(--green-border, rgba(34,197,94,0.4));
}

.stat.bad {
  color: var(--red, #ef4444);
  border: 1px solid var(--red-border, rgba(239,68,68,0.4));
}

.stat.time {
  color: var(--blue, #3b82f6);
  border: 1px solid var(--blue-border, rgba(59,130,246,0.4));
  background: var(--blue-bg, rgba(59,130,246,0.08));
  font-variant-numeric: tabular-nums;
  min-width: 85px;
  text-align: center;
}

/* ===== RANGE INPUTS RESPONSIVE FIX ===== */

.range-inputs {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Inputs have fixed width on desktop */
.range-inputs input {
  min-width: 120px;
}

/* Separator */
.range-sep {
  flex-shrink: 0;
  color: var(--text-muted);
  font-weight: 600;
}

/* ===== MOBILE / TABLET FIX ===== */
@media (max-width: 768px) {
  .row {
    flex-direction: column;
  }

  .range-inputs {
    /* Keep horizontal layout with tighter spacing */
    gap: 8px;
  }

  .range-sep {
    font-size: 14px;
    margin-top: 0;
  }

  .range-inputs input {
    width: 90px;
    font-size: 14px;
    padding: 8px 10px;
    height: 36px;
  }
  
  /* Custom dropdown responsive */
  .custom-select-btn,
  .custom-select-dropdown {
    min-width: auto;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .range-inputs {
    gap: 6px;
  }

  .range-inputs input {
    width: 75px;
    font-size: 14px;
    padding: 6px 8px;
    height: 34px;
  }
  
  .range-sep {
    font-size: 12px;
  }
  
  .card {
    padding: 20px 16px;
  }
}

/* ===== RESULTS PAGE ===== */

.results-summary {
  margin: 24px 0 32px;
  text-align: center;
}

.result-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
}

.stat-number {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.correct-color {
  color: var(--green);
}

.wrong-color {
  color: var(--red);
}

.total-color {
  color: var(--text-primary);
}

.percentage-color {
  color: var(--blue);
}

.time-color {
  color: var(--blue);
}

.wrong-questions-section {
  margin-top: 32px;
}

.wrong-questions-section h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.wrong-count {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 1rem;
}

.wrong-questions-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wrong-question-item {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-radius: 12px;
  background: var(--wrong-question-bg);
  border: 1px solid var(--wrong-question-border);
}

.question-number {
  color: var(--red);
  font-weight: 700;
  font-size: 14px;
  min-width: 20px;
  margin-top: 2px;
}

.question-content {
  flex: 1;
}

.question-text {
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.correct-answer {
  font-size: 14px;
  color: var(--text-muted);
}

.correct-answer span {
  color: var(--green);
  font-weight: 600;
}

.user-answer {
  font-size: 14px;
  color: var(--text-muted);
}

.user-answer span {
  color: var(--red);
  font-weight: 600;
}

.perfect-score {
  text-align: center;
  margin: 32px 0;
  padding: 24px;
  border-radius: 16px;
  background: var(--perfect-score-bg);
  border: 1px solid var(--perfect-score-border);
}

.perfect-score h2 {
  color: var(--green);
  margin-bottom: 8px;
  font-size: 1.6rem;
}

.perfect-score p {
  color: var(--text-muted);
  font-size: 16px;
}

.results-actions {
  text-align: center;
  margin-top: 32px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}

.results-actions button {
  margin: 0; /* Odstraním margin, protože už používáme gap */
}

/* Mobile adjustments */
@media (max-width: 640px) {
  .result-stats {
    gap: 16px;
  }
  
  .stat-item {
    min-width: 70px;
  }
  
  .stat-number {
    font-size: 1.8rem;
  }
  
  .wrong-question-item {
    padding: 12px;
  }
}

/* ===== LEARNING COMPLETION ===== */

.learning-completion {
  text-align: center;
  padding: 32px 24px;
  max-width: 500px;
  margin: 0 auto;
}

.learning-icon {
  font-size: 4rem;
  margin-bottom: 20px;
  opacity: 0.8;
}

.learning-completion h2 {
  color: var(--text-primary);
  margin-bottom: 16px;
  font-size: 1.8rem;
  font-weight: 600;
}

.learning-description {
  color: var(--text-muted);
  line-height: 1.6;
  font-size: 16px;
  margin-bottom: 0;
}

button.secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-soft);
}

@media (hover: hover) {
  button.secondary:hover {
    background: var(--bg-card-soft);
    color: var(--text-primary);
  }
}




/* Portrait mode - full screen, no card decorations */
@media (max-width: 768px) and (orientation: portrait) {
  body {
    align-items: flex-start;
    background: var(--bg-card) !important;
  }

  .card {
    background: var(--bg-card);
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 20px 16px;
    min-height: 100vh;
  }
}

/* ===== EXAM VERDICT ===== */

.exam-verdict {
  text-align: center;
  padding: 24px;
  border-radius: 16px;
  margin: 0 auto 24px;
  max-width: 400px;
}

.exam-verdict-icon {
  font-size: 3rem;
  margin-bottom: 8px;
}

.exam-verdict-text {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.exam-verdict-detail {
  font-size: 14px;
  color: var(--text-muted);
}

.exam-passed {
  background: var(--perfect-score-bg);
  border: 2px solid var(--perfect-score-border);
}

.exam-passed .exam-verdict-text {
  color: var(--green);
}

.exam-failed {
  background: var(--wrong-question-bg);
  border: 2px solid var(--wrong-question-border);
}

.exam-failed .exam-verdict-text {
  color: var(--red);
}

.stat.time.time-warning {
  color: var(--red) !important;
  border-color: var(--red-border) !important;
  background: rgba(239, 68, 68, 0.08) !important;
  animation: pulse-warning 1s ease-in-out infinite;
}

@keyframes pulse-warning {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Unsure questions list styling */
.unsure-list {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
}

.unsure-item {
  margin: 8px 0;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 4px;
  border-left: 3px solid var(--accent);
  cursor: pointer;
  transition: all 0.2s ease;
}

.unsure-item:hover {
  background: var(--bg-hover);
  transform: translateX(2px);
}

.unsure-item.expanded {
  background: var(--accent-light);
  border-left-color: var(--accent);
}

.answer-container {
  margin-top: 12px;
  padding: 20px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
  text-align: center;
}

.answer-container .answer-image {
  width: 1000px;
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  object-fit: contain;
  margin-bottom: 10px;
}

.answer-container .answer-image:last-child {
  margin-bottom: 0;
}