/* Plugin: sheet — tableur Phase 2 (palette dark EdenALOS). */

.sheet-float-window {
  position: fixed;
  display: flex; flex-direction: column;
  background: rgba(8, 14, 28, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  box-shadow:
    0 18px 60px rgba(0, 0, 0, 0.55),
    0 0 24px rgba(88, 200, 255, 0.14);
  overflow: hidden;
  font-family: var(--font-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
  color: var(--fg, #cdd6f4);
  animation: sheet-win-in 0.18s ease-out;
}
@keyframes sheet-win-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }
.sheet-float-window.sheet-float-window-maximized { border-radius: 0; box-shadow: none; }

.sheet-float-window-titlebar {
  display: flex; align-items: center;
  height: 32px; padding: 0 12px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: grab; user-select: none;
  flex-shrink: 0;
}
.sheet-float-window-titlebar:active { cursor: grabbing; }
.sheet-float-window-titlebar-left {
  display: flex; align-items: center; gap: 8px;
  min-width: 0; flex: 1;
}
.sheet-float-window-title {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-left: 6px;
}

/* Body : flex column (toolbar / formula / grid / tabs) */
.sheet-float-window-body {
  display: flex; flex-direction: column;
  flex: 1; overflow: hidden;
  position: relative;
  background: #0a0f1c;
  outline: none;
}

/* Toolbar */
.sheet-toolbar {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  flex-wrap: wrap;
}
/* Groupe d'actions de la toolbar : pattern Google Sheets — boutons collés
   entre eux dans un groupe, séparateur entre groupes via pseudo-element. */
.sheet-tb-group {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  padding: 0 4px;
  position: relative;
}
.sheet-tb-group + .sheet-tb-group::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 4px;
  bottom: 4px;
  width: 1px;
  background: rgba(255, 255, 255, 0.10);
}
.sheet-tb-sep {
  width: 1px; height: 22px;
  background: rgba(255, 255, 255, 0.08);
  margin: 0 4px;
}
.sheet-name {
  flex: 0 0 200px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--fg, #cdd6f4);
  border-radius: 5px;
  padding: 5px 9px;
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
  font-weight: 600;
}
.sheet-name:focus { border-color: rgba(88, 200, 255, 0.40); }
.sheet-tb-btn {
  min-width: 28px; height: 26px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--fg, #cdd6f4);
  border-radius: 5px;
  font-size: 12px;
  cursor: pointer;
  padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: inherit;
  transition: background .15s, border-color .15s, color .15s;
}
.sheet-tb-btn:hover {
  background: rgba(88, 200, 255, 0.12);
  border-color: rgba(88, 200, 255, 0.32);
  color: #a8d4ff;
}
/* Bouton toggle actif (bold/italic/underline/strike/align ON sur la cellule) */
.sheet-tb-btn.is-active {
  background: rgba(88, 200, 255, 0.18);
  border-color: rgba(88, 200, 255, 0.50);
  color: #58c8ff;
}
/* Mini label texte à droite de l'icône (ex: "+L", "+C", "CSV", "XLSX") */
.sheet-tb-btn .sheet-tb-mini {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.05em;
  margin-left: 3px;
  opacity: 0.85;
}
/* SVG dans bouton toolbar : flex centering OK, pas de problème de baseline */
.sheet-tb-btn svg { flex-shrink: 0; }
/* Wrapper pour color picker : icône cliquable révèle le color picker natif
   masqué par-dessus. Pattern Google Sheets : icône A barrée + bandeau couleur. */
.sheet-tb-color-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  color: var(--fg, #cdd6f4);
  transition: background .15s, border-color .15s, color .15s;
}
.sheet-tb-color-wrap:hover {
  background: rgba(88, 200, 255, 0.12);
  border-color: rgba(88, 200, 255, 0.32);
  color: #a8d4ff;
}
.sheet-tb-color-wrap input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  border: none;
  background: transparent;
  cursor: pointer;
  opacity: 0; /* Native color input invisible — on révèle juste l'icône SVG dessous */
  padding: 0;
}
.sheet-tb-sel {
  height: 26px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--fg, #cdd6f4);
  border-radius: 5px;
  font-family: inherit;
  font-size: 11.5px;
  padding: 0 6px;
  outline: none;
  cursor: pointer;
}
.sheet-tb-sel:focus { border-color: rgba(88, 200, 255, 0.40); }
.sheet-tb-color {
  width: 30px; height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  padding: 2px;
}
.sheet-info {
  flex: 1; text-align: right;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.5);
  font-variant-numeric: tabular-nums;
  margin-left: 12px;
  min-width: 200px;
}

/* Formula bar */
.sheet-formulabar {
  display: flex; align-items: center;
  background: rgba(0, 0, 0, 0.20);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.sheet-fbar-addr {
  width: 60px; text-align: center;
  font-size: 12px; font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #a8d4ff;
  padding: 5px 0;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.sheet-fbar-input {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--fg, #cdd6f4);
  padding: 5px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  outline: none;
}

/* Grid wrapper */
.sheet-grid-wrap {
  flex: 1;
  overflow: auto;
  background: #0a0f1c;
  position: relative;
}
.sheet-grid {
  border-collapse: separate;
  border-spacing: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  table-layout: fixed;
}

/* Headers */
.sheet-grid thead th,
.sheet-grid th.sheet-head-row {
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.55);
  font-weight: 600;
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-align: center;
  padding: 4px 0;
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  user-select: none;
  position: relative;
}
.sheet-grid thead th { position: sticky; top: 0; z-index: 3; height: 22px; }
.sheet-head-corner {
  width: 44px !important;
  position: sticky !important;
  left: 0; z-index: 4 !important;
  background: rgba(255, 255, 255, 0.05) !important;
}
.sheet-head-row {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 44px;
  background: rgba(255, 255, 255, 0.03);
}
.sheet-col-resize {
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 5px;
  cursor: col-resize;
}
.sheet-col-resize:hover { background: rgba(88, 200, 255, 0.30); }
.sheet-row-resize {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 4px;
  cursor: row-resize;
}
.sheet-row-resize:hover { background: rgba(88, 200, 255, 0.30); }

/* Cells */
.sheet-grid td {
  height: 22px;
  padding: 2px 6px;
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--fg, #cdd6f4);
  background: transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: cell;
  font-variant-numeric: tabular-nums;
}
.sheet-grid td.is-active {
  outline: 2px solid rgba(88, 200, 255, 0.55);
  outline-offset: -2px;
  z-index: 1;
  position: relative;
}
.sheet-grid td.is-in-range {
  background: rgba(88, 200, 255, 0.06);
}

/* Editor flottant */
.sheet-celledit {
  position: absolute;
  display: none;
  z-index: 50;
  background: #0a0f1c;
  border: 2px solid rgba(88, 200, 255, 0.7);
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  padding: 1px 5px;
  outline: none;
  box-shadow: 0 4px 14px rgba(88, 200, 255, 0.18);
}

/* Tabs feuilles */
.sheet-tabs {
  display: flex;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.30);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 0 8px;
  overflow-x: auto;
  height: 30px;
}
.sheet-tab {
  display: inline-flex; align-items: center;
  height: 30px;
  padding: 0 12px;
  background: transparent;
  border: none;
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.6);
  font-family: inherit;
  font-size: 11.5px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
  gap: 6px;
}
.sheet-tab:hover { background: rgba(255, 255, 255, 0.04); color: #fff; }
.sheet-tab.active {
  background: rgba(88, 200, 255, 0.10);
  color: #a8d4ff;
  border-bottom: 2px solid #58c8ff;
}
.sheet-tab-x {
  width: 14px; height: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  transition: background .12s, color .12s;
}
.sheet-tab-x:hover { background: rgba(239, 68, 68, 0.20); color: #ef4444; }
.sheet-tab-add {
  width: 28px; height: 30px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
}
.sheet-tab-add:hover { color: #a8d4ff; }

/* Modals (conditional formatting / validation) */
.sheet-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(2, 6, 14, 0.78);
  z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.sheet-modal {
  background: rgba(8, 14, 28, 0.98);
  border: 1px solid rgba(88, 200, 255, 0.30);
  border-radius: 10px;
  width: min(560px, 96vw);
  max-height: 86vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  color: var(--fg, #cdd6f4);
  font-family: var(--font-ui, sans-serif);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}
.sheet-modal-head {
  font-size: 14px; font-weight: 600;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  letter-spacing: 0.02em;
}
.sheet-modal-body { flex: 1; overflow-y: auto; padding: 14px 18px; }
.sheet-modal-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.sheet-modal-row label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.65);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.sheet-modal-row input[type="text"],
.sheet-modal-row input[type="number"],
.sheet-modal-row input:not([type]),
.sheet-modal-row select {
  flex: 1;
  min-width: 100px;
  background: rgba(0, 0, 0, 0.30);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 5px;
  color: var(--fg, #cdd6f4);
  padding: 6px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  outline: none;
}
.sheet-modal-row input:focus,
.sheet-modal-row select:focus {
  border-color: rgba(88, 200, 255, 0.50);
}
.sheet-modal-row input[type="color"] {
  width: 36px; height: 26px;
  flex: 0 0 auto;
  padding: 2px;
  cursor: pointer;
}
.sheet-modal-row input[type="checkbox"] {
  flex: 0 0 auto;
  margin-right: 4px;
}
.sheet-modal-add {
  background: rgba(88, 200, 255, 0.16);
  border: 1px solid rgba(88, 200, 255, 0.40);
  color: #a8d4ff;
  padding: 7px 14px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 14px;
  letter-spacing: 0.04em;
}
.sheet-modal-add:hover { background: rgba(88, 200, 255, 0.24); }
.sheet-modal-list { font-size: 11.5px; }
.sheet-modal-empty {
  padding: 16px 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.4);
  font-style: italic;
}
.sheet-modal-rules {
  width: 100%;
  border-collapse: collapse;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.sheet-modal-rules th {
  text-align: left;
  padding: 5px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.55);
  font-weight: 600;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.sheet-modal-rules td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--fg, #cdd6f4);
  vertical-align: middle;
}
.sheet-modal-rules code {
  background: rgba(255, 255, 255, 0.04);
  padding: 1px 5px; border-radius: 3px; font-size: 11px;
}
.sheet-modal-preview {
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 600;
}
.sheet-modal-rm {
  width: 22px; height: 22px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
}
.sheet-modal-rm:hover { background: rgba(239, 68, 68, 0.16); border-color: #ef4444; color: #ef4444; }
.sheet-modal-foot {
  padding: 12px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex; justify-content: flex-end;
  flex-shrink: 0;
}
.sheet-modal-close {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: var(--fg, #cdd6f4);
  padding: 7px 16px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
.sheet-modal-close:hover { background: rgba(255, 255, 255, 0.08); }

/* Indicateur ▾ pour cellules avec validation list */
.sheet-grid td[data-validation="list"] {
  position: relative;
  padding-right: 18px;
}
.sheet-grid td[data-validation="list"]::after {
  content: '▾';
  position: absolute;
  right: 4px; top: 50%;
  transform: translateY(-50%);
  font-size: 9px;
  color: rgba(88, 200, 255, 0.55);
  pointer-events: none;
}

/* Picker de liste déroulante au clic sur une cellule list-validée */
.sheet-list-picker {
  position: fixed;
  z-index: 9500;
  background: rgba(8, 14, 28, 0.98);
  border: 1px solid rgba(88, 200, 255, 0.40);
  border-radius: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  display: flex; flex-direction: column;
  padding: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  min-width: 120px;
  max-height: 280px;
  overflow-y: auto;
}
.sheet-list-opt, .sheet-list-clear {
  background: transparent;
  border: none;
  color: var(--fg, #cdd6f4);
  text-align: left;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
}
.sheet-list-opt:hover { background: rgba(88, 200, 255, 0.14); color: #a8d4ff; }
.sheet-list-clear { color: rgba(255, 255, 255, 0.4); font-style: italic; border-top: 1px solid rgba(255,255,255,0.06); margin-top: 2px; }

/* Menu contextuel (cellule, header ligne/colonne) — pattern Google Sheets */
.sheet-ctxmenu {
  position: fixed;
  z-index: 999999;
  background: rgba(8, 14, 28, 0.98);
  border: 1px solid rgba(88, 200, 255, 0.30);
  border-radius: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  padding: 4px;
  display: flex; flex-direction: column;
  min-width: 220px;
  user-select: none;
}
.sheet-ctxmenu button {
  background: transparent;
  border: none;
  color: var(--fg, #cdd6f4);
  text-align: left;
  padding: 6px 10px;
  font-family: var(--font-ui, sans-serif);
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.sheet-ctxmenu button svg { flex-shrink: 0; opacity: 0.85; }
.sheet-ctxmenu button:hover { background: rgba(88, 200, 255, 0.14); color: #a8d4ff; }
.sheet-ctxmenu button:hover svg { opacity: 1; }
.sheet-ctxmenu button.danger { color: #ff8b94; }
.sheet-ctxmenu button.danger:hover { background: rgba(239, 68, 68, 0.14); color: #ff5d6c; }
.sheet-ctxmenu .sheet-ctxmenu-sep {
  height: 1px;
  background: rgba(255, 255, 255, 0.10);
  margin: 4px 6px;
}
