/* Interface plein écran — outil de personnalisation Sage X3 */
:root {
  --ink: #14232b;
  --muted: #5b6f79;
  --line: #c5d2da;
  --panel: #ffffff;
  --aside: #0f2a33;
  --aside-text: #d7e6ee;
  --aside-active: #1a4a58;
  --accent: #0b6e4f;
  --danger: #b42318;
  --warn: #9a6700;
  --sage-green: #6bbf2a;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background: #d9e3ea;
}

.app {
  display: grid;
  grid-template-columns: 260px 360px 1fr;
  grid-template-rows: 52px auto 1fr;
  height: 100vh;
  width: 100vw;
}

.rules-hero {
  grid-column: 1 / -1;
  padding: 12px 16px 14px;
  background: #eef7f2;
  border-bottom: 1px solid var(--line);
  max-height: 42vh;
  overflow: auto;
}
.rules-hero-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}
.rules-hero-head h2 {
  margin: 0;
  font-size: 16px;
}
.rules-hero-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rules-hero .rule-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.rules-hero .rule-card.disabled-rule {
  opacity: 0.55;
}
.rule-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  margin-top: 8px;
}
.rule-swatch {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 1px solid #999;
  flex: 0 0 auto;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: #0b1c22;
  color: #e8f1f5;
}

.topbar h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
}

.topbar .meta {
  font-size: 0.82rem;
  color: #9db4bf;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

button:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: #e7eef2; color: var(--ink); }
.btn-warn { background: #fff3cd; color: var(--warn); }
.btn-danger { background: #fce8e6; color: var(--danger); }
.btn-ghost { background: transparent; color: #cfe0e8; border: 1px solid #35515c; }

.catalog, .editor, .preview-pane {
  min-height: 0;
  overflow: auto;
}

.catalog {
  background: var(--aside);
  color: var(--aside-text);
  padding: 12px;
  border-right: 1px solid #0a1a20;
}

.catalog h2, .editor h2, .preview-pane h2 {
  margin: 0 0 10px;
  font-size: 0.92rem;
}

.catalog p.hint {
  margin: 0 0 12px;
  font-size: 0.78rem;
  color: #9db4bf;
  line-height: 1.35;
}

.cat-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 6px;
  border: 1px solid transparent;
}

.cat-item:hover { background: rgba(255,255,255,0.05); }
.cat-item.active {
  background: var(--aside-active);
  border-color: #2f6b7c;
}

.cat-item input { margin-top: 3px; }
.cat-item .title { font-weight: 600; font-size: 0.9rem; }
.cat-item .help { font-size: 0.75rem; color: #9db4bf; margin-top: 2px; line-height: 1.3; }

.editor {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 14px;
}

.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 5px;
}
.field input[type="text"],
.field input[type="color"],
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  font: inherit;
}
.field input[type="color"] { height: 42px; padding: 4px; }
.row { display: flex; gap: 10px; }
.row .field { flex: 1; }
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 14px;
  font-size: 0.9rem;
}

.editor-empty {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
  padding: 8px 0;
}

.block {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.block h3 {
  margin: 0 0 8px;
  font-size: 0.85rem;
}

.templates-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 160px;
  overflow: auto;
}

.tpl-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.tpl-row span {
  flex: 1;
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  margin-top: 12px;
  padding: 10px;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.35;
  display: none;
}
.status.show { display: block; }
.status.ok { background: #e8f7ef; color: #0b6e4f; }
.status.err { background: #fce8e6; color: var(--danger); }

.preview-pane {
  background: #cfd8de;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.preview-toolbar span {
  font-size: 0.8rem;
  color: var(--muted);
}

.sage-frame {
  flex: 1;
  min-height: 0;
  background: #fff;
  border: 1px solid #9aaeb8;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(20, 35, 43, 0.18);
}

.pv-bar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  position: relative;
  background: var(--sage-green);
  color: #fff;
  flex-shrink: 0;
}

.pv-left, .pv-right {
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 2;
  font-size: 0.85rem;
}

.pv-logo { font-weight: 700; letter-spacing: 0.04em; }
.pv-logo span {
  margin-left: 6px;
  padding-left: 8px;
  border-left: 1px solid rgba(255,255,255,0.5);
}

.pv-banner {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-weight: 700;
  white-space: nowrap;
  z-index: 1;
  pointer-events: none;
}
.pv-banner.blink {
  animation: x3perso-blink 1.6s ease-in-out infinite;
}
@keyframes x3perso-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.pv-main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 220px 1fr;
}

.pv-leftlist {
  border-right: 1px solid #d5dee4;
  background: #f4f7f8;
  padding: 12px;
  color: #1a2b33;
  font-size: 0.85rem;
}

.pv-leftlist .group {
  font-weight: 700;
  margin-bottom: 8px;
}
.pv-leftlist .item {
  padding: 6px 8px;
  border-radius: 6px;
  margin-bottom: 4px;
}
.pv-leftlist .item.active {
  background: #d9dbdb;
}

.pv-content {
  padding: 14px 16px;
  overflow: auto;
  background: #fff;
}

.pv-crumb {
  color: #2e7d32;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.pv-title-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.pv-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #1a2b33;
}

.pv-actions {
  display: flex;
  gap: 8px;
}

.pv-btn {
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem;
  background: #546D78;
  color: #fff;
  border: 0;
}

.pv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.pv-table th {
  background: #546D78;
  color: #fff;
  text-align: left;
  padding: 8px 10px;
}
.pv-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e4ebef;
}
.pv-table tr.selected td {
  background: #D9DBDB;
}
.pv-link {
  color: #0065A8;
  text-decoration: underline;
  cursor: default;
}

.css-box {
  display: none;
  margin: 0;
  max-height: 120px;
  overflow: auto;
  background: #0f1c22;
  color: #d7e6ee;
  border-radius: 8px;
  padding: 10px;
  font-family: Consolas, monospace;
  font-size: 0.72rem;
  white-space: pre-wrap;
}
.css-box.show { display: block; }

/* Zone en cours d'édition dans l'aperçu */
.pv-hot {
  outline: 3px solid #ff9800 !important;
  outline-offset: -3px;
  box-shadow: inset 0 0 0 2px rgba(255, 152, 0, 0.35);
}

.rule-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
  background: #f7fafc;
}
.rule-head {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.rule-head input[type="text"] {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}
.rules-list {
  max-height: 48vh;
  overflow: auto;
  padding-right: 4px;
}
.pv-ll-row {
  transition: background-color 0.15s ease, color 0.15s ease;
}

@media (max-width: 1100px) {
  .app {
    grid-template-columns: 220px 1fr;
    grid-template-rows: 52px auto 1fr;
  }
  .preview-pane { grid-column: 1 / -1; min-height: 45vh; }
}
