/* ============================================================
   frage.pl – Responsywny CSS
   Breakpoints:
     Mobile:  < 600px
     Tablet:  600px – 1024px
     Desktop: > 1024px
   ============================================================ */

/* ─── CZCIONKI ─────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Signika:wght@300;400;600;700&display=swap');

/* ─── ZMIENNE ──────────────────────────────────────────────── */
:root {
  --color-primary:      #161443;
  --color-primary-mid:  #323063;
  --color-primary-light:#514fa4;
  --color-accent:       #7876ad;
  --color-accent-pale:  #e3e8ff;
  --color-bg:           #f4f4f4;
  --color-card:         rgba(255,255,255,0.95);
  --color-text:         #333;
  --color-text-muted:   #555;
  --color-success:      #28a745;
  --color-error:        #e74c3c;
  --color-border:       #ddd;

  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   16px;

  --shadow-sm:   0 2px 6px rgba(0,0,0,0.08);
  --shadow-md:   0 4px 14px rgba(0,0,0,0.12);
  --shadow-lg:   0 8px 28px rgba(0,0,0,0.18);

  --font:        'Signika', sans-serif;

  --sidebar-h:   60px;   /* desktop */
}

/* ─── RESET ────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

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

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: calc(var(--sidebar-h) + 20px);
}

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

img { max-width: 100%; display: block; }

/* ─── SIDEBAR (nawigacja pozioma) ──────────────────────────── */
.sidebar {
  width: 100%;
  background-color: rgba(255,255,255,0.97);
  border-bottom: 2px solid var(--color-accent-pale);
  box-shadow: var(--shadow-sm);
  position: fixed;
  top: 0;
  left: 0;
  height: var(--sidebar-h);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 0 12px;
  z-index: 1000;
  transition: background-color 0.3s ease;
  overflow-x: auto;        /* fallback — desktop rzadko potrzebuje */
  overflow-y: hidden;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

.sidebar a {
  color: var(--color-primary);
  font-weight: 500;
  font-size: 0.82rem;
  white-space: nowrap;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: background-color 0.25s ease, color 0.25s ease;
  flex-shrink: 0;
}

.sidebar-brand {
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-primary);
  letter-spacing: 0.02em;
  padding: 8px 14px;
  flex-shrink: 0;
  text-decoration: none;
}
.sidebar-brand:hover {
  background: none !important;
  color: var(--color-primary-light) !important;
}
.sidebar-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.sidebar-links::-webkit-scrollbar { display: none; }
.sidebar-links a {
  color: var(--color-primary);
  font-weight: 500;
  font-size: 0.82rem;
  white-space: nowrap;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: background-color 0.25s ease, color 0.25s ease;
  flex-shrink: 0;
  text-decoration: none;
}
.sidebar-links a:hover,
.sidebar-links a.active {
  background-color: var(--color-primary-light);
  color: #fff;
  text-decoration: none;
}
.sidebar-logout { margin-left: 8px; }

.sidebar a:hover,
.sidebar a.active {
  background-color: var(--color-primary-light);
  color: #fff;
  text-decoration: none;
}

/* Hamburger – domyślnie ukryty */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  flex-shrink: 0;
}
.sidebar-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--color-primary);
  margin: 5px 0;
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Menu mobilne (drawer) */
.sidebar-drawer {
  display: none;
  position: fixed;
  top: var(--sidebar-h);
  left: 0;
  width: 100%;
  background: rgba(255,255,255,0.99);
  box-shadow: var(--shadow-md);
  z-index: 999;
  flex-direction: column;
  padding: 10px 0;
  border-bottom: 2px solid var(--color-accent-pale);
}
.sidebar-drawer.open { display: flex; }

.sidebar-drawer a {
  display: block;
  padding: 14px 24px;
  color: var(--color-primary);
  font-size: 1rem;
  font-weight: 500;
  border-bottom: 1px solid var(--color-accent-pale);
  transition: background-color 0.2s ease;
}
.sidebar-drawer a:last-child { border-bottom: none; }
.sidebar-drawer a:hover,
.sidebar-drawer a.active {
  background-color: var(--color-accent-pale);
  text-decoration: none;
}

/* ─── KONTENERY ────────────────────────────────────────────── */
.container {
  background: var(--color-card);
  padding: 40px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 860px;
  margin: 20px auto;
}

/* ─── NAGŁÓWKI ─────────────────────────────────────────────── */
h1 { font-size: 2rem;   color: #3b3b3b; margin-bottom: 20px; line-height: 1.2; }
h2 { font-size: 1.6rem; color: #3b3b3b; margin-bottom: 16px; line-height: 1.2; }
h3 { font-size: 1.3rem; color: #3b3b3b; margin-bottom: 12px; }

/* ─── FORMULARZE ───────────────────────────────────────────── */
input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  font-family: var(--font);
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--color-text);
  background: #fafafa;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
  margin-bottom: 14px;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  border-color: var(--color-primary-light);
  box-shadow: 0 0 0 3px rgba(81,79,164,0.15);
  outline: none;
}

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

/* ─── PRZYCISKI ────────────────────────────────────────────── */
.btn-submit,
button[type="submit"],
.button {
  display: inline-block;
  padding: 12px 24px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background-color: var(--color-primary);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 0.25s ease, transform 0.2s ease, box-shadow 0.2s ease;
  text-align: center;
  white-space: nowrap;
}

.btn-submit:hover,
button[type="submit"]:hover,
.button:hover {
  background-color: var(--color-primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.btn-submit:active,
button[type="submit"]:active {
  transform: translateY(0);
}

/* Warianty przycisków */
.btn-add  { background: #f1f3f5; color: var(--color-text); }
.btn-add:hover { background: #e1e4e8; color: var(--color-text); }

.btn-remove {
  background: #f1f3f5;
  color: var(--color-text);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}
.btn-remove:hover { background: #ffd6d6; color: var(--color-error); }

.btn-delete { background: var(--color-error); color: #fff; }
.btn-delete:hover { background: #c0392b; }

.btn-nav {
  padding: 10px 18px;
  font-size: 1rem;
  background-color: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.25s ease, transform 0.2s ease;
  display: inline-block;
}
.btn-nav:hover {
  background-color: var(--color-primary-light);
  transform: translateY(-2px);
  text-decoration: none;
}

/* Przyciski ocen fiszek */
.rating-btn { padding: 10px 14px; font-size: 0.9rem; color: #fff; border: none; border-radius: var(--radius-sm); cursor: pointer; font-family: var(--font); transition: transform 0.2s ease, box-shadow 0.2s ease; }
.rating-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }

.btn-green      { background-color: var(--color-primary); }
.btn-lightgreen { background-color: var(--color-primary-mid); }
.btn-yellow     { background-color: #4b4980; }
.btn-orange     { background-color: var(--color-accent); }
.btn-red        { background-color: #b1b0d4; color: #fff; }

/* ─── KOMUNIKATY ────────────────────────────────────────────── */
.success, .success-message {
  color: var(--color-success);
  background: #e9f7ef;
  border: 1px solid #b7dfc5;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-weight: 600;
}

.error, .error-message {
  color: var(--color-error);
  background: #fdecea;
  border: 1px solid #f5c6c6;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-weight: 600;
}

/* ─── TABELA ĆWICZEŃ ────────────────────────────────────────── */
.exercise-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 0.95rem;
}

.exercise-table th,
.exercise-table td {
  border: 1px solid #ccc;
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
}

.exercise-table th {
  background-color: #f0f2ff;
  font-weight: 600;
  color: var(--color-primary);
}

.exercise-table tbody tr:nth-child(even) {
  background-color: #fafafa;
}

.exercise-table input[type="text"] {
  width: auto;
  min-width: 90px;
  padding: 6px 8px;
  font-size: 0.9rem;
  margin-bottom: 0;
}

/* ─── FISZKI (learn) ────────────────────────────────────────── */
#flashcard-container {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px;
  width: 100%;
  min-height: 180px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow 0.2s ease;
}
#flashcard-container:hover { box-shadow: var(--shadow-lg); }

.flashcard-info {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  margin: 12px 0;
  text-align: center;
}

.flashcard-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 700px;
  text-align: center;
}

.navigation-container {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 14px;
}

.button-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}

/* ─── FORMULARZ FISZEK (add/edit) ───────────────────────────── */
#flashcardForm {
  width: 100%;
  max-width: 860px;
  background: var(--color-card);
  padding: 36px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.input-container {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 10px;
}

.input-container input {
  flex: 1;
  margin-bottom: 0;
}

.flashcard-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: var(--font);
  transition: border-color 0.25s;
}
.flashcard-input:focus {
  border-color: var(--color-primary-light);
  outline: none;
}

.level-container {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.level-select,
.set-select {
  width: 100%;
  max-width: 400px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  font-size: 1rem;
  font-family: var(--font);
  background: #fafafa;
}

.import-container {
  margin-top: 16px;
}

/* ─── PASEK POSTĘPU ────────────────────────────────────────── */
.progress-bar {
  background: #e0e0e0;
  border-radius: 10px;
  width: 100%;
  height: 18px;
  margin: 16px 0;
  overflow: hidden;
}
.progress-bar-fill {
  background: var(--color-primary);
  height: 100%;
  border-radius: 10px;
  transition: width 0.5s ease;
}

.progress-info {
  font-size: 1.05rem;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

/* ─── LISTA LINKÓW GRAMATYKI ───────────────────────────────── */
.link-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.link-list li { margin-bottom: 12px; }
.link-list a {
  display: block;
  padding: 13px 18px;
  color: var(--color-primary);
  font-size: 1rem;
  background: var(--color-accent-pale);
  border-radius: var(--radius-sm);
  transition: background-color 0.25s ease, color 0.25s ease;
}
.link-list a:hover {
  background: var(--color-primary-light);
  color: #fff;
  text-decoration: none;
}

/* ─── REJESTRACJA / LOGOWANIE ──────────────────────────────── */
.tab {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  margin-bottom: 20px;
}
.tab button {
  flex: 1;
  padding: 10px;
  cursor: pointer;
  background-color: var(--color-primary);
  font-size: 1rem;
  font-family: var(--font);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  transition: background-color 0.25s;
}
.tab button:hover { background-color: var(--color-primary-light); }

/* ─── CHECKBOX GRID (dashboard poziomy) ───────────────────── */
form div {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 16px;
}
label {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
input[type="checkbox"] {
  transform: scale(1.2);
  accent-color: var(--color-primary);
}

/* ─── STOPKA ────────────────────────────────────────────────── */
footer {
  width: 100%;
  padding: 20px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: auto;
}

/* ─── HARD-RESET: nadpisz inline style z PHP ────────────────── */
.no-flashcards {
  text-align: center;
  padding: 40px;
  color: var(--color-text-muted);
  font-size: 1.1rem;
}

/* ================================================================
   TABLET  600px – 1024px
   ================================================================ */
@media (max-width: 1024px) {

  :root { --sidebar-h: 60px; }

  body { padding-top: calc(var(--sidebar-h) + 16px); }

  /* Sidebar – hamburger od tabletu w dół */
  .sidebar {
    justify-content: space-between;
    padding: 0 14px;
    overflow: visible;
  }
  .sidebar-links { display: none !important; }
  .sidebar > a:not(.sidebar-brand) { display: none !important; }
  .sidebar-toggle { display: flex !important; flex-direction: column; justify-content: center; }
  .sidebar-brand {
    display: block !important;
    font-size: 1rem;
  }

  .container {
    padding: 28px 24px;
    max-width: 100%;
    margin: 12px 16px;
    width: calc(100% - 32px);
  }

  #flashcardForm {
    padding: 24px 20px;
    max-width: 100%;
  }

  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.35rem; }

  .exercise-table th,
  .exercise-table td { padding: 8px 8px; font-size: 0.88rem; }

  #flashcard-container { font-size: 1.5rem; }

  .rating-btn { padding: 9px 10px; font-size: 0.82rem; }
}

/* ================================================================
   MOBILE  < 600px
   ================================================================ */
@media (max-width: 599px) {

  :root { --sidebar-h: 56px; }

  body {
    padding-top: calc(var(--sidebar-h) + 12px);
    align-items: stretch;
  }

  /* ── Sidebar mobile: hamburger ── */
  .sidebar {
    justify-content: space-between;
    padding: 0 14px;
    overflow: visible;
  }

  /* Ukryj wszystkie linki i sidebar-links w pasku */
  .sidebar > a,
  .sidebar-links { display: none !important; }

  /* Pokaż hamburger */
  .sidebar-toggle { display: flex !important; flex-direction: column; justify-content: center; }

  /* Logo / nazwa w sidebar */
  .sidebar-brand {
    display: block !important;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--color-primary);
    letter-spacing: 0.02em;
    text-decoration: none;
  }

  /* ── Kontener ── */
  .container {
    padding: 20px 16px;
    margin: 8px 10px;
    width: calc(100% - 20px);
    border-radius: var(--radius-md);
  }

  h1 { font-size: 1.35rem; }
  h2 { font-size: 1.15rem; }

  /* ── Formularz fiszek ── */
  #flashcardForm {
    padding: 16px 12px;
    width: 100%;
  }

  .input-container {
    flex-wrap: wrap;
    gap: 8px;
  }
  .input-container input,
  .flashcard-input {
    width: 100%;
    flex: none;
    font-size: 0.95rem;
  }
  .btn-remove {
    width: 100%;
    border-radius: var(--radius-sm);
  }

  /* ── Tabela ćwiczeń ── */
  .exercise-table { font-size: 0.82rem; }
  .exercise-table th,
  .exercise-table td { padding: 6px 6px; }
  .exercise-table input[type="text"] { min-width: 70px; font-size: 0.82rem; }

  /* ── Fiszka ── */
  #flashcard-container {
    font-size: 1.25rem;
    min-height: 140px;
    padding: 16px;
  }

  .navigation-container {
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: 6px;
    padding-bottom: 4px;
    justify-content: flex-start;
    scrollbar-width: none;
  }
  .navigation-container::-webkit-scrollbar { display: none; }
  .btn-nav {
    padding: 10px 12px;
    font-size: 0.9rem;
    flex-shrink: 0;
  }
  .button-container {
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
  }
  .rating-btn {
    padding: 12px 6px;
    font-size: 0.82rem;
    flex: 1 1 calc(20% - 6px);
    min-width: 60px;
    max-width: 120px;
  }

  /* ── Rejestracja / logowanie ── */
  .container.auth-container {
    max-width: 100%;
    margin: 8px;
  }
  .tab button { font-size: 0.9rem; padding: 9px 8px; }
  .btn-submit { padding: 13px 16px; width: 100%; }

  /* ── Lista linków gramatyki ── */
  .link-list a { font-size: 0.92rem; padding: 11px 14px; }

  /* ── Postępy ── */
  .progress-info { font-size: 0.9rem; }

  /* ── Najtrudniejsze fiszki ── */
  .hardest-flashcards li { font-size: 0.9rem; }

  /* ── Select / level ── */
  .level-select, .set-select { max-width: 100%; }

  /* ── Przyciski akcji w edit (tylko w formularzach) ── */
  .centered-form .button-container,
  #flashcardForm .button-container { flex-direction: column; align-items: stretch; }
  .centered-form .button-container .btn-submit,
  .centered-form .button-container .btn-add,
  #flashcardForm .button-container .btn-submit,
  #flashcardForm .button-container .btn-add { width: 100%; text-align: center; }

  /* ── Margines top dla br-spacerów ── */
  br { display: none; }
}

/* ─── FOOTER ────────────────────────────────────────────────── */
footer {
  background-color: rgba(255,255,255,0.9);
  color: var(--color-text-muted);
  padding: 20px;
  text-align: center;
  font-size: 0.85rem;
  border-top: 2px solid var(--color-accent-pale);
  width: 100%;
  margin-top: auto;
}
.footer-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  flex-wrap: wrap;
  gap: 8px;
}
.footer-left, .footer-right { flex: 1; min-width: 200px; }
.footer-right { text-align: right; }
.footer-right a { color: var(--color-primary); font-weight: 500; }
.footer-right a:hover { text-decoration: underline; }

/* ─── SETS LIST (learn_flashcard_set) ───────────────────────── */
.sets-list-container {
  width: 100%;
  max-width: 800px;
  background: var(--color-card);
  padding: 16px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  position: relative;
}
.set-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.checkbox-container {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
#setsForm { padding: 8px 4px; }
#toggleButton {
  position: absolute;
  right: 16px;
  top: 16px;
  padding: 7px 12px;
  font-size: 0.85rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.25s;
}
#toggleButton:hover { background: var(--color-primary-light); }
.sets-list.collapsed { display: none; }

/* ─── HARDEST FLASHCARDS LIST ───────────────────────────────── */
.hardest-flashcards { margin-top: 24px; text-align: left; }
.hardest-flashcards ul { list-style: none; padding: 0; }
.hardest-flashcards li {
  background: #f9f9f9;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  font-size: 0.95rem;
}

/* ─── RESPONSIVE FOOTER ─────────────────────────────────────── */
@media (max-width: 599px) {
  .footer-container { flex-direction: column; text-align: center; }
  .footer-right { text-align: center; }
}
