/* ─────────────────────────────────────────────────────────────
   Italiano Facile – Global Stylesheet
   Italian flag palette:  green #009246  white #fff  red #ce2b37
   ───────────────────────────────────────────────────────────── */

:root {
  --green:       #009246;
  --green-dark:  #007035;
  --green-light: #e6f5ed;
  --red:         #ce2b37;
  --red-dark:    #a5202a;
  --red-light:   #fdecea;
  --white:       #ffffff;
  --off-white:   #f8f9fa;
  --gray-100:    #f1f3f5;
  --gray-200:    #e9ecef;
  --gray-400:    #ced4da;
  --gray-600:    #6c757d;
  --gray-800:    #343a40;
  --text:        #212529;
  --shadow-sm:   0 2px 6px rgba(0,0,0,.08);
  --shadow-md:   0 4px 20px rgba(0,0,0,.12);
  --shadow-lg:   0 8px 40px rgba(0,0,0,.16);
  --radius:      14px;
  --radius-sm:   8px;
  --transition:  .25s ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--off-white);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* ── Navbar ── */
.navbar {
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green) 100%);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--white) !important;
  font-family: 'Playfair Display', serif;
  font-size: 1.35rem;
  text-decoration: none !important;
}
.navbar-brand .flag { font-size: 1.5rem; }
.navbar-brand em { color: #ffd166; font-style: italic; }
.navbar-right { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.nav-user { color: rgba(255,255,255,.75); font-size: .875rem; }
.nav-link { color: var(--white) !important; font-size: .9rem; font-weight: 500; opacity: .9; }
.nav-link:hover { opacity: 1; text-decoration: none; }
.nav-logout { background: rgba(255,255,255,.15); padding: .3rem .75rem; border-radius: 20px; }
.nav-logout:hover { background: rgba(255,255,255,.25); }

/* ── Main & footer ── */
.main-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}
.site-footer {
  text-align: center;
  padding: 1.25rem;
  color: var(--gray-600);
  font-size: .8rem;
  border-top: 1px solid var(--gray-200);
  background: var(--white);
}

/* ── Flash messages ── */
.flash-container { margin-bottom: 1.25rem; }
.flash {
  padding: .85rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: .5rem;
  font-size: .9rem;
  font-weight: 500;
}
.flash-error   { background: var(--red-light);   color: var(--red-dark);   border-left: 4px solid var(--red); }
.flash-success { background: var(--green-light);  color: var(--green-dark); border-left: 4px solid var(--green); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .65rem 1.4rem;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none !important;
  white-space: nowrap;
}
.btn-primary {
  background: var(--green);
  color: var(--white);
  border-color: var(--green);
}
.btn-primary:hover { background: var(--green-dark); border-color: var(--green-dark); }
.btn-outline {
  background: transparent;
  color: var(--green);
  border-color: var(--green);
}
.btn-outline:hover { background: var(--green-light); }
.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border-color: var(--gray-400);
}
.btn-ghost:hover { background: var(--gray-100); }
.btn-full { width: 100%; }
.btn-lg { padding: .85rem 2rem; font-size: 1.05rem; }
.btn-sm { padding: .4rem .9rem; font-size: .82rem; }

/* ── Page header ── */
.page-header { margin-bottom: 2rem; }
.page-header.centered { text-align: center; }
.page-header h1 { font-family: 'Playfair Display', serif; font-size: 2rem; color: var(--gray-800); }
.subtitle { color: var(--gray-600); margin: .4rem 0 1.25rem; font-size: 1rem; }

/* ═══════════════════════════════════════════════════════════
   AUTH PAGES
   ═══════════════════════════════════════════════════════════ */
.auth-wrapper {
  min-height: calc(100vh - 140px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.auth-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem 2.25rem;
  width: 100%;
  max-width: 420px;
}
.auth-header { text-align: center; margin-bottom: 2rem; }
.auth-flag { font-size: 3rem; margin-bottom: .75rem; }
.auth-header h1 { font-family: 'Playfair Display', serif; font-size: 1.8rem; color: var(--gray-800); }
.auth-header p { color: var(--gray-600); margin-top: .35rem; }
.auth-form { display: flex; flex-direction: column; gap: 1.1rem; }
.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-group label { font-size: .875rem; font-weight: 600; color: var(--gray-800); }
.form-group input {
  padding: .7rem 1rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  transition: var(--transition);
  font-family: inherit;
}
.form-group input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(0,146,70,.12);
}
.hint { color: var(--gray-600); font-weight: 400; font-size: .8rem; }
.auth-footer { text-align: center; margin-top: 1.5rem; font-size: .9rem; color: var(--gray-600); }

/* ═══════════════════════════════════════════════════════════
   DASHBOARD
   ═══════════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  gap: .9rem;
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon { font-size: 2.5rem; }
.stat-title { font-family: 'Playfair Display', serif; font-size: 1.2rem; color: var(--gray-800); }
.stat-row { display: flex; justify-content: space-between; align-items: center; font-size: .9rem; }
.stat-label { color: var(--gray-600); }
.stat-value { font-weight: 700; font-size: 1.25rem; }
.stat-value.highlight { color: var(--green); }

.progress-block { display: flex; flex-direction: column; gap: .35rem; }
.progress-label { display: flex; justify-content: space-between; font-size: .82rem; color: var(--gray-600); }
.progress-bar-track { height: 8px; background: var(--gray-200); border-radius: 4px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 4px; transition: width .4s ease; min-width: 3px; }
.progress-bar-fill.green { background: var(--green); }
.progress-bar-fill.blue  { background: #4a90d9; }

.recent-section h2 { font-family: 'Playfair Display', serif; font-size: 1.4rem; margin-bottom: 1rem; }
.table-wrapper { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  background: var(--white);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.data-table th {
  background: var(--green);
  color: var(--white);
  padding: .75rem 1rem;
  text-align: left;
  font-weight: 600;
}
.data-table td { padding: .7rem 1rem; border-bottom: 1px solid var(--gray-200); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--gray-100); }
.data-table code { background: var(--gray-100); padding: .2em .5em; border-radius: 4px; font-size: .85rem; }

/* ═══════════════════════════════════════════════════════════
   SELECT AREA
   ═══════════════════════════════════════════════════════════ */
.area-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}
.area-card {
  cursor: pointer;
  display: block;
}
.area-card input[type=radio] { display: none; }
.area-card-inner {
  background: var(--white);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
  text-align: center;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}
.area-card-inner:hover { border-color: var(--green); box-shadow: var(--shadow-md); transform: translateY(-3px); }
.area-card.selected .area-card-inner {
  border-color: var(--green);
  background: var(--green-light);
  box-shadow: 0 0 0 4px rgba(0,146,70,.15);
}
.area-icon { font-size: 3rem; margin-bottom: .75rem; }
.area-card-inner h2 { font-family: 'Playfair Display', serif; font-size: 1.3rem; color: var(--gray-800); }
.area-sub { font-size: .85rem; color: var(--gray-600); margin: .25rem 0 .75rem; }
.area-desc { font-size: .88rem; color: var(--gray-600); line-height: 1.55; }
.area-action { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; justify-content: center; }

/* ═══════════════════════════════════════════════════════════
   LEARNING SESSION
   ═══════════════════════════════════════════════════════════ */
.session-wrapper {
  max-width: 700px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
}

/* Header row */
.session-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .5rem 0;
}
.session-cat { font-weight: 600; font-size: .95rem; color: var(--green-dark); }
.session-progress-info { font-size: .9rem; color: var(--gray-600); }
.side-badge {
  font-size: .78rem;
  font-weight: 700;
  padding: .2rem .65rem;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.side-badge.italian { background: var(--green-light); color: var(--green-dark); }
.side-badge.translation { background: var(--red-light); color: var(--red-dark); }

/* Timer */
.timer-track {
  width: 100%;
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
}
.timer-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--green);
  transition: width linear, background-color .5s;
}
.timer-fill.warning  { background: #f5a623; }
.timer-fill.critical { background: var(--red); }
.timer-seconds {
  font-size: .82rem;
  color: var(--gray-600);
  align-self: flex-end;
  font-variant-numeric: tabular-nums;
}

/* Loading spinner */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 4rem 2rem;
  color: var(--gray-600);
}
.spinner {
  width: 40px; height: 40px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Flip Card ── */
.card-stage {
  width: 100%;
  perspective: 1400px;
  position: relative;
}
.flip-card {
  width: 100%;
  min-height: 320px;
  cursor: pointer;
  position: relative;
}
.flip-card-inner {
  width: 100%;
  min-height: 320px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.4, .2, .2, 1);
}
.flip-card.flipped .flip-card-inner { transform: rotateY(180deg); }

.flip-card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
  padding: 2rem 2.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  box-shadow: var(--shadow-lg);
  min-height: 320px;
}

/* Italian-first front: green gradient */
.flip-card-front.italian-side {
  background: linear-gradient(145deg, #007035 0%, #009246 60%, #00b856 100%);
  color: var(--white);
}
/* Polish/English-first front: warm white */
.flip-card-front.translation-side {
  background: linear-gradient(145deg, #fff9f0 0%, #ffffff 100%);
  color: var(--text);
  border: 2px solid var(--gray-200);
}
/* Back always warm white / parchment */
.flip-card-back {
  transform: rotateY(180deg);
  background: linear-gradient(145deg, #fff9f0 0%, #fff 60%, #fff8f5 100%);
  color: var(--text);
  border: 2px solid var(--gray-200);
}
/* Back of Italian-first (translation side) */
.flip-card-back.translation-side {
  background: linear-gradient(145deg, #fff9f0 0%, #ffffff 100%);
}
/* Back of Polish/English-first (Italian side) */
.flip-card-back.italian-side {
  background: linear-gradient(145deg, #007035 0%, #009246 60%, #00b856 100%);
  color: var(--white);
}

.card-type-badge {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  opacity: .7;
  align-self: flex-start;
}

.card-body-content { text-align: center; }
.card-main-text {
  font-size: 1.85rem;
  font-weight: 700;
  font-family: 'Playfair Display', serif;
  line-height: 1.25;
  margin-bottom: .5rem;
}
.card-sub-text {
  font-size: 1.05rem;
  font-weight: 400;
  opacity: .85;
  margin-top: .35rem;
}
.card-type-label {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  opacity: .6;
  margin-bottom: .5rem;
}
.card-sentence { font-style: italic; }

/* Checkbox on card */
.card-checkbox-wrap {
  margin-top: .5rem;
}
.learned-label {
  display: flex;
  align-items: center;
  gap: .6rem;
  cursor: pointer;
  font-size: .88rem;
  font-weight: 600;
  user-select: none;
  padding: .5rem .85rem;
  border-radius: 20px;
  background: rgba(255,255,255,.18);
  border: 1.5px solid rgba(255,255,255,.4);
  transition: var(--transition);
}
/* On white-background cards */
.translation-side .learned-label,
.flip-card-back:not(.italian-side) .learned-label {
  background: var(--green-light);
  border-color: var(--green);
  color: var(--green-dark);
}
.learned-label:hover { opacity: .85; transform: scale(1.02); }
.learned-label input[type=checkbox] { display: none; }
.checkmark {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,.7);
  border-radius: 5px;
  flex-shrink: 0;
  position: relative;
  background: transparent;
  transition: var(--transition);
}
.translation-side .checkmark,
.flip-card-back:not(.italian-side) .checkmark {
  border-color: var(--green);
}
.learned-label input:checked ~ .checkmark {
  background: var(--white);
  border-color: var(--white);
}
.learned-label input:checked ~ .checkmark::after {
  content: '';
  position: absolute;
  top: 2px; left: 6px;
  width: 5px; height: 10px;
  border: 2px solid var(--green-dark);
  border-top: none; border-left: none;
  transform: rotate(45deg);
}
.translation-side .learned-label input:checked ~ .checkmark,
.flip-card-back:not(.italian-side) .learned-label input:checked ~ .checkmark {
  background: var(--green);
  border-color: var(--green);
}
.translation-side .learned-label input:checked ~ .checkmark::after,
.flip-card-back:not(.italian-side) .learned-label input:checked ~ .checkmark::after {
  border-color: var(--white);
}

.card-hint { font-size: .72rem; opacity: .5; margin-top: auto; }

/* Review badge */
.review-badge {
  position: absolute;
  top: -10px; right: 12px;
  background: #f5a623;
  color: var(--white);
  font-size: .75rem;
  font-weight: 700;
  padding: .25rem .75rem;
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

/* Done overlay */
.done-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}
.done-box {
  background: var(--white);
  border-radius: var(--radius);
  padding: 3rem 2.5rem;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.done-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.done-box h2 { font-family: 'Playfair Display', serif; font-size: 1.8rem; margin-bottom: .5rem; }
.done-box p { color: var(--gray-600); margin-bottom: 1.5rem; }
.done-actions { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }

/* ═══════════════════════════════════════════════════════════
   SESSION COMPLETE PAGE
   ═══════════════════════════════════════════════════════════ */
.complete-wrapper {
  min-height: calc(100vh - 140px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.complete-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 3rem 2.5rem;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.complete-icon { font-size: 4rem; margin-bottom: 1rem; }
.complete-card h1 { font-family: 'Playfair Display', serif; font-size: 2rem; margin-bottom: .5rem; }
.complete-sub { color: var(--gray-600); margin-bottom: 2rem; }
.complete-stats {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
.cstat { text-align: center; }
.cstat-val { font-size: 2.25rem; font-weight: 700; color: var(--green); font-family: 'Playfair Display', serif; }
.cstat-lbl { font-size: .8rem; color: var(--gray-600); margin-top: .25rem; }
.complete-actions { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }

/* ═══════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  .main-content { padding: 1.25rem 1rem; }
  .flip-card-face { padding: 1.5rem 1.25rem; }
  .card-main-text { font-size: 1.5rem; }
  .stats-grid, .area-grid { grid-template-columns: 1fr; }
  .navbar-inner { flex-wrap: wrap; gap: .5rem; }
  .navbar-right { gap: .75rem; }
}
