@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400&family=DM+Sans:wght@300;400;500&display=swap');

/* ═══════════════════════════════════════════
   VARIABLES & RESET
═══════════════════════════════════════════ */
:root {
  --bg:        #16120e;
  --bg2:       #1e1912;
  --bg3:       #252018;
  --surface:   #2c2519;
  --border:    #3d3425;
  --gold:      #c9933a;
  --gold-light:#e8b86d;
  --gold-dim:  #7a5820;
  --text:      #e8e0d0;
  --text-dim:  #9e9282;
  --text-muted:#5e5548;
  --red:       #c0392b;
  --green:     #2ecc71;
  --radius:    10px;
  --shadow:    0 8px 32px rgba(0,0,0,0.5);
  --transition: 0.2s ease;
}

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

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: 'Playfair Display', serif;
  line-height: 1.2;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-light); }

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

button {
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  border: none;
  outline: none;
}

input, select, textarea {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

/* ═══════════════════════════════════════════
   LAYOUT
═══════════════════════════════════════════ */
.page { max-width: 1400px; margin: 0 auto; padding: 0 24px; }

/* ═══════════════════════════════════════════
   NAVBAR
═══════════════════════════════════════════ */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 64px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.navbar-brand span { font-size: 1.4rem; }

.navbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.navbar-user img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--gold-dim);
}

.btn-signout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  transition: all var(--transition);
}

.btn-signout:hover {
  border-color: var(--gold-dim);
  color: var(--text);
}

/* ═══════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
}

.btn-primary {
  background: var(--gold);
  color: #1a1200;
  border: none;
}

.btn-primary:hover {
  background: var(--gold-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(201,147,58,0.3);
}

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

.btn-secondary:hover {
  border-color: var(--gold-dim);
  color: var(--gold-light);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
}

.btn-danger:hover {
  background: var(--red);
  color: #fff;
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 1rem;
  transition: all var(--transition);
}

.btn-icon:hover {
  border-color: var(--gold-dim);
  color: var(--gold-light);
}

.btn-icon.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #1a1200;
}

/* ═══════════════════════════════════════════
   LOGIN PAGE
═══════════════════════════════════════════ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, #2c1f08 0%, var(--bg) 70%);
}

.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 56px 48px;
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: var(--shadow), 0 0 80px rgba(201,147,58,0.05);
  animation: fadeUp 0.5s ease;
}

.login-logo {
  font-size: 3rem;
  margin-bottom: 16px;
}

.login-card h1 {
  font-size: 2rem;
  color: var(--gold);
  margin-bottom: 8px;
}

.login-card p {
  color: var(--text-dim);
  margin-bottom: 36px;
  font-size: 0.9rem;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 14px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: 'DM Sans', sans-serif;
}

.btn-google:hover {
  border-color: var(--gold-dim);
  background: var(--bg3);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.btn-google svg { flex-shrink: 0; }

.login-error {
  margin-top: 20px;
  padding: 12px 16px;
  background: rgba(192,57,43,0.15);
  border: 1px solid rgba(192,57,43,0.4);
  border-radius: var(--radius);
  color: #e74c3c;
  font-size: 0.85rem;
  display: none;
}

.login-error.visible { display: block; }

/* ═══════════════════════════════════════════
   FILTERS BAR
═══════════════════════════════════════════ */
.filters-bar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.filter-input {
  width: 80px;
  padding: 7px 10px;
  font-size: 0.85rem;
}

.filter-select {
  padding: 7px 10px;
  font-size: 0.85rem;
  min-width: 140px;
}

.filter-tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  max-width: 400px;
}

.filter-tag-pill {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: 'DM Sans', sans-serif;
}

.filter-tag-pill.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #1a1200;
}

.filter-tag-pill:hover:not(.active) {
  border-color: var(--gold-dim);
  color: var(--text);
}

.filters-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ═══════════════════════════════════════════
   DASHBOARD HEADER
═══════════════════════════════════════════ */
.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 24px 0;
}

.dash-title {
  font-size: 1.6rem;
  color: var(--gold);
}

.dash-count {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-family: 'DM Sans', sans-serif;
  font-weight: 400;
}

/* ═══════════════════════════════════════════
   GRID VIEW
═══════════════════════════════════════════ */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
  padding: 24px;
}

.game-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  animation: fadeUp 0.4s ease both;
  display: flex;
  flex-direction: column;
}

.game-card:hover {
  transform: translateY(-4px);
  border-color: var(--gold-dim);
  box-shadow: 0 12px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(201,147,58,0.1);
}

.card-img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: var(--surface);
}

.card-img-placeholder {
  width: 100%;
  height: 160px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--text-muted);
}

.card-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card-name {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  color: var(--text);
  font-weight: 600;
  line-height: 1.3;
}

.card-meta {
  display: flex;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.card-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: auto;
  padding-top: 4px;
}

.tag-pill {
  padding: 2px 9px;
  border-radius: 20px;
  background: rgba(201,147,58,0.12);
  border: 1px solid rgba(201,147,58,0.25);
  color: var(--gold-light);
  font-size: 0.72rem;
}

.card-last-played {
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 4px;
}

/* ═══════════════════════════════════════════
   LIST VIEW
═══════════════════════════════════════════ */
.games-table-wrap {
  padding: 24px;
  overflow-x: auto;
}

.games-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 6px;
}

.games-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 8px 16px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.games-table th:hover { color: var(--gold-light); }
.games-table th.sort-active { color: var(--gold); }

.games-table td {
  background: var(--bg2);
  padding: 12px 16px;
  font-size: 0.88rem;
  vertical-align: middle;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.games-table td:first-child {
  border-left: 1px solid var(--border);
  border-radius: var(--radius) 0 0 var(--radius);
}

.games-table td:last-child {
  border-right: 1px solid var(--border);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.games-table tr { cursor: pointer; }

.games-table tr:hover td {
  background: var(--surface);
  border-color: var(--gold-dim);
}

.table-img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface);
}

.table-img-placeholder {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.table-name-cell strong {
  display: block;
  color: var(--text);
  font-weight: 500;
}

.table-name-cell small {
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* ═══════════════════════════════════════════
   FICHE JEU
═══════════════════════════════════════════ */
.fiche-page { padding: 32px 24px; max-width: 900px; margin: 0 auto; }

.fiche-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 0.88rem;
  margin-bottom: 28px;
  transition: color var(--transition);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
}

.fiche-back:hover { color: var(--gold-light); }

.fiche-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 36px;
  align-items: start;
}

.fiche-img-wrap {
  position: sticky;
  top: 80px;
}

.fiche-img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.fiche-img-placeholder {
  width: 100%;
  aspect-ratio: 3/4;
  background: var(--surface);
  border-radius: 14px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 3rem;
}

.fiche-content {}

.fiche-header { margin-bottom: 28px; }

.fiche-nom-court {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  color: var(--gold);
  margin-bottom: 4px;
}

.fiche-nom-long {
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.95rem;
}

.fiche-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.fiche-stats {
  display: flex;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
}

.fiche-stat {
  flex: 1;
  padding: 16px 12px;
  text-align: center;
  border-right: 1px solid var(--border);
}

.fiche-stat:last-child { border-right: none; }

.fiche-stat-val {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  color: var(--gold);
  display: block;
}

.fiche-stat-lbl {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 2px;
}

.fiche-section {
  margin-bottom: 24px;
}

.fiche-section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.fiche-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.fiche-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.fiche-text {
  color: var(--text-dim);
  font-size: 0.92rem;
  line-height: 1.7;
}

.fiche-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.fiche-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.85rem;
  transition: all var(--transition);
  text-decoration: none;
}

.fiche-link-btn:hover {
  border-color: var(--gold-dim);
  color: var(--gold-light);
}

.fiche-last-played {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
}

.fiche-last-played-date {
  color: var(--text-dim);
  font-size: 0.88rem;
}

/* ═══════════════════════════════════════════
   EDIT FORM
═══════════════════════════════════════════ */
.edit-form { display: flex; flex-direction: column; gap: 20px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

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

.tags-input-wrap {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 46px;
  transition: border-color var(--transition);
  cursor: text;
}

.tags-input-wrap:focus-within { border-color: var(--gold); }

.tags-input-wrap .tag-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
}

.tag-remove {
  background: transparent;
  border: none;
  color: var(--gold-light);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0;
  line-height: 1;
}

.tag-remove:hover { color: var(--red); }

.tags-text-input {
  border: none;
  background: transparent;
  outline: none;
  color: var(--text);
  font-size: 0.88rem;
  min-width: 120px;
  flex: 1;
  padding: 4px 4px;
}

.tags-suggestions {
  position: absolute;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 50;
  overflow: hidden;
  box-shadow: var(--shadow);
  min-width: 180px;
}

.tags-suggestions-item {
  padding: 9px 14px;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--text-dim);
  transition: background var(--transition);
}

.tags-suggestions-item:hover {
  background: var(--surface);
  color: var(--text);
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.upload-zone:hover {
  border-color: var(--gold-dim);
}

.upload-zone input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.upload-zone-text {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.upload-preview {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 12px;
}

/* ═══════════════════════════════════════════
   FAB (Floating Action Button)
═══════════════════════════════════════════ */
.fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gold);
  color: #1a1200;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(201,147,58,0.4);
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  z-index: 90;
}

.fab:hover {
  background: var(--gold-light);
  transform: scale(1.08) rotate(10deg);
  box-shadow: 0 8px 32px rgba(201,147,58,0.5);
}

/* ═══════════════════════════════════════════
   MODAL (confirmation delete)
═══════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px;
  max-width: 380px;
  width: 90%;
  text-align: center;
}

.modal-box h3 {
  font-size: 1.3rem;
  margin-bottom: 12px;
  color: var(--text);
}

.modal-box p {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ═══════════════════════════════════════════
   TOAST
═══════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 0.88rem;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: all 0.35s ease;
  z-index: 999;
  white-space: nowrap;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.toast-success { border-color: var(--green); color: var(--green); }
.toast.toast-error   { border-color: var(--red); color: #e74c3c; }

/* ═══════════════════════════════════════════
   LOADING
═══════════════════════════════════════════ */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px;
  color: var(--text-muted);
  gap: 20px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 {
  font-family: 'Playfair Display', serif;
  color: var(--text-dim);
  margin-bottom: 8px;
}

/* ═══════════════════════════════════════════
   ANIMATIONS
═══════════════════════════════════════════ */
@keyframes spin { to { transform: rotate(360deg); } }

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

.game-card:nth-child(1)  { animation-delay: 0.02s; }
.game-card:nth-child(2)  { animation-delay: 0.04s; }
.game-card:nth-child(3)  { animation-delay: 0.06s; }
.game-card:nth-child(4)  { animation-delay: 0.08s; }
.game-card:nth-child(5)  { animation-delay: 0.10s; }
.game-card:nth-child(6)  { animation-delay: 0.12s; }
.game-card:nth-child(7)  { animation-delay: 0.14s; }
.game-card:nth-child(8)  { animation-delay: 0.16s; }

/* ═══════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════ */
@media (max-width: 768px) {
  .fiche-layout {
    grid-template-columns: 1fr;
  }

  .fiche-img-wrap { position: static; }

  .fiche-img, .fiche-img-placeholder {
    aspect-ratio: 16/9;
    max-height: 260px;
  }

  .form-row { grid-template-columns: 1fr; }

  .filters-bar { padding: 12px 16px; }
  .filters-right { margin-left: 0; width: 100%; }

  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
    padding: 16px;
  }

  .fiche-stats { flex-wrap: wrap; }
  .fiche-stat { min-width: 80px; }

  .fab { bottom: 20px; right: 20px; }
}

@media (max-width: 480px) {
  .navbar { padding: 0 16px; }
  .navbar-brand { font-size: 1.1rem; }
}

/* ═══════════════════════════════════════════
   TABLEAU MOBILE — fix simple
═══════════════════════════════════════════ */
@media (max-width: 640px) {
  .games-table-wrap { padding: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .games-table { min-width: 480px; }
}
