/* nallium-sheets-frontend — design system
 *
 * Base copiée à l'identique de nallium-drive-frontend/css/style.css (tokens
 * :root + chrome commun : topbar, boutons, panels, alertes, empty-state)
 * pour rester visuellement cohérent avec le reste de la suite bureautique
 * Nallium — c'est un pré-requis produit explicite ("chrome" homogène sur
 * Drive/Docs/Sheets/Slides). Les styles propres à l'éditeur de classeur
 * (grille, barre de formule, onglets de feuille) sont ajoutés à la fin.
 */

:root {
  --text: #172033;
  --muted: #64748b;
  --blue: #3b82f6;
  --green: #22c55e;
  --amber: #f59e0b;
  --pink: #ec4899;
  --violet: #8b5cf6;
  --red: #ef4444;
  --cyan: #06b6d4;
  --bg: #f7f9ff;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-solid: #ffffff;
  --border: rgba(30, 41, 59, 0.12);
  --shadow: 0 24px 80px rgba(30, 41, 59, 0.12);
  --shadow-soft: 0 14px 38px rgba(30, 41, 59, 0.09);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 4%, rgba(59, 130, 246, 0.16), transparent 28%),
    radial-gradient(circle at 90% 12%, rgba(236, 72, 153, 0.12), transparent 24%),
    radial-gradient(circle at 72% 88%, rgba(34, 197, 94, 0.13), transparent 26%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--blue);
  text-decoration: none;
}

button {
  font: inherit;
}

/* ---------------------------------------------------------------------
 * Barre de navigation (reprise drive-frontend)
 * ------------------------------------------------------------------- */
.store-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.store-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  font-size: 18px;
  letter-spacing: -0.02em;
  color: #0f172a;
  cursor: pointer;
}

.store-brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  padding: 2px;
  background: conic-gradient(from 180deg, var(--blue), var(--green), var(--amber), var(--pink), var(--violet), var(--blue));
}

.store-brand-logo span {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  background: #ffffff;
  font-weight: 950;
  font-size: 15px;
  color: #111827;
}

.store-nav {
  display: flex;
  gap: 4px;
}

.store-nav a {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

.store-nav a.active,
.store-nav a:hover {
  background: rgba(59, 130, 246, 0.1);
  color: var(--blue);
}

.store-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.store-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--violet);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 9px 18px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 10px 24px rgba(59, 130, 246, 0.28);
}

.btn-outline {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: #fff;
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------------------------------------------------------------------
 * Layout général
 * ------------------------------------------------------------------- */
.store-page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.panel {
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}

.form-control {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 10px 14px;
  font-size: 14px;
  background: #fff;
}

.hint {
  font-size: 12px;
  color: var(--muted);
}

.alert-banner {
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 18px;
}

.alert-banner.error {
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
}

.alert-banner.success {
  background: rgba(34, 197, 94, 0.1);
  color: #15803d;
}

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

.empty-state .empty-icon {
  font-size: 40px;
  margin-bottom: 10px;
}

.login-gate {
  text-align: center;
  padding: 50px 20px;
}

.login-gate p {
  color: var(--muted);
  margin-bottom: 18px;
}

.plan-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 10px;
}

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

/* =======================================================================
 * Nallium Sheets — styles propres à l'éditeur de classeur
 * ===================================================================== */

/* Le classeur occupe tout l'espace sous la topbar : on désactive le
 * padding/centrage de .store-page pour cette vue précise et on passe en
 * colonne flex plein écran (topbar / barre de formule / grille / onglets). */
.sheets-page {
  max-width: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 65px);
}

.sheets-topbar {
  flex-wrap: wrap;
  row-gap: 10px;
}

.sheets-title-input {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 6px 10px;
  font-weight: 800;
  font-size: 15px;
  color: var(--text);
  background: transparent;
  min-width: 120px;
  max-width: 320px;
}

.sheets-title-input:hover,
.sheets-title-input:focus {
  border-color: var(--border);
  background: #fff;
  outline: none;
}

.sheets-title-input:disabled {
  color: var(--text);
}

.sheets-save-status {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sheets-save-status.is-saving { color: var(--blue); }
.sheets-save-status.is-saved { color: var(--green); }
.sheets-save-status.is-error { color: var(--red); }

.sheets-readonly-badge {
  background: rgba(245, 158, 11, 0.14);
  color: #92400e;
  font-weight: 800;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.sheets-conflict-banner {
  background: rgba(239, 68, 68, 0.12);
  color: #991b1b;
  font-weight: 700;
  font-size: 13px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

/* -----------------------------------------------------------------
 * Barre d'outils
 * ------------------------------------------------------------- */
.sheets-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.7);
  border-bottom: 1px solid var(--border);
}

.sheets-toolbar-sep {
  width: 1px;
  align-self: stretch;
  background: var(--border);
  margin: 2px 6px;
}

.sheets-tool-btn {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}

.sheets-tool-btn:hover {
  background: rgba(30, 41, 59, 0.08);
}

.sheets-tool-btn.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.35);
  color: var(--blue);
}

.sheets-tool-btn-wide {
  width: auto;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
}

.sheets-color-input {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: #fff;
}

/* -----------------------------------------------------------------
 * Barre de formule
 * ------------------------------------------------------------- */
.sheets-formula-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.sheets-formula-ref {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  min-width: 46px;
  text-align: center;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.sheets-formula-fx {
  font-style: italic;
  font-weight: 800;
  color: var(--muted);
  font-size: 13px;
}

.sheets-formula-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #fff;
}

.sheets-formula-input:focus {
  outline: 2px solid rgba(59, 130, 246, 0.3);
  border-color: var(--blue);
}

/* -----------------------------------------------------------------
 * Grille
 * ------------------------------------------------------------- */
.sheets-grid-wrap {
  flex: 1;
  overflow: auto;
  background: #fff;
  position: relative;
}

.sheets-grid {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.sheets-grid th,
.sheets-grid td {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0;
  height: 26px;
  min-width: 90px;
  width: 90px;
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheets-grid .sheets-col-head,
.sheets-grid .sheets-row-head {
  background: #f1f5f9;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
  user-select: none;
  position: sticky;
  z-index: 3;
}

.sheets-grid .sheets-col-head {
  top: 0;
  z-index: 4;
}

.sheets-grid .sheets-row-head {
  left: 0;
  min-width: 42px;
  width: 42px;
  z-index: 2;
}

.sheets-grid .sheets-corner {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 5;
  background: #f1f5f9;
  min-width: 42px;
  width: 42px;
}

.sheets-grid thead th.sheets-col-head {
  position: sticky;
}

.sheets-cell {
  padding: 0 5px;
  line-height: 25px;
  cursor: cell;
  vertical-align: middle;
  position: relative;
  color: var(--text);
}

.sheets-cell.sheets-cell-num {
  text-align: right;
}

.sheets-cell.selected {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
  background: rgba(59, 130, 246, 0.06);
  z-index: 1;
}

.sheets-cell.in-range {
  background: rgba(59, 130, 246, 0.08);
}

.sheets-cell-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 2px solid var(--blue);
  padding: 0 4px;
  font-size: 12.5px;
  font-family: inherit;
  background: #fff;
  z-index: 6;
}

.sheets-cell-input:focus {
  outline: none;
}

/* -----------------------------------------------------------------
 * Onglets de feuille
 * ------------------------------------------------------------- */
.sheets-tabsbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.85);
  border-top: 1px solid var(--border);
  overflow-x: auto;
}

.sheets-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px 8px 0 0;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid transparent;
}

.sheets-tab:hover {
  background: rgba(30, 41, 59, 0.06);
}

.sheets-tab.active {
  color: var(--blue);
  background: #fff;
  border-color: var(--border);
  border-bottom-color: #fff;
  margin-bottom: -1px;
}

.sheets-tab-name-input {
  border: 1px solid var(--blue);
  border-radius: 6px;
  padding: 1px 4px;
  font-size: 12.5px;
  font-weight: 700;
  width: 100px;
}

.sheets-tab-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  border-radius: 999px;
}

.sheets-tab-close:hover {
  color: var(--red);
  background: rgba(239, 68, 68, 0.1);
}

.sheets-tab-add {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  font-size: 16px;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  cursor: pointer;
}

.sheets-tab-add:hover {
  background: rgba(30, 41, 59, 0.08);
  color: var(--text);
}

/* -----------------------------------------------------------------
 * Modale d'historique des versions
 * ------------------------------------------------------------- */
.sheets-version-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
}

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

.sheets-version-meta {
  font-size: 12.5px;
  color: var(--muted);
}

.sheets-version-meta strong {
  color: var(--text);
}
