*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f0f0d;
  --surface:   #161614;
  --surface2:  #1e1e1b;
  --surface3:  #252520;
  --border:    rgba(255,255,255,0.07);
  --border2:   rgba(255,255,255,0.12);
  --text:      #e8e6df;
  --text2:     #8a8880;
  --text3:     #5a5855;
  --accent:    #c8a96e;
  --accent2:   #a88a50;
  --accent-bg: rgba(200,169,110,0.08);
  --danger:    #c0533a;
  --success:   #4a9060;
  --font:      'DM Sans', sans-serif;
  --mono:      'DM Mono', monospace;
  --radius:    10px;
  --radius-sm: 6px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* LAYOUT */
.shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* SIDEBAR */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1;
}

.logo-c {
  color: var(--accent);
}

.logo-text {
  color: var(--text);
}

.logo-sub {
  font-size: 11px;
  color: var(--text3);
  font-family: var(--mono);
  margin-top: 4px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 12px 12px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text2);
  font-family: var(--font);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  width: 100%;
}

.nav-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nav-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

.nav-btn.active {
  background: var(--accent-bg);
  color: var(--accent);
}

.sidebar-sessions {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px 0;
  min-height: 0;
}

.sessions-label {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--mono);
  padding: 0 4px;
  margin-bottom: 8px;
}

.sessions-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.session-item {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.session-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.session-item.active {
  background: var(--surface2);
  color: var(--text);
}

.session-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: all 0.15s;
}

.session-item:hover .session-delete {
  opacity: 1;
}

.session-delete:hover {
  color: var(--danger);
}

.session-delete svg {
  width: 13px;
  height: 13px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.new-chat-btn svg {
  width: 14px;
  height: 14px;
}

.new-chat-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* MAIN */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* PANELS */
.panel {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.panel.active {
  display: flex;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-title {
  font-size: 13px;
  font-family: var(--mono);
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.panel-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

/* MESSAGES */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 0;
}

.messages-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 40px;
}

.empty-logo {
  font-family: var(--mono);
  font-size: 48px;
  font-weight: 500;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 4px;
}

.empty-title {
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
}

.empty-sub {
  font-size: 13px;
  color: var(--text3);
  font-family: var(--mono);
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 20px;
}

.suggestion {
  padding: 8px 16px;
  border-radius: 100px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.suggestion:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

/* MESSAGE BUBBLES */
.message {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 800px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message.user {
  align-self: flex-end;
  align-items: flex-end;
}

.message.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.65;
  position: relative;
}

.message.user .message-bubble {
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  border-bottom-right-radius: 3px;
}

.message.assistant .message-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 3px;
}

.message-bubble.important {
  border-color: var(--accent);
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.message-time {
  font-size: 11px;
  color: var(--text3);
  font-family: var(--mono);
}

.star-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text3);
  padding: 0;
  display: flex;
  align-items: center;
  transition: color 0.15s;
  opacity: 0;
}

.message:hover .star-btn {
  opacity: 1;
}

.star-btn.starred,
.star-btn:hover {
  color: var(--accent);
  opacity: 1;
}

.star-btn svg {
  width: 13px;
  height: 13px;
}

/* TYPING INDICATOR */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-bottom-left-radius: 3px;
  width: fit-content;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text3);
  animation: typing 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* INPUT */
.input-area {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 10px 12px;
  transition: border-color 0.15s;
}

.input-wrapper:focus-within {
  border-color: var(--accent);
}

.input-upload-btn {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color 0.15s;
  margin-bottom: 2px;
}

.input-upload-btn svg {
  width: 18px;
  height: 18px;
}

.input-upload-btn:hover {
  color: var(--accent);
}

.input-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  resize: none;
  max-height: 200px;
  line-height: 1.5;
}

.input-textarea::placeholder {
  color: var(--text3);
}

.send-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  margin-bottom: 0;
}

.send-btn svg {
  width: 16px;
  height: 16px;
}

.send-btn:hover {
  background: var(--accent2);
}

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

/* PANEL CONTENT */
.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.section-title {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
}

/* CASCADE SELECTORS */
.cascade-selectors {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.cascade-select {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
  min-width: 160px;
}

.cascade-select:focus {
  border-color: var(--accent);
}

.cascade-select option {
  background: var(--surface2);
}

.search-row {
  display: flex;
  gap: 10px;
}

.doc-search-input {
  flex: 1;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.doc-search-input:focus {
  border-color: var(--accent);
}

.doc-search-input::placeholder {
  color: var(--text3);
}

.search-btn {
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.search-btn:hover {
  background: var(--accent2);
}

.doc-results {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.doc-result-item {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: border-color 0.15s;
}

.doc-result-item:hover {
  border-color: var(--border2);
}

.doc-result-title {
  font-size: 13px;
  color: var(--text);
  font-family: var(--mono);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-result-area {
  font-size: 11px;
  color: var(--text3);
  font-family: var(--mono);
  flex-shrink: 0;
}

.doc-result-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.doc-action-btn {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.doc-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* UPLOAD SECTION */
.upload-drop-zone {
  border: 1px dashed var(--border2);
  border-radius: var(--radius);
  padding: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text3);
}

.upload-drop-zone svg {
  width: 28px;
  height: 28px;
}

.upload-drop-zone:hover,
.upload-drop-zone.drag-over {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

.upload-hint {
  font-size: 12px;
  font-family: var(--mono);
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  font-size: 13px;
  font-family: var(--mono);
  color: var(--text2);
}

.file-remove {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.file-remove:hover {
  color: var(--danger);
}

.file-remove svg {
  width: 14px;
  height: 14px;
}

/* FLUJOS */
.flujos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.flujo-card {
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s;
}

.flujo-card:hover {
  border-color: var(--border2);
}

.flujo-nombre {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.flujo-btn {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.flujo-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

/* MODAL */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}

.modal-box {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  width: 520px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.97) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.modal-close:hover {
  background: var(--surface2);
  color: var(--text);
}

.modal-close svg {
  width: 18px;
  height: 18px;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-secondary {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover {
  border-color: var(--text2);
  color: var(--text);
}

.btn-primary {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: var(--accent2);
}

.upload-selectors {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--border2); }

/* TOAST */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  font-size: 13px;
  z-index: 200;
  animation: toastIn 0.2s ease;
}

.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── BRIEFING BUTTONS ─────────────────────────────────── */
.briefing-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.briefing-btn {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}

.briefing-btn:hover {
  background: var(--accent);
  color: var(--bg);
}
