/* ============================================================
   LEXIPROF v9 — STYLE.CSS
   Glassmorphism | Border-left 2px pastel | Mode rétro
   Micro-interactions | Hero animé | Skeleton | Focus mode
   ============================================================ */

:root {
  --bg: #f7f5f0;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --surface2: rgba(240, 237, 230, 0.6);
  --border: rgba(226, 221, 213, 0.5);

  --text: #1a1814;
  --text-soft: #3a3530;
  --text-muted: #7a7570;

  --mgt: #2563a8;
  --mgt-light: rgba(37, 99, 168, 0.12);
  --drt: #b45309;
  --drt-light: rgba(180, 83, 9, 0.12);
  --eco: #166534;
  --eco-light: rgba(22, 101, 52, 0.12);
  --rh: #7c3aed;
  --rh-light: rgba(124, 58, 237, 0.12);

  --accent: #2563a8;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --success: #15803d;
  --success-light: #dcfce7;

  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 24px 80px rgba(0, 0, 0, 0.12);

  --radius: 16px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body.dark {
  --bg: #151412;
  --surface: rgba(29, 27, 24, 0.72);
  --surface-solid: #1d1b18;
  --surface2: rgba(37, 34, 30, 0.6);
  --border: rgba(55, 51, 45, 0.5);

  --text: #f5f2ec;
  --text-soft: #d8d3ca;
  --text-muted: #9b958c;

  --shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 12px 45px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 80px rgba(0, 0, 0, 0.5);
}

/* ============================================================
   RESET & BASE
   ============================================================ */

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

button, input, textarea, select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: var(--text);
  color: white;
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 20px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================================
   HEADER
   ============================================================ */

header {
  height: 64px;
  padding: 0 24px;
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.logo {
  display: flex;
  align-items: baseline;
  gap: 6px;
  user-select: none;
}

.logo-main {
  font-family: 'Lora', serif;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.5px;
}

.logo-tag {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.user-display {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
}

.user-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-soft);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.btn-icon:hover {
  transform: translateY(-2px) scale(1.05);
  background: var(--surface2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.btn-icon:active {
  transform: scale(0.94);
}

.btn-admin {
  border: none;
  background: var(--text);
  color: var(--bg);
  padding: 9px 15px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  transition: transform var(--transition), opacity var(--transition);
}

.btn-admin:hover {
  transform: translateY(-1px);
  opacity: 0.9;
}

.btn-admin:active {
  transform: scale(0.96);
}

/* ============================================================
   MAIN
   ============================================================ */

main {
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  padding: 38px 0 60px;
}

/* ============================================================
   HERO ANIMÉ (lettres qui apparaissent)
   ============================================================ */

.hero {
  text-align: center;
  margin-bottom: 28px;
  padding: 20px 0 16px;
  transition: background 0.25s ease;
}

.hero h1 {
  font-family: 'Lora', serif;
  font-size: clamp(28px, 5vw, 36px);
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.7px;
  margin-bottom: 8px;
  min-height: 1.2em;
}

.hero-letter {
  display: inline-block;
  opacity: 0;
  transform: translateY(20px);
  animation: letterAppear 0.5s ease forwards;
}

@keyframes letterAppear {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 24px;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}

/* ============================================================
   SEARCH
   ============================================================ */

.search-wrap {
  position: relative;
  max-width: 540px;
  margin: 0 auto;
}

.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

#searchInput {
  width: 100%;
  height: 50px;
  padding: 0 44px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--surface-solid);
  color: var(--text);
  outline: none;
  font-size: 15px;
  box-shadow: var(--shadow);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

#searchInput::placeholder {
  color: #aaa49c;
}

#searchInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(37, 99, 168, 0.09);
  transform: translateY(-1px);
}

.search-clear {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  transition: background var(--transition), color var(--transition);
}

.search-clear.visible {
  display: flex;
}

.search-clear:hover {
  background: var(--text);
  color: var(--bg);
}

/* SEARCH HISTORY */
.search-history {
  max-width: 540px;
  margin: 8px auto 0;
  text-align: left;
  display: none;
}

.search-history.visible {
  display: block;
}

.search-history button {
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 6px 11px;
  margin: 3px;
  cursor: pointer;
  font-size: 12px;
  transition: all var(--transition);
}

.search-history button:hover {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  transform: translateY(-1px);
}

/* COUNTER */
.definition-counter {
  margin-top: 12px;
  min-height: 18px;
  color: var(--text-muted);
  font-size: 12px;
}

/* ============================================================
   FILTRES DROPDOWN
   ============================================================ */

.filters-dropdown {
  margin: 0 0 18px;
}

.filter-dropdown-wrap {
  position: relative;
  display: inline-block;
}

.filter-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface-solid);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}

.filter-dropdown-btn:hover {
  border-color: var(--text-muted);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.filter-dropdown-btn.open {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 168, 0.1);
}

.filter-dropdown-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text);
  transition: background var(--transition);
}

.filter-dropdown-arrow {
  transition: transform var(--transition);
  color: var(--text-muted);
}

.filter-dropdown-btn.open .filter-dropdown-arrow {
  transform: rotate(180deg);
}

.filter-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s ease;
}

.filter-dropdown-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.filter-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: background var(--transition);
}

.filter-dropdown-item:hover {
  background: var(--surface2);
}

.filter-dropdown-item.active {
  background: var(--surface2);
  font-weight: 600;
}

.filter-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.filter-fav-star {
  font-size: 12px;
  color: var(--drt);
}

.filter-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

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

.results-info {
  min-height: 18px;
  margin-bottom: 10px;
  color: var(--text-muted);
  font-size: 12px;
}

/* ============================================================
   SKELETON LOADING
   ============================================================ */

.skeleton-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skeleton-card {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  animation: skeletonPulse 1.5s ease-in-out infinite;
}

@keyframes skeletonPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.skeleton-badge {
  width: 80px;
  height: 20px;
  border-radius: 20px;
  background: var(--surface2);
  margin-bottom: 10px;
}

.skeleton-title {
  width: 60%;
  height: 22px;
  border-radius: 6px;
  background: var(--surface2);
  margin-bottom: 10px;
}

.skeleton-text {
  width: 100%;
  height: 14px;
  border-radius: 4px;
  background: var(--surface2);
  margin-bottom: 6px;
}

.skeleton-text.short {
  width: 70%;
}

/* ============================================================
   CARDS (Glassmorphism + Border-left 2px pastel)
   ============================================================ */

.cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  position: relative;
  background: var(--surface);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: cardIn 0.4s ease both;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.card[data-matiere='Management'] {
  border-left: 2px solid var(--mgt);
}

.card[data-matiere='Droit'] {
  border-left: 2px solid var(--drt);
}

.card[data-matiere='Économie'] {
  border-left: 2px solid var(--eco);
}

.card[data-matiere='RH'] {
  border-left: 2px solid var(--rh);
}

.card:hover {
  transform: translateY(-3px) scale(1.01);
  box-shadow: var(--shadow-hover);
  border-color: rgba(0, 0, 0, 0.1);
}

body.dark .card:hover {
  border-color: rgba(255, 255, 255, 0.1);
}

.card:active {
  transform: scale(0.995);
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.card-term {
  font-family: 'Lora', serif;
  font-size: 18px;
  line-height: 1.3;
  font-weight: 600;
  color: var(--text);
  transition: transform 0.2s ease;
}

.card:hover .card-term {
  transform: scale(1.02);
}

.card-term mark,
.card-def mark {
  background: #fff0a6;
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
}

body.dark .card-term mark,
body.dark .card-def mark {
  background: #665a24;
}

.matiere-badge {
  flex: 0 0 auto;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 5px 9px;
  border-radius: 20px;
}

.badge-Management {
  background: var(--mgt-light);
  color: var(--mgt);
}

.badge-Droit {
  background: var(--drt-light);
  color: var(--drt);
}

.badge-Économie {
  background: var(--eco-light);
  color: var(--eco);
}

.badge-RH {
  background: var(--rh-light);
  color: var(--rh);
}

.card-def {
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.7;
}

.card-actions-row {
  display: flex;
  gap: 7px;
  margin-top: 14px;
  align-items: center;
}

.card-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all var(--transition);
  flex-shrink: 0;
}

.card-action-btn:hover {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.card-action-btn:active {
  transform: scale(0.96);
}

.card-action-btn.fav-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 16px;
}

.heart-icon {
  display: inline-block;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card-action-btn.fav-btn.active .heart-icon {
  animation: heartBeat 0.5s ease;
}

@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.3); }
  50% { transform: scale(1); }
  75% { transform: scale(1.15); }
}

.open-card-btn {
  flex: 1;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.open-card-btn:hover {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  transform: translateY(-1px);
}

.open-card-btn:active {
  transform: scale(0.985);
}

.card-extra {
  display: none;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  animation: extraOpen 0.25s ease;
}

.card-extra.open {
  display: block;
}

@keyframes extraOpen {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.extra-block {
  padding: 13px;
  margin-bottom: 9px;
  border-radius: 11px;
  background: var(--surface2);
}

.extra-block:last-child {
  margin-bottom: 0;
}

.extra-block h4 {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
}

.extra-block p {
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.65;
}

/* ============================================================
   SCROLL SENTINEL
   ============================================================ */

.scroll-sentinel {
  height: 20px;
  margin-top: 20px;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */

.empty-state {
  text-align: center;
  padding: 65px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 38px;
  margin-bottom: 12px;
}

.empty-state h3 {
  color: var(--text);
  font-size: 17px;
  margin-bottom: 5px;
}

.empty-state p {
  font-size: 13px;
}

/* ============================================================
   SCROLL TOP
   ============================================================ */

.scroll-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.scroll-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.scroll-top:hover {
  transform: translateY(-2px) scale(1.1);
  box-shadow: var(--shadow-hover);
}

/* ============================================================
   READING PROGRESS
   ============================================================ */

.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, var(--mgt), var(--rh));
  z-index: 9999;
  transition: width 0.05s linear;
}

/* ============================================================
   OVERLAY
   ============================================================ */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 500;
}

.overlay.open {
  display: flex;
  animation: overlayIn 0.2s ease;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ============================================================
   AUTH MODAL
   ============================================================ */

.auth-modal {
  width: 100%;
  max-width: 400px;
  background: var(--surface-solid);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s ease;
  overflow: hidden;
}

.auth-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 22px 0;
}

.auth-header h2 {
  font-family: 'Lora', serif;
  font-size: 19px;
}

.auth-tabs {
  display: flex;
  gap: 0;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  margin-top: 16px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}

.auth-tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.auth-body {
  padding: 20px 22px 25px;
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
  animation: formIn 0.2s ease;
}

@keyframes formIn {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: translateX(0); }
}

.auth-soon-note {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
  line-height: 1.5;
}

/* ============================================================
   ADMIN PANEL
   ============================================================ */

.admin-panel {
  width: 100%;
  max-width: 620px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface-solid);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(15px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  padding: 20px 22px 16px;
  background: var(--surface-solid);
  border-bottom: 1px solid var(--border);
}

.admin-header h2 {
  font-family: 'Lora', serif;
  font-size: 19px;
}

.admin-subtitle {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 12px;
}

.btn-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.btn-close:hover {
  background: var(--text);
  color: var(--bg);
  transform: rotate(90deg);
}

.admin-body {
  padding: 20px 22px 25px;
}

.form-section {
  padding: 17px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  background: var(--surface2);
  border-radius: 13px;
}

.form-section h3 {
  margin-bottom: 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

.form-row {
  margin-bottom: 12px;
}

.form-row:last-child {
  margin-bottom: 0;
}

.form-row label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
}

.form-row label span {
  color: var(--text-muted);
  font-weight: 400;
}

.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  background: var(--surface-solid);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-row textarea {
  min-height: 85px;
  resize: vertical;
  line-height: 1.5;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 168, 0.08);
}

.form-row input[type='file'] {
  padding: 8px;
}

.btn-add {
  width: 100%;
  margin-top: 4px;
  padding: 11px 14px;
  border: none;
  border-radius: 9px;
  background: var(--text);
  color: var(--bg);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: transform var(--transition), opacity var(--transition);
  display: inline-block;
  text-align: center;
}

.btn-add:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

.btn-add:active {
  transform: scale(0.99);
}

.btn-secondary,
.btn-cancel-edit {
  width: 100%;
  margin-top: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-solid);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transition);
  display: inline-block;
  text-align: center;
}

.btn-secondary:hover,
.btn-cancel-edit:hover {
  background: var(--text);
  color: var(--bg);
}

.btn-cancel-edit {
  color: var(--danger);
}

.json-editor {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
  font-size: 12px !important;
  min-height: 170px !important;
  line-height: 1.55 !important;
}

.admin-definitions {
  margin-top: 5px;
}

.admin-list-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.admin-list-heading h3 {
  font-size: 14px;
}

.admin-list-heading p {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 2px;
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.admin-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-solid);
  transition: background var(--transition);
}

.admin-item:hover {
  background: var(--surface2);
}

.admin-item-term {
  font-size: 13px;
  font-weight: 600;
}

.admin-item-meta {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11px;
}

.admin-item-actions {
  display: flex;
  gap: 5px;
}

.btn-edit,
.btn-del,
.btn-approve,
.btn-reject {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.btn-edit {
  background: var(--surface2);
  color: var(--text);
}

.btn-edit:hover {
  background: var(--text);
  color: var(--bg);
}

.btn-del,
.btn-reject {
  background: var(--danger-light);
  color: var(--danger);
}

.btn-del:hover,
.btn-reject:hover {
  background: var(--danger);
  color: white;
}

.btn-approve {
  background: var(--success-light);
  color: var(--success);
}

.btn-approve:hover {
  background: var(--success);
  color: white;
}

.admin-badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 20px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
}

.proposal-item-def {
  margin-top: 6px;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.5;
}

/* PASSWORD */
.change-pwd-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.change-pwd-toggle {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
}

.change-pwd-form {
  display: none;
  margin-top: 15px;
}

.change-pwd-form.open {
  display: block;
}

/* PASSWORD MODAL */
.pwd-modal {
  width: 100%;
  max-width: 350px;
  padding: 30px 26px;
  background: var(--surface-solid);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: modalIn 0.25s ease;
}

.lock-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 13px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.pwd-modal h2 {
  font-family: 'Lora', serif;
  font-size: 19px;
  margin-bottom: 5px;
}

.pwd-modal p {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 18px;
}

#pwdInput {
  width: 100%;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  background: var(--surface-solid);
  color: var(--text);
  outline: none;
  text-align: center;
  letter-spacing: 3px;
}

#pwdInput:focus {
  border-color: var(--accent);
}

#pwdInput.error {
  border-color: var(--danger);
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.pwd-error {
  min-height: 17px;
  margin: 7px 0;
  color: var(--danger);
  font-size: 11px;
}

.btn-unlock {
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: 9px;
  background: var(--text);
  color: var(--bg);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: opacity var(--transition);
}

.btn-unlock:hover {
  opacity: 0.9;
}

.pwd-cancel {
  margin-top: 12px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
}

/* ============================================================
   FLASHCARD
   ============================================================ */

.flashcard-modal {
  width: min(520px, 100%);
  background: var(--surface-solid);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s ease;
}

.flashcard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.flashcard-counter {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.flashcard-body {
  min-height: 330px;
  padding: 50px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}

.flashcard-body:hover {
  background: var(--surface2);
}

.flashcard-matiere {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 15px;
}

.flashcard-term {
  font-family: 'Lora', serif;
  font-size: clamp(26px, 7vw, 38px);
  font-weight: 600;
  transition: transform 0.3s ease;
}

.flashcard-body:hover .flashcard-term {
  transform: scale(1.03);
}

.flashcard-reveal {
  margin-top: 20px;
  color: var(--text-muted);
  font-size: 12px;
}

.flashcard-def {
  max-width: 430px;
  margin-top: 22px;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.7;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.flashcard-actions {
  display: flex;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}

.flashcard-btn {
  flex: 1;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-solid);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all var(--transition);
}

.flashcard-btn:hover {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  transform: translateY(-1px);
}

.flashcard-btn.primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.flashcard-btn.primary:hover {
  opacity: 0.9;
}

/* ============================================================
   RANDOM MODAL
   ============================================================ */

.random-modal {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.random-modal.open {
  display: flex;
  animation: overlayIn 0.2s ease;
}

.random-modal-card {
  position: relative;
  width: min(500px, 100%);
  padding: 32px 26px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s ease;
}

.random-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 19px;
  transition: all var(--transition);
}

.random-close:hover {
  background: var(--text);
  color: var(--bg);
  transform: rotate(90deg);
}

.random-label {
  display: block;
  margin-bottom: 16px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
}

.random-matiere {
  display: inline-block;
  margin-bottom: 12px;
  padding: 5px 9px;
  border-radius: 20px;
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
}

.random-modal-card h2 {
  font-family: 'Lora', serif;
  font-size: 25px;
  margin-bottom: 12px;
  transition: transform 0.2s ease;
}

.random-modal-card:hover h2 {
  transform: scale(1.02);
}

.random-modal-card p {
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.7;
}

.random-actions {
  display: flex;
  gap: 8px;
  margin-top: 22px;
}

.random-actions button {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 9px;
  background: var(--text);
  color: var(--bg);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all var(--transition);
}

.random-actions button:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.random-actions button.secondary {
  background: var(--surface2);
  color: var(--text);
}

.random-actions button.secondary:hover {
  background: var(--text);
  color: var(--bg);
}

/* ============================================================
   WELCOME
   ============================================================ */

.welcome-banner {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 120px);
  width: min(500px, calc(100% - 32px));
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s ease;
}

.welcome-banner.show {
  transform: translate(-50%, 0);
  opacity: 1;
  pointer-events: auto;
}

.welcome-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--surface2);
}

.welcome-content {
  flex: 1;
  min-width: 0;
}

.welcome-content strong {
  display: block;
  font-size: 12px;
}

.welcome-content span {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11px;
}

.welcome-banner > button {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  transition: color var(--transition);
}

.welcome-banner > button:hover {
  color: var(--text);
}

/* ============================================================
   INSTALL BUTTON
   ============================================================ */

.install-app-btn {
  position: fixed;
  left: 18px;
  bottom: 18px;
  display: none;
  align-items: center;
  gap: 7px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow-hover);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  z-index: 95;
  transition: all var(--transition);
}

.install-app-btn.visible {
  display: flex;
}

.install-app-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* ============================================================
   KEYBOARD HINT
   ============================================================ */

.keyboard-hint {
  position: fixed;
  left: 50%;
  bottom: 12px;
  transform: translate(-50%, 50px);
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-solid);
  color: var(--text-muted);
  font-size: 10px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 1200;
}

.keyboard-hint.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

kbd {
  padding: 2px 5px;
  margin: 0 2px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface2);
  color: var(--text);
  font-size: 9px;
}

/* ============================================================
   LOADER AVEC LOGO
   ============================================================ */

.global-loader {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.global-loader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-logo-img {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  object-fit: cover;
  box-shadow: var(--shadow);
  animation: loaderPulse 1.2s infinite ease-in-out;
}

@keyframes loaderPulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.06); opacity: 1; }
}

.loader-bar {
  width: 120px;
  height: 3px;
  margin-top: 24px;
  overflow: hidden;
  border-radius: 10px;
  background: var(--border);
}

.loader-bar span {
  display: block;
  width: 40%;
  height: 100%;
  background: var(--text);
  border-radius: inherit;
  animation: loading 1s infinite ease-in-out;
}

@keyframes loading {
  from { transform: translateX(-120px); }
  to { transform: translateX(160px); }
}

.global-loader p {
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

/* ============================================================
   TOAST
   ============================================================ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 15px);
  max-width: calc(100% - 32px);
  padding: 10px 17px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 2000;
  transition: all 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ============================================================
   FOOTER
   ============================================================ */

footer {
  padding: 28px 16px 35px;
  margin-top: 10px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.8;
}

footer strong {
  color: var(--text);
}

footer small {
  font-size: 10px;
}

/* ============================================================
   MODE FOCUS (lecture immersive)
   ============================================================ */

body.focus-mode .card {
  background: var(--surface-solid);
  backdrop-filter: none;
  border-left-width: 3px;
}

body.focus-mode .card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

body.focus-mode header {
  backdrop-filter: blur(30px);
}

/* ============================================================
   MODE RETRO (Easter Egg Konami)
   ============================================================ */

body.retro-mode {
  --bg: #0a0a0f;
  --surface: rgba(20, 20, 35, 0.85);
  --surface-solid: #141423;
  --surface2: rgba(30, 30, 50, 0.6);
  --border: rgba(0, 255, 136, 0.2);
  --text: #00ff88;
  --text-soft: #00cc6a;
  --text-muted: #008844;
  --mgt: #ff00ff;
  --drt: #00ffff;
  --eco: #ffff00;
  --rh: #ff6600;
  --accent: #00ff88;
  --shadow: 0 0 20px rgba(0, 255, 136, 0.15);
  --shadow-hover: 0 0 40px rgba(0, 255, 136, 0.25);
}

body.retro-mode .card {
  border: 1px solid rgba(0, 255, 136, 0.3);
  box-shadow: 0 0 15px rgba(0, 255, 136, 0.1);
  font-family: 'Courier New', monospace;
}

body.retro-mode .card:hover {
  box-shadow: 0 0 30px rgba(0, 255, 136, 0.2);
}

body.retro-mode .card-term {
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 1px;
}

body.retro-mode .matiere-badge {
  border: 1px solid currentColor;
  background: transparent !important;
}

body.retro-mode header {
  background: rgba(10, 10, 15, 0.9);
  border-bottom-color: rgba(0, 255, 136, 0.2);
}

body.retro-mode .search-wrap::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 16px;
  background: linear-gradient(45deg, #ff00ff, #00ffff, #ffff00, #ff00ff);
  background-size: 400% 400%;
  animation: gradientShift 3s ease infinite;
  z-index: -1;
  opacity: 0.5;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

body.retro-mode .loader-bar span {
  background: linear-gradient(90deg, #ff00ff, #00ffff, #ffff00);
  background-size: 200% 100%;
  animation: loading 1s infinite ease-in-out, gradientShift 2s ease infinite;
}

body.retro-mode::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9997;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.1) 2px,
    rgba(0, 0, 0, 0.1) 4px
  );
  animation: scanlines 0.1s linear infinite;
}

@keyframes scanlines {
  from { transform: translateY(0); }
  to { transform: translateY(4px); }
}

/* ============================================================
   LANDING PAGE (index.html)
   ============================================================ */

.landing-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 460px;
  margin: 0 auto;
}

.landing-cta-row .btn-add,
.landing-cta-row .btn-secondary {
  width: auto;
  margin-top: 0;
}

.landing-cta-primary,
.landing-cta-secondary {
  flex: 1 1 200px;
  white-space: normal;
}

.landing-subjects {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 32px 0;
}

.landing-subject-card {
  padding: 16px;
  background: var(--surface);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
}

.landing-subject-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.landing-subject-card p {
  margin-top: 10px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
}

.landing-features {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 36px;
}

.landing-feature {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
}

.landing-feature:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.landing-feature-icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  border-radius: 12px;
  background: var(--surface2);
}

.landing-feature h3 {
  font-family: 'Lora', serif;
  font-size: 15px;
  margin-bottom: 4px;
}

.landing-feature p {
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
}

/* ============================================================
   PROPOSE PAGE (propose.html)
   ============================================================ */

.propose-intro {
  text-align: center;
  margin-bottom: 26px;
}

.propose-intro h1 {
  font-family: 'Lora', serif;
  font-size: clamp(24px, 5vw, 30px);
  margin-bottom: 8px;
}

.propose-intro p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

.propose-honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 650px) {
  header {
    height: 58px;
    padding: 0 14px;
  }

  .logo-main {
    font-size: 19px;
  }

  .logo-tag {
    display: none;
  }

  .btn-admin {
    padding: 0 12px;
    height: 36px;
  }

  .btn-admin-text {
    display: inline;
  }

  .user-display {
    padding: 3px 8px;
  }

  .user-name {
    max-width: 80px;
    font-size: 11px;
  }

  main {
    width: calc(100% - 24px);
    padding-top: 28px;
  }

  .hero {
    margin-bottom: 21px;
  }

  .hero h1 {
    font-size: 28px;
  }

  .hero p {
    font-size: 13px;
    margin-bottom: 19px;
  }

  .landing-subjects {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 15px;
    border-radius: 13px;
  }

  .card-term {
    font-size: 17px;
  }

  .card-def {
    font-size: 13px;
    line-height: 1.65;
  }

  .scroll-top {
    right: 12px;
    bottom: 12px;
  }

  .loader-logo-img {
    width: 64px;
    height: 64px;
  }

  .filter-dropdown-menu {
    left: 0;
    right: auto;
    min-width: 200px;
  }
}

@media (max-width: 400px) {
  .card-actions-row {
    flex-wrap: wrap;
  }

  .card-action-btn {
    font-size: 11px;
    padding: 6px 10px;
  }

  .header-actions {
    gap: 4px;
  }

  .btn-icon {
    width: 32px;
    height: 32px;
  }
}
