:root {
  /* Palette Supabase Dark */
  --colors-scale1: #161616;
  --colors-scale2: #1c1c1c;
  --colors-scale3: #232323;
  --colors-scale4: #282828;
  --colors-scale5: #2e2e2e;
  --colors-scale6: #343434;
  --colors-scale7: #3e3e3e;
  --colors-scale8: #505050;
  --colors-scale9: #707070;
  --colors-scale10: #878787;
  --colors-scale11: #a0a0a0;
  --colors-scale12: #ededed;

  --colors-brand: #3ecf8e;
  --colors-brand-hover: #34b27b;
  --danger: #ef4444;
  --good: #22c55e;

  --sidebar-width: 260px;
  --header-height: 60px;
}

* { box-sizing: border-box; }

body {
  margin: 0; padding: 0;
  background-color: var(--colors-scale2);
  color: var(--colors-scale12);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  overflow: hidden;
  height: 100%;
}

a { text-decoration: none; color: inherit; }

/* Loader (overlay inside content only) */
.page-loader {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(22, 22, 22, 0.7);
  color: #3ecf8e;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.page-loader.visible { display: grid; opacity: 1; }
.page-loader.hidden { opacity: 0; }
.loader { width: 64px; height: 64px; }
.loader-svg { width: 100%; height: 100%; display: block; }
.loader-stroke {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: square;
  stroke-linejoin: miter;
  stroke-miterlimit: 10;
  stroke-dasharray: 230;
  stroke-dashoffset: 0;
  animation: w-elastic 2s ease-in-out infinite;
}
@keyframes w-elastic {
  0% { stroke-dasharray: 0, 230; stroke-dashoffset: 0; }
  50% { stroke-dasharray: 230, 230; stroke-dashoffset: 0; }
  100% { stroke-dasharray: 0, 230; stroke-dashoffset: -230; }
}

/* --- LAYOUT GLOBAL --- */
.app-container {
  display: flex;
  min-height: 100vh;
  height: 100dvh;
  width: 100%;
}

/* SIDEBAR (Navigation) */








.user-role { color: var(--colors-scale9); }





/* MAIN CONTENT */
.main-content {
  flex: 1;
  display: flex; flex-direction: column;
  overflow: hidden;
  background-color: var(--colors-scale2);
  position: relative;
  min-width: 0;
  min-height: 0;
}

.top-header {
  height: var(--header-height);
  border-bottom: 1px solid var(--colors-scale4);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; background-color: var(--colors-scale2);
  flex-shrink: 0;
}

.page-title { font-size: 16px; font-weight: 600; color: var(--colors-scale12); }

/* CONTENU SCROLLABLE */
.content-scroll {
  flex: 1; overflow-y: auto; padding: 32px 32px 42px;
  display: flex; flex-direction: column; gap: 24px;
  max-width: 1000px; margin: 0 auto; width: 100%;
  min-height: 0;
}

/* Scrollbar (fine + dark) */
.content-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--colors-scale6) transparent;
}
.content-scroll::-webkit-scrollbar { width: 6px; }
.content-scroll::-webkit-scrollbar-track { background: transparent; }
.content-scroll::-webkit-scrollbar-thumb {
  background-color: var(--colors-scale6);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.content-scroll::-webkit-scrollbar-corner { background: transparent; }

/* PANELS (Cartes) */
.panel {
  background-color: var(--colors-scale3);
  border: 1px solid var(--colors-scale5);
  border-radius: 8px;
  overflow: hidden;
}

.panel.panel-knowledge {
  overflow: visible;
  margin-bottom: 0;
}

.panel-knowledge .input-zone {
  padding: 24px 24px 16px;
}

.panel-head {
  padding: 16px 24px;
  border-bottom: 1px solid var(--colors-scale5);
  display: flex; align-items: center; justify-content: space-between;
  background-color: var(--colors-scale3);
}

.panel-title { font-weight: 600; color: var(--colors-scale12); font-size: 14px; }

/* TABS */
.tabs {
  display: flex; gap: 4px; padding: 4px;
  background: var(--colors-scale4);
  border-radius: 6px;
}

.tab {
  padding: 6px 12px; border-radius: 4px;
  font-size: 12px; font-weight: 500;
  color: var(--colors-scale10);
  cursor: pointer; border: none; background: transparent;
  transition: all 0.2s;
}
.tab:hover { color: var(--colors-scale12); }
.tab.active { background: var(--colors-scale5); color: var(--colors-brand); }

/* INPUT ZONES */
.input-zone { padding: 24px; display: none; }
.input-zone.active { display: block; }

.field-label {
  display: block; font-size: 11px; font-weight: 600;
  color: var(--colors-scale10); margin-bottom: 8px; text-transform: uppercase;
}

.editor-shell {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--colors-scale5);
  border-radius: 8px;
  background: var(--colors-scale2);
}

.editor-toolbar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--colors-scale10);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.editor-fullscreen-btn {
  border: 1px solid var(--colors-scale6);
  border-radius: 8px;
  padding: 7px 11px;
  background: var(--colors-scale3);
  color: var(--colors-scale12);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.editor-fullscreen-btn:hover {
  background: var(--colors-scale4);
  border-color: var(--colors-scale8);
}

.editor-shell.is-fullscreen {
  position: fixed;
  inset: 14px;
  z-index: 1200;
  border: 1px solid var(--colors-scale5);
  border-radius: 12px;
  background: var(--colors-scale2);
  padding: 14px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.65);
}

.input-text {
  width: 100%; min-height: clamp(260px, 50vh, 560px);
  padding: 16px;
  background: var(--colors-scale1);
  border: 1px solid var(--colors-scale5);
  border-radius: 6px;
  color: var(--colors-scale12);
  font-family: inherit;
  font-size: 13px; line-height: 1.6;
  resize: vertical;
}
.input-text:focus { outline: none; border-color: var(--colors-scale7); }

#fileExtractedContent.input-text {
  min-height: 200px;
  max-height: 360px;
}

.editor-shell.is-fullscreen .input-text {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  resize: none;
}

/* UPLOAD BOX */
.upload-box {
  border: 2px dashed var(--colors-scale5);
  border-radius: 8px; padding: 40px; text-align: center;
  background: var(--colors-scale1);
  cursor: pointer; transition: all 0.2s; position: relative;
}
.upload-box:hover { border-color: var(--colors-brand); background: var(--colors-scale3); }
.upload-box input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.upload-icon { font-size: 24px; margin-bottom: 12px; display: block; opacity: 0.7; }
.upload-text { font-size: 14px; font-weight: 500; color: var(--colors-scale12); }
.upload-sub { font-size: 12px; color: var(--colors-scale10); margin-top: 4px; }

/* ACTIONS */
.action-row {
  display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; padding: 16px 24px;
  border-top: 1px solid var(--colors-scale5);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.01), rgba(255, 255, 255, 0.005)); gap: 10px;
}

.panel-knowledge .action-row {
  min-height: 0;
  padding: 14px 24px 16px;
  align-content: center;
  overflow: visible;
  position: sticky;
  bottom: 0;
  z-index: 3;
  margin-top: 10px;
  border-top-color: var(--colors-scale6);
  background: rgba(28, 28, 28, 0.96);
  backdrop-filter: blur(7px);
  box-shadow: 0 -12px 28px rgba(0, 0, 0, 0.35);
}

.action-row .btn {
  min-width: 112px;
  min-height: 42px;
  padding: 11px 18px;
  border-radius: 8px;
  line-height: 1.2;
  transform: none;
}

.action-row #btnSave {
  min-width: 172px;
}

.action-row .btn:not(.primary) {
  background: var(--colors-scale2);
  color: var(--colors-scale12);
  border-color: var(--colors-scale6);
}

.action-row .btn:not(.primary):hover {
  background: var(--colors-scale4);
  border-color: var(--colors-scale8);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px;
  padding: 10px 16px; border-radius: 8px;
  border: 1px solid var(--colors-scale6);
  background: var(--colors-scale3);
  color: var(--colors-scale12);
  font-size: 13px; font-weight: 600; line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { background: var(--colors-scale4); border-color: var(--colors-scale8); color: var(--colors-scale12); }
.btn.primary {
  background: var(--colors-brand); color: #07170f;
  border-color: var(--colors-brand); font-weight: 600;
  box-shadow: 0 0 0 1px rgba(62, 207, 142, 0.14) inset;
}
.btn.primary:hover { background: var(--colors-brand-hover); border-color: var(--colors-brand-hover); color: #07170f; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* SOURCES LIST */
.sources-list {
  display: flex; flex-direction: column;
}

.source-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--colors-scale5);
}
.source-item:last-child { border-bottom: none; }

.source-info { display: flex; flex-direction: column; gap: 4px; }
.source-title { font-weight: 500; font-size: 14px; color: var(--colors-scale12); }
.source-meta { font-size: 12px; color: var(--colors-scale10); }

.tag {
  display: inline-block; padding: 2px 8px;
  border-radius: 4px; font-size: 10px; font-weight: 700;
  text-transform: uppercase;
  background: var(--colors-scale4); color: var(--colors-scale11);
  border: 1px solid var(--colors-scale5);
}

/* Mobile */
@media (max-width: 1000px) {
  .app-container { flex-direction: column; }
  

@media (max-width: 640px) {
  .action-row {
    justify-content: flex-end;
  }
  .action-row .btn {
    flex: 1 1 140px;
    min-width: 0;
  }

  .panel-knowledge .input-zone {
    padding: 18px 16px 14px;
  }

  .panel-knowledge .action-row {
    min-height: 0;
    padding: 12px 16px 16px;
    gap: 8px;
  }

  .editor-shell.is-fullscreen {
    inset: 8px;
    padding: 10px;
    border-radius: 10px;
  }
}

/* Sidebar collapsed */
body
body
body
body
body
body
body
body
