/* ============================================================
   App Store — thème « premium dark / glassmorphism »
   Aucune ressource externe (CSP default-src 'self').
   ============================================================ */

:root {
  color-scheme: dark;
  --bg: #070b16;
  --bg-2: #0c1226;
  --card: rgba(255, 255, 255, 0.06);
  --card-strong: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.12);
  --border-soft: rgba(255, 255, 255, 0.08);
  --text: #eef1f8;
  --muted: rgba(226, 232, 244, 0.62);
  --faint: rgba(226, 232, 244, 0.42);

  --ios: #30d158;          /* vert Apple */
  --ios-deep: #1d9e4b;
  --android: #3ddc84;      /* vert Android */
  --android-deep: #1fae63;

  --accent: #8b7cff;       /* violet, éléments admin */
  --accent-2: #5a8cff;
  --danger: #ff5f57;

  --radius: 22px;
  --radius-sm: 12px;
  --shadow-card: 0 24px 70px rgba(2, 6, 20, 0.55);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(60rem 40rem at 85% -10%, rgba(139, 124, 255, 0.22), transparent 60%),
    radial-gradient(50rem 36rem at -15% 110%, rgba(61, 220, 132, 0.12), transparent 60%),
    radial-gradient(46rem 34rem at 8% -8%, rgba(90, 140, 255, 0.18), transparent 55%),
    linear-gradient(165deg, var(--bg-2) 0%, var(--bg) 55%, #05070f 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1 { font-size: 1.55rem; margin: 0 0 0.25rem; letter-spacing: -0.03em; }
h2 { font-size: 1.1rem; margin: 1.75rem 0 0.75rem; letter-spacing: -0.02em; }

a { color: #a9bcff; text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-soft);
  padding: 0.1em 0.4em;
  border-radius: 7px;
  font-size: 0.88em;
  font-family: var(--mono);
}

::selection { background: rgba(139, 124, 255, 0.4); }

/* --- Accessibilité : focus visible --- */
:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.container { max-width: 1020px; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }
.container-narrow { max-width: 580px; }

/* --- Cartes verre --- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  backdrop-filter: blur(22px) saturate(1.35);
  -webkit-backdrop-filter: blur(22px) saturate(1.35);
  box-shadow: var(--shadow-card);
}

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.empty {
  color: var(--muted);
  padding: 2.25rem 1rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

/* --- Boutons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid transparent;
  border-radius: 13px;
  padding: 0.6rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 650;
  font-family: inherit;
  cursor: pointer;
  background: none;
  color: var(--text);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease,
    border-color 0.16s ease, color 0.16s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
  box-shadow: 0 10px 26px rgba(120, 110, 255, 0.35);
}
.btn-primary:hover {
  transform: translateY(-2px);
  text-decoration: none;
  box-shadow: 0 14px 34px rgba(120, 110, 255, 0.45);
}
.btn-danger {
  background: rgba(255, 95, 87, 0.1);
  color: #ff8a84;
  border-color: rgba(255, 95, 87, 0.35);
}
.btn-danger:hover { background: var(--danger); color: #2b0a08; text-decoration: none; }
.btn-sm { padding: 0.32rem 0.75rem; font-size: 0.85rem; border-radius: 10px; }
.btn-block { display: flex; width: 100%; text-align: center; }
.btn-link { color: var(--muted); padding: 0.3rem 0.55rem; }
.btn-link:hover { color: var(--text); text-decoration: none; }
.btn[disabled] { opacity: 0.55; cursor: wait; transform: none; }

/* --- Barre supérieure (admin) --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1.5rem;
  background: rgba(10, 14, 30, 0.72);
  border-bottom: 1px solid var(--border-soft);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
}
.topbar .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.topbar .brand::before {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), var(--android));
  box-shadow: 0 4px 14px rgba(139, 124, 255, 0.45);
}
.topbar nav { display: flex; align-items: center; gap: 0.4rem; }
.topbar nav a {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.4rem 0.7rem;
  border-radius: 10px;
  transition: background 0.15s ease, color 0.15s ease;
}
.topbar nav a:hover { color: var(--text); background: rgba(255, 255, 255, 0.07); text-decoration: none; }
.inline-form { display: inline; margin: 0; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin: 0.5rem 0 1.5rem;
  flex-wrap: wrap;
}

/* --- Tableaux --- */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: var(--shadow-card);
}
.table th, .table td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}
.table th {
  background: rgba(255, 255, 255, 0.045);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 700;
}
.table tbody tr { transition: background 0.14s ease; }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.035); }
.table tr:last-child td { border-bottom: none; }
.table td > a { color: var(--text); font-weight: 600; }
.table td > a:hover { color: #c4d2ff; }
.notes-cell { max-width: 260px; white-space: pre-wrap; word-break: break-word; }
.actions-cell { white-space: nowrap; text-align: right; }

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.22rem 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ios { background: rgba(48, 209, 88, 0.14); color: #6ef09a; border-color: rgba(48, 209, 88, 0.35); }
.badge-android { background: rgba(61, 220, 132, 0.13); color: #7becb4; border-color: rgba(61, 220, 132, 0.35); }
.badge-active { background: rgba(61, 220, 132, 0.13); color: #7becb4; border-color: rgba(61, 220, 132, 0.3); }
.badge-revoked { background: rgba(255, 95, 87, 0.12); color: #ff8a84; border-color: rgba(255, 95, 87, 0.3); }

/* --- Formulaires --- */
.form-card label { display: block; font-weight: 650; font-size: 0.92rem; margin: 1rem 0 0.35rem; }
.form-card label:first-child { margin-top: 0; }
.form-card input[type="text"],
.form-card input[type="email"],
.form-card input[type="password"],
.form-card input[type="file"],
.form-card select,
.form-card textarea,
.auth-card input {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.form-card input:focus, .form-card select:focus, .form-card textarea:focus, .auth-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px rgba(139, 124, 255, 0.22);
  background: rgba(255, 255, 255, 0.07);
}
.form-card input::placeholder, .form-card textarea::placeholder { color: var(--faint); }
.form-card select option { background: var(--bg-2); color: var(--text); }
.form-card textarea { resize: vertical; min-height: 84px; }
.form-card button[type="submit"] { margin-top: 1.15rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }

.alert {
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.1rem;
  margin: 1rem 0;
  border: 1px solid transparent;
}
.alert-error { background: rgba(255, 95, 87, 0.12); border-color: rgba(255, 95, 87, 0.35); color: #ffb1ac; }
.alert-success { background: rgba(61, 220, 132, 0.1); border-color: rgba(61, 220, 132, 0.32); color: #a4f2c9; }
.alert-success p { margin: 0 0 0.35rem; }
.key-reveal {
  display: block;
  margin-top: 0.6rem;
  padding: 0.7rem 0.9rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px dashed rgba(61, 220, 132, 0.45);
  border-radius: 10px;
  word-break: break-all;
  user-select: all;
  color: #d2ffe9;
}

/* --- Connexion / 404 --- */
.auth-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 2.5rem 2.25rem;
  text-align: left;
  animation: fade-up 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.auth-card h1 {
  text-align: center;
  font-size: 1.9rem;
  background: linear-gradient(120deg, #ffffff, #a9bcff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.auth-card > p.muted { text-align: center; margin-top: 0; }
.auth-card label { display: block; font-weight: 650; font-size: 0.92rem; margin: 1rem 0 0.35rem; }
.auth-card button { margin-top: 1.4rem; }
.auth-404 { text-align: center; font-size: 3.4rem; margin: 0; letter-spacing: -0.05em; }

/* --- Drop zone + progression --- */
.drop-zone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}
.drop-zone p { margin: 0.25rem 0 0.9rem; font-size: 0.95rem; }
.drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(139, 124, 255, 0.1);
  color: #d5ccff;
  transform: scale(1.01);
}
.drop-zone.has-file {
  border-style: solid;
  border-color: rgba(61, 220, 132, 0.5);
  background: rgba(61, 220, 132, 0.07);
  color: #a4f2c9;
}
.drop-zone-file { display: block; margin-top: 0.7rem; font-weight: 650; color: var(--text); word-break: break-all; }
.drop-zone input[type="file"] { max-width: 100%; }
.progress-wrap {
  margin-top: 1rem;
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--android));
  box-shadow: 0 0 14px rgba(139, 124, 255, 0.6);
  transition: width 0.18s ease;
}
#upload-status.error { color: #ffb1ac; }
#upload-status.ok { color: #7becb4; }

/* ============================================================
   Page publique d'installation — mobile first
   ============================================================ */
.install-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  padding: max(1.5rem, env(safe-area-inset-top)) 1.1rem max(1.5rem, env(safe-area-inset-bottom));
}

.install-card {
  width: 100%;
  max-width: 420px;
  text-align: center;
  padding: 2.6rem 1.9rem 2.1rem;
  border-radius: 28px;
  animation: fade-up 0.65s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.install-card > * { animation: fade-up 0.6s cubic-bezier(0.22, 1, 0.36, 1) both; }
.install-card > *:nth-child(2) { animation-delay: 0.06s; }
.install-card > *:nth-child(3) { animation-delay: 0.1s; }
.install-card > *:nth-child(4) { animation-delay: 0.14s; }
.install-card > *:nth-child(5) { animation-delay: 0.18s; }
.install-card > *:nth-child(6) { animation-delay: 0.22s; }
.install-card > *:nth-child(7) { animation-delay: 0.26s; }
.install-card > *:nth-child(8) { animation-delay: 0.3s; }

.app-icon {
  display: block;
  margin: 0 auto 1.1rem;
  border-radius: 24%;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.app-icon-placeholder {
  width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  text-transform: uppercase;
  background: linear-gradient(140deg, var(--accent) 0%, var(--accent-2) 55%, var(--android) 120%);
}
.platform-android .app-icon-placeholder {
  background: linear-gradient(140deg, #1fae63 0%, var(--android) 90%);
  color: #04240f;
}

.install-card h1 {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.035em;
  margin: 0 0 0.55rem;
}
.install-card .badge { margin-bottom: 0.35rem; }

.release-meta {
  display: flex;
  justify-content: center;
  gap: 1.4rem 1.7rem;
  margin: 1.35rem 0 0.4rem;
  flex-wrap: wrap;
}
.release-meta div { display: flex; flex-direction: column; gap: 0.15rem; }
.release-meta dt {
  font-size: 0.68rem;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 700;
}
.release-meta dd { margin: 0; font-weight: 700; font-size: 0.98rem; }

.notes-block { margin: 1.1rem 0 0.2rem; text-align: left; }
.notes-block h2 {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--faint);
}
.release-notes {
  margin: 0;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.05rem;
  white-space: pre-line;
  word-break: break-word;
  font-size: 0.92rem;
  color: var(--muted);
  max-height: 11.5rem;
  overflow-y: auto;
}

/* --- Bouton d'installation : gros, natif --- */
.btn-install {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  margin: 1.5rem 0 0.35rem;
  padding: 1.05rem 1.4rem;
  border-radius: 18px;
  font-size: 1.13rem;
  font-weight: 750;
  letter-spacing: -0.01em;
  text-decoration: none;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}
.btn-install svg { flex: none; }
.btn-install:hover { transform: translateY(-2px); text-decoration: none; filter: brightness(1.07); }
.btn-install:active { transform: scale(0.97); }
.btn-install-ios {
  background: linear-gradient(180deg, #3be068 0%, var(--ios-deep) 100%);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 60, 20, 0.3);
  box-shadow: 0 14px 34px rgba(48, 209, 88, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.btn-install-android {
  background: linear-gradient(180deg, #4aec9a 0%, var(--android-deep) 100%);
  color: #032313;
  box-shadow: 0 14px 34px rgba(61, 220, 132, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.install-hint { margin: 0.55rem 0 0; font-size: 0.8rem; color: var(--faint); line-height: 1.5; }

/* --- QR code --- */
.qr-block { margin-top: 1.6rem; padding-top: 1.5rem; border-top: 1px solid var(--border-soft); }
.qr-frame {
  display: inline-block;
  background: #fff;
  padding: 10px;
  border-radius: 18px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}
.qr { display: block; width: 132px; height: 132px; }
.qr-caption { margin: 0.75rem 0 0; font-size: 0.8rem; color: var(--faint); }

.install-footer {
  font-size: 0.74rem;
  color: var(--faint);
  text-align: center;
  animation: fade-up 0.7s 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* --- Animations --- */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 640px) {
  .table { display: block; overflow-x: auto; }
  .grid-2 { grid-template-columns: 1fr; }
  .topbar { padding: 0.7rem 1rem; flex-wrap: wrap; }
  .install-card { padding: 2.2rem 1.5rem 1.9rem; }
  .install-card h1 { font-size: 1.6rem; }
}

/* --- Édition app / icône / release (page détail admin) --- */
.grid-cards { gap: 0 1.25rem; align-items: start; }
.grid-cards .card { min-width: 0; }

.icon-edit-row { display: flex; gap: 1.1rem; align-items: flex-start; flex-wrap: wrap; }
.app-icon-preview {
  width: 64px;
  height: 64px;
  flex: none;
  border-radius: 24%;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.app-icon-preview.app-icon-placeholder { font-size: 1.7rem; margin: 0; }
.icon-form { flex: 1; min-width: 200px; }
.icon-form button[type="submit"] { margin-top: 0.6rem; }

.edit-release { display: inline-block; text-align: left; margin-bottom: 0.4rem; }
.edit-release > summary {
  list-style: none;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.32rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--text);
  background: var(--card);
  display: inline-block;
  user-select: none;
}
.edit-release > summary::-webkit-details-marker { display: none; }
.edit-release > summary:hover { background: var(--card-strong); }
.edit-release[open] > summary { border-color: var(--accent); color: #c4baff; }
.edit-release-form {
  position: absolute;
  right: 1rem;
  z-index: 20;
  width: min(340px, calc(100vw - 2rem));
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  padding: 1rem 1.1rem;
}
.actions-cell { position: relative; }
.edit-release-form button[type="submit"] { margin-top: 0.7rem; }

@media (max-width: 640px) {
  .grid-cards { grid-template-columns: 1fr; }
}
