/* ── Reset ── */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: #f8f9fb;
}

/* ── Sidebar ── */
.sidebar {
  width: 66px;
  background: #10182A;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 6px;
  flex-shrink: 0;
}
.sidebar-logo { width: 38px; height: 38px; object-fit: contain; margin-bottom: 12px; }
.sidebar-sep  { width: 32px; height: 1px; background: rgba(255,255,255,.08); margin: 6px 0; }
.sidebar-icon {
  width: 40px; height: 40px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: #4a5875;
  transition: background .15s, color .15s;
}
.sidebar-icon:hover  { background: rgba(255,255,255,.06); color: #9ca3af; }
.sidebar-icon.active { background: rgba(255,255,255,.10); color: #fff; }

/* ── Shell ── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.header {
  height: 44px;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
  display: flex; align-items: center;
  padding: 0 20px; gap: 6px;
  font-size: 13px; color: #9ca3af;
  flex-shrink: 0;
}
.header .sep     { color: #d1d5db; }
.header .current { color: #111827; font-weight: 500; }

.content { flex: 1; overflow: auto; }

.dot-bg {
  background-color: #f8f9fb;
  background-image: radial-gradient(#dde1e9 1px, transparent 1px);
  background-size: 22px 22px;
  height: 100%;
}

/* ── Rules bar ── */
/* Spacer so content doesn't hide behind the fixed drawer */
.rules-bar { height: 44px; flex-shrink: 0; }

/* Team dropdown */
.team-dd { position: relative; }
.team-dd-btn {
  border: 1px solid #e5e7eb; border-radius: 6px;
  padding: 4px 10px;
  font-size: 13px; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  background: white; color: #374151;
  user-select: none; max-width: 260px;
}
#team-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.team-dd-btn:hover { border-color: #9ca3af; }
.chevron      { font-size: 10px; color: #9ca3af; transition: transform .15s; }
.chevron.open { transform: rotate(180deg); }
.team-menu {
  position: absolute; top: calc(100% + 4px); left: 0;
  background: white; border: 1px solid #e5e7eb; border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.1);
  padding: 6px; min-width: 250px;
  display: none; z-index: 200;
}
.team-menu.open { display: block; }
.team-item { padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; color: #374151; display: flex; align-items: center; gap: 10px; }
.team-item:hover { background: #f3f4f6; }
.team-item-info  { flex: 1; }
.team-sub        { font-size: 11px; color: #9ca3af; font-weight: 400; }
.team-cb {
  width: 16px; height: 16px; flex-shrink: 0;
  border: 1.5px solid #d1d5db; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  background: white; transition: background .1s, border-color .1s;
}
.team-item.sel .team-cb { background: #2563eb; border-color: #2563eb; }
.team-cb-check { display: none; color: white; font-size: 11px; font-weight: 700; }
.team-item.sel .team-cb-check { display: block; }

/* ── Prompt view ── */
.view-prompt {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 88px);
  padding: 40px 20px;
}
.prompt-card {
  background: white; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 20px; width: 580px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
}
.prompt-card h3 { font-size: 15px; font-weight: 500; margin-bottom: 12px; }

.prompt-textarea {
  width: 100%; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 12px; font-size: 14px; line-height: 1.5;
  min-height: 90px; resize: none;
  font-family: inherit; outline: none; color: #111827;
}
.prompt-textarea::placeholder { color: #9ca3af; }
.prompt-textarea:focus        { border-color: #9ca3af; }

.model-chip {
  display: none; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: #f8f9fb; border: 1px solid #e5e7eb; border-radius: 6px;
  font-size: 13px; margin-top: 8px; color: #374151;
}
.model-chip.show { display: flex; }
.chip-text { flex: 1; }
.chip-x       { cursor: pointer; color: #9ca3af; font-size: 18px; line-height: 1; }
.chip-x:hover { color: #374151; }

.prompt-footer { display: flex; align-items: center; margin-top: 10px; gap: 6px; }

/* Link dropdown */
.link-dd-wrap { position: relative; }
.link-dd-menu {
  display: none; position: absolute; bottom: calc(100% + 6px); left: 0;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.1);
  padding: 4px; min-width: 220px; z-index: 100;
}
.link-dd-menu.open { display: block; }
.link-dd-item { padding: 8px 10px; border-radius: 6px; font-size: 13px; color: #374151; cursor: pointer; }
.link-dd-item:hover { background: #f3f4f6; }

.icon-btn {
  width: 30px; height: 30px;
  border: 1px solid #e5e7eb; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; background: white; color: #6b7280;
}
.icon-btn:hover { border-color: #9ca3af; color: #374151; }

.spacer { flex: 1; }

.btn-gen { padding: 7px 18px; background: #111827; color: white; border: none; border-radius: 6px; font-size: 13px; cursor: pointer; font-family: inherit; }
.btn-gen:hover { background: #1f2937; }

/* ── 3-column view ── */
.view-results { display: none; }

.three-col {
  display: flex; gap: 20px; padding: 20px;
  min-height: calc(100vh - 218px);
  align-items: stretch;
}

/* ── KPI strip (cost / weight / efficiency impact) ── */
.kpi-strip { padding: 20px 20px 0; }

.kpi-row { display: flex; gap: 20px; align-items: stretch; }

.kpi-tile {
  flex: 1;
  background: #fff; border: 1px solid #E5E7EB; border-radius: 12px;
  padding: 14px 16px 15px;
  display: flex; flex-direction: column; gap: 6px;
  min-width: 0;
}
.kpi-label {
  font-size: 12px; color: #9ca3af; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi-value-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.kpi-value { font-size: 26px; font-weight: 600; color: #10182A; line-height: 1.1; }
.kpi-delta {
  font-size: 12px; font-weight: 500;
  padding: 2px 8px; border-radius: 20px;
  white-space: nowrap;
}
.kpi-delta.up   { background: #dcfce7; color: #15803d; }  /* improvement */
.kpi-delta.down { background: #fee2e2; color: #991b1b; }  /* regression  */
.kpi-delta.flat { background: #f3f4f6; color: #6b7280; }
.kpi-ref { font-size: 11px; color: #9ca3af; }

.kpi-note { font-size: 11px; color: #9ca3af; margin-top: 8px; }

/* ── Column tabs ── */
/* Only .active is interactive. .disabled tabs are present to signal the
   capability exists (version history, comments) and are inert by design. */
.col-tabs {
  display: flex; gap: 16px;
  border-bottom: 1px solid #e5e7eb;
  margin: 10px 0 14px;
}
.col-tab {
  font-size: 12.5px; padding: 0 1px 7px;
  border-bottom: 2px solid transparent;
  display: flex; align-items: center; gap: 6px;
  user-select: none;
}
.col-tab.active   { color: #10182A; font-weight: 500; border-bottom-color: #2563eb; }
/* Inert, but still hoverable so the title tooltip explains what it is. */
.col-tab.disabled { color: #c8ccd4; cursor: default; }
.col-tab-badge {
  background: #f3f4f6; color: #b6bac3;
  font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: 20px;
}

.col-left { width: 25%; flex-shrink: 0; }

.col-mid,
.col-right {
  width: 37.5%; flex-shrink: 1;
  background: #fff; border: 1px solid #E5E7EB; border-radius: 12px;
  overflow: hidden;
  display: flex; flex-direction: column;
}

.col-inner { padding: 20px; overflow-y: auto; flex: 1; }

.col-title { font-size: 15px; font-weight: 500; color: #10182A; margin-bottom: 3px; }
.col-sub   { font-size: 12px; color: #9ca3af; margin-bottom: 16px; }

/* Compact prompt (left col) */
.prompt-card.compact { box-shadow: none; border-radius: 8px; padding: 14px; margin-bottom: 16px; width: 100%; }
.prompt-card.compact h3                  { font-size: 13px; }
.prompt-card.compact .prompt-textarea    { font-size: 13px; min-height: 64px; background: #fafafa; pointer-events: none; }
.prompt-card.compact .btn-gen            { font-size: 12px; padding: 5px 12px; }

/* ── T-shirt area ── */
.tshirt-area { display: flex; flex-direction: column; align-items: center; padding: 8px 0 12px; }

.tshirt-loader { width: 220px; height: 240px; object-fit: contain; display: none; }
@keyframes pulse { 0%,100% { opacity: .9; } 50% { opacity: .45; } }
.tshirt-loader.pulsing { animation: pulse 1.4s ease-in-out infinite; }

.tshirt-carousel { display: none; flex-direction: column; align-items: center; }
.tshirt-img      { width: 220px; height: 240px; object-fit: contain; }
.carousel-counter { font-size: 11px; color: #9ca3af; margin-top: 6px; }

.nav-arrows { display: flex; gap: 8px; margin-top: 10px; }
.arrow-btn {
  width: 30px; height: 30px;
  border: 1px solid #e5e7eb; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; background: white; color: #6b7280;
  user-select: none; font-size: 13px;
}
.arrow-btn:hover { border-color: #9ca3af; }

/* ── Skeleton shimmer ── */
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.sk {
  display: inline-block; border-radius: 4px; vertical-align: middle;
  background: linear-gradient(90deg, #ececec 25%, #e0e0e0 50%, #ececec 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
}

/* ── Attributes table ── */
.attr-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.attr-table th { text-align: left; font-weight: 500; color: #9ca3af; padding: 7px 0; border-bottom: 1px solid #e5e7eb; font-size: 12px; }
.attr-table th.r { text-align: right; }
.attr-table td   { padding: 9px 0; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.attr-table .n   { color: #374151; }
.attr-table .v   { text-align: right; color: #111827; }
.attr-table .pv  { text-align: right; color: #9ca3af; text-decoration: line-through; font-size: 12px; }
.attr-table .nv  { text-align: right; color: #111827; font-weight: 500; }

/* ── Recommendations ── */
.rec-card { border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 500; margin-bottom: 8px; }
.bw { background: #fef3c7; color: #92400e; }
.bb { background: #fee2e2; color: #991b1b; }
.rec-title   { font-size: 13px; font-weight: 500; margin-bottom: 6px; color: #111827; }
.rec-body    { font-size: 12.5px; color: #4b5563; line-height: 1.55; }
.rec-body strong { color: #111827; }
.rec-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.btn-rej { padding: 5px 14px; background: white; border: 1px solid #e5e7eb; border-radius: 6px; font-size: 12.5px; cursor: pointer; font-family: inherit; }
.btn-rej:hover { background: #f9fafb; }
.btn-acc { padding: 5px 14px; background: #2563eb; color: white; border: none; border-radius: 6px; font-size: 12.5px; cursor: pointer; font-family: inherit; }
.btn-acc:hover { background: #1d4ed8; }
.rec-done { text-align: center; color: #9ca3af; font-size: 13px; padding: 48px 20px; }

/* ── Rules drawer ── */
/* The drawer is fixed at the bottom. Its header (44px) is always visible.
   The body (60vh) is hidden below — slides up on open. */
.rules-drawer {
  position: fixed;
  bottom: 0; left: 90px; right: 24px;
  height: calc(44px + 60vh);
  background: white;
  border-top: 1px solid #e5e7eb;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,.08);
  z-index: 50;
  display: flex; flex-direction: column;
  transform: translateY(60vh);
  transition: transform .3s cubic-bezier(.4,0,.2,1), box-shadow .2s;
}
.rules-drawer:not(.open):not(.hidden):hover {
  transform: translateY(calc(60vh - 6px));
  box-shadow: 0 -10px 32px rgba(0,0,0,.16);
}
.rules-drawer.open   { transform: translateY(0); }
.rules-drawer.hidden { transform: translateY(100%); }

/* Header — always visible, acts as the handle */
.rules-drawer-hd {
  height: 44px; flex-shrink: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.rules-drawer.open .rules-drawer-hd { border-bottom-color: #e5e7eb; }

.rules-label {
  font-weight: 500; color: #111827;
  user-select: none;
}

.rules-close {
  margin-left: auto;
  cursor: pointer; color: #9ca3af; font-size: 20px; line-height: 1;
  opacity: 0; transition: opacity .2s;
  pointer-events: none;
}
.rules-drawer.open .rules-close { opacity: 1; pointer-events: auto; }

/* Body — scrollable table */
.rules-drawer-body { flex: 1; overflow-y: auto; }

.rules-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rules-table th {
  position: sticky; top: 0; background: white;
  text-align: left; font-weight: 500; color: #9ca3af; font-size: 12px;
  padding: 10px 16px; border-bottom: 1px solid #e5e7eb;
}
.rules-table th.r, .rules-table td.r { text-align: right; }
.rules-table td { padding: 11px 16px; border-bottom: 1px solid #f3f4f6; color: #374151; vertical-align: middle; }
.rules-table tr:hover td { background: #fafafa; }

.rule-cb-cell { width: 36px; }
.rule-cb {
  width: 16px; height: 16px;
  border: 1.5px solid #d1d5db; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; background: white;
  transition: background .1s, border-color .1s;
  vertical-align: middle;
}
.rule-cb.checked { background: #2563eb; border-color: #2563eb; }
.rule-cb.checked::after { content: '✓'; color: white; font-size: 10px; font-weight: 700; }

.rule-owner { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.rule-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: #e5e7eb; display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600; color: #374151; flex-shrink: 0;
}
.rule-team-pill {
  display: inline-block; padding: 2px 8px;
  background: #f3f4f6; border-radius: 20px;
  font-size: 11px; color: #374151; white-space: nowrap;
}
.rule-date { color: #9ca3af; font-size: 12px; white-space: nowrap; }
.rule-more { color: #9ca3af; cursor: pointer; font-size: 16px; padding: 0 4px; }
.rule-more:hover { color: #374151; }
