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

:root {
  --bg-dark: #050507;
  --bg-chat: #0d0d12;
  --sidebar-bg: #000000;
  --card-bg: #121319;
  --card-hover: #191b24;
  --border: #212530;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --text-main: #ececec;
  --text-muted: #8e8ea0;
  --text-dim: #5d5d6c;
  --accent: #2563eb;
  --accent-glow: rgba(37, 99, 235, 0.3);
  --accent-gradient: linear-gradient(135deg, #2563eb, #4f46e5);
  --ok: #10b981;
  --ok-bg: rgba(16, 185, 129, 0.15);
  --err: #ef4444;
  --err-bg: rgba(239, 68, 68, 0.15);
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'Fira Code', monospace;
}

body.chatgpt-theme {
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  height: 100vh;
  overflow: hidden;
}

/* APP LAYOUT */
.app-layout {
  display: flex;
  width: 100vw;
  height: 100vh;
}

/* LEFT SIDEBAR (CHATGPT STYLE) */
.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px;
  transition: transform 0.3s ease, margin-left 0.3s ease;
  z-index: 50;
}

.sidebar.collapsed {
  margin-left: -260px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 0 12px var(--accent-glow);
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.new-chat-btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
}
.new-chat-btn:hover {
  background: var(--card-hover);
  border-color: #3b82f6;
}
.plus-icon { font-size: 18px; font-weight: bold; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 14px;
}

.nav-item {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.nav-item:hover { background: var(--card-hover); color: var(--text-main); }
.nav-item.active { background: rgba(59, 130, 246, 0.15); color: #60a5fa; font-weight: 600; }

.sidebar-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-top: 20px;
  overflow: hidden;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  padding: 0 8px 8px;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-item {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.2s;
}
.history-item:hover { background: var(--card-hover); color: var(--text-main); }
.history-item.active { background: #1e2536; color: #fff; font-weight: 500; }

.history-actions {
  display: none;
  gap: 4px;
}
.history-item:hover .history-actions { display: flex; }

.sidebar-footer {
  padding: 12px 8px 4px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f59e0b;
  color: #000;
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-info { display: flex; flex-direction: column; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; }
.user-plan { font-size: 11px; color: var(--text-dim); }

/* MAIN WRAPPER */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-chat);
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* TOP BAR */
.top-bar {
  height: 54px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--bg-dark);
}

.top-bar-left, .top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.model-dropdown-wrapper select {
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-weight: 600;
  font-size: 13.5px;
  padding: 6px 12px;
  border-radius: 10px;
  outline: none;
  cursor: pointer;
}

.token-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.pill-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.badge-tag { background: rgba(59, 130, 246, 0.2); color: #60a5fa; padding: 2px 6px; border-radius: 10px; font-size: 11px; font-weight: 600; }

/* CHAT WORKSPACE SPLIT */
.chat-workspace-split {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  position: relative;
  padding: 0 16px;
}

/* HERO WELCOME SCREEN (ChatGPT style ¿Qué toca hoy?) */
.hero-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
}

.hero-title {
  font-size: 32px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
}

.hero-sub {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 32px;
  max-width: 500px;
}

.quick-suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 680px;
}

.suggestion-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  text-align: left;
  color: var(--text-main);
  font-size: 13.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
}
.suggestion-card:hover {
  background: var(--card-hover);
  border-color: var(--text-muted);
}
.suggestion-card .icon { font-size: 22px; }

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

.msg {
  display: flex;
  gap: 16px;
  max-width: 100%;
  line-height: 1.65;
  font-size: 14.5px;
}

.msg.user {
  justify-content: flex-end;
}
.msg.user .msg-bubble {
  background: #232733;
  color: #fff;
  border-radius: 18px;
  border-bottom-right-radius: 4px;
  padding: 12px 18px;
  max-width: 80%;
}

.msg.bot {
  justify-content: flex-start;
}
.msg.bot .msg-bubble {
  background: transparent;
  color: var(--text-main);
  max-width: 100%;
}

.msg-attachments {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.attachment-img-preview {
  max-width: 240px;
  max-height: 240px;
  border-radius: 10px;
  border: 1px solid var(--border);
  object-fit: cover;
}

/* MEDIA PREVIEW THUMBNAILS BAR ABOVE INPUT */
.media-preview-bar {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.preview-title { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.media-thumbnails { display: flex; gap: 8px; flex-wrap: wrap; }
.media-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.media-thumb img, .media-thumb video {
  width: 100%; height: 100%; object-fit: cover;
}
.media-thumb-remove {
  position: absolute;
  top: 2px; right: 2px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border-radius: 50%;
  width: 16px; height: 16px;
  font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}

/* FLOATING CHATGPT INPUT BAR */
.chat-input-wrapper {
  position: absolute;
  bottom: 0;
  left: 16px; right: 16px;
  padding-bottom: 16px;
  background: linear-gradient(180deg, transparent, var(--bg-chat) 30%);
}

.chat-input-box {
  background: #181820;
  border: 1px solid #282836;
  border-radius: 26px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  transition: border-color 0.2s ease;
}
.chat-input-box:focus-within {
  border-color: #4b5563;
}

.attach-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #272733;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  cursor: pointer;
  transition: background 0.2s;
}
.attach-btn:hover { background: #343444; }

.chat-input-box textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.5;
  resize: none;
  max-height: 180px;
  padding: 6px 0;
}

.input-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.send-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #ffffff;
  color: #000000;
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: opacity 0.2s;
}
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.send-icon { font-size: 18px; font-weight: bold; }

.input-footer-info {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
  padding: 0 8px;
}

/* RIGHT PANEL: CODEX SANDBOX */
.right-panel {
  width: 480px;
  background: var(--bg-dark);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px;
  transition: margin-right 0.3s ease;
}
.right-panel.hidden { display: none; }

.sandbox-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border-radius: 12px;
  padding: 14px;
  border: 1px solid var(--border);
}

.sandbox-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.sandbox-title h3 { font-size: 14px; font-weight: 700; }
.sandbox-actions { display: flex; gap: 6px; }

.sandbox-subnav { display: flex; gap: 4px; background: #0b0d13; padding: 4px; border-radius: 8px; margin-bottom: 10px; }
.tab-btn { flex: 1; background: transparent; border: none; color: var(--text-muted); padding: 6px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; }
.tab-btn.active { background: var(--card-bg); color: #60a5fa; }

.drop-zone { border: 2px dashed var(--border); border-radius: 8px; padding: 10px; text-align: center; font-size: 11.5px; color: var(--text-dim); margin-bottom: 10px; }
.drop-zone.dragover { border-color: var(--accent); background: rgba(37,99,235,0.08); }

.tab-content { display: none; flex: 1; flex-direction: column; }
.tab-content.active { display: flex; }

.file-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.file-item { background: #08090d; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; display: flex; align-items: center; justify-content: space-between; }
.file-name { font-size: 12.5px; font-weight: 600; cursor: pointer; }
.file-name:hover { color: var(--accent); }

#codeEditor { flex: 1; font-family: var(--font-mono); font-size: 12.5px; background: #050608; color: #e2e8f0; border-radius: 8px; padding: 12px; resize: none; white-space: pre; border: 1px solid var(--border); }
#livePreviewFrame { width: 100%; height: 100%; border: none; background: #fff; border-radius: 8px; }

/* CONFIG CARD OVERLAY */
.config-card { margin: 12px 16px; }

/* VAULT MODAL */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 640px; max-height: 80vh; display: flex; flex-direction: column; }
.modal-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 18px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.vault-item { background: #08090d; border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }

/* BUTTONS */
.btn { padding: 8px 14px; border-radius: 8px; border: none; font-weight: 600; cursor: pointer; font-size: 13px; }
.btn.primary { background: var(--accent-gradient); color: #fff; }
.btn.secondary { background: var(--card-bg); color: var(--text-main); border: 1px solid var(--border); }
.btn.secondary-sm, .btn.primary-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.ghost-btn, .ghost-btn-sm { background: transparent; border: 1px solid var(--border); color: var(--text-muted); border-radius: 6px; padding: 4px 8px; font-size: 12px; cursor: pointer; }
.icon-btn, .icon-btn-sm { background: transparent; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; }
.link-btn, .link-btn-xs { background: none; border: none; color: var(--accent); font-size: 11px; cursor: pointer; text-decoration: underline; }

.hidden { display: none !important; }

/* INJECTOR & QUEUE TABLE STYLING */
#injectorTextarea {
  width: 100%;
  background: #08090e;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 10px 12px;
  resize: vertical;
  outline: none;
}
#injectorTextarea:focus { border-color: var(--accent); }

.queue-table {
  background: #08090e;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  max-height: 220px;
  overflow-y: auto;
}

.queue-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
}
.queue-row:last-child { border-bottom: none; }

.queue-key { font-family: var(--font-mono); color: var(--text-muted); }
.queue-provider { font-weight: 600; color: #60a5fa; }
.queue-status { font-weight: 600; }
.queue-status.pending { color: var(--warn); }
.queue-status.ok { color: var(--ok); }
.queue-status.err { color: var(--err); }

