/* ============================================================
   Taehoney.AI — Gemini-Style Dark Theme v2
   ============================================================ */

/* ---------- Design Tokens ---------- */
:root {
  --bg-primary: #0f0f11;
  --bg-secondary: #18181b;
  --bg-surface: #1e1e23;
  --bg-surface-hover: #26262d;
  --bg-input: #222228;
  --accent: #7c6ff7;
  --accent-light: #a08bfc;
  --accent-glow: rgba(124, 111, 247, 0.25);
  --accent-gradient: linear-gradient(135deg, #7c6ff7, #4ea8f6);
  --bubble-user-bg: linear-gradient(135deg, #3b5cf5 0%, #5b7cf7 100%);
  --bubble-user-text: #ffffff;
  --bubble-ai-bg: #25252c;
  --bubble-ai-text: #d7d7db;
  --text-primary: #ececf1;
  --text-secondary: #a1a1aa;
  --text-muted: #6b6b76;
  --border-color: #2c2c34;
  --border-hover: #3a3a44;
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.15);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.35);
  --shadow-dropdown: 0 8px 32px rgba(0, 0, 0, 0.55);
  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --header-height: 60px;
  --sidebar-width: 300px;
  --input-max-width: 780px;
}

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 100px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* ===================== HEADER ===================== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(15, 15, 17, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 100;
  gap: 8px;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-toggle:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.logo {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  user-select: none;
  white-space: nowrap;
}

.logo-dot {
  font-weight: 700;
}

.header-spacer {
  flex: 1;
}

/* --- Header Dropdowns --- */
.header-dropdown {
  position: relative;
}

.dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 100px;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.dropdown-trigger:hover {
  border-color: var(--accent);
  background: var(--bg-surface-hover);
}

.dropdown-trigger.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.dropdown-trigger-icon {
  gap: 5px;
}

.dropdown-trigger-icon .param-label {
  font-weight: 600;
}

.dropdown-chevron {
  transition: transform var(--transition-fast);
  opacity: 0.6;
}

.dropdown-trigger.active .dropdown-chevron {
  transform: rotate(180deg);
}

/* Dropdown Panel */
.dropdown-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 280px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-dropdown);
  padding: 16px;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity var(--transition-fast), visibility var(--transition-fast), transform var(--transition-fast);
}

.dropdown-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-panel-right {
  left: auto;
  right: 0;
}

.dropdown-panel-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Model List in Dropdown */
.model-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.model-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
  position: relative;
}

.model-option:hover {
  background: var(--bg-surface-hover);
}

.model-option input[type="radio"] {
  display: none;
}

.model-radio {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-hover);
  border-radius: 50%;
  position: relative;
  transition: border-color var(--transition-fast);
  flex-shrink: 0;
}

.model-radio::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%) scale(0);
  transition: transform var(--transition-fast);
}

.model-option input[type="radio"]:checked~.model-radio {
  border-color: var(--accent);
}

.model-option input[type="radio"]:checked~.model-radio::after {
  transform: translate(-50%, -50%) scale(1);
}

.model-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
}

.model-badge {
  font-size: 0.58rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: auto;
}

.badge-new {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
}

.badge-default {
  background: var(--accent-glow);
  color: var(--accent-light);
}

.badge-legacy {
  background: rgba(161, 161, 170, 0.12);
  color: var(--text-muted);
}

.badge-open {
  background: rgba(96, 165, 250, 0.15);
  color: #60a5fa;
}

.model-section-title {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 16px 4px;
  margin-top: 4px;
}

.model-section-title:first-child {
  margin-top: 0;
  padding-top: 4px;
}

/* Sliders in Dropdown */
.slider-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 0;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
}

.slider-value {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-light);
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.slider-range {
  display: flex;
  justify-content: space-between;
  font-size: 0.66rem;
  color: var(--text-muted);
}

.custom-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  background: var(--border-color);
  border-radius: 100px;
  outline: none;
  cursor: pointer;
}

.custom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
  cursor: pointer;
  transition: box-shadow var(--transition-fast);
}

.custom-slider::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 6px var(--accent-glow);
}

.custom-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  box-shadow: 0 0 0 4px var(--accent-glow);
  cursor: pointer;
}

/* ===================== APP LAYOUT ===================== */
.app-layout {
  display: flex;
  height: 100dvh;
  padding-top: var(--header-height);
}

/* ===================== SIDEBAR — CHAT HISTORY ===================== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-smooth);
  z-index: 90;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 14px;
  flex: 1;
  overflow: hidden;
}

/* New Chat Button */
.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px;
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
  flex-shrink: 0;
}

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

/* Search Box */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  flex-shrink: 0;
  transition: border-color var(--transition-fast);
}

.search-box:focus-within {
  border-color: var(--accent);
}

.search-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 0.82rem;
  color: var(--text-primary);
  padding: 9px 0;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-clear {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  transition: color var(--transition-fast);
}

.search-clear:hover {
  color: var(--text-primary);
}

.search-clear.visible {
  display: flex;
}

/* Chat List */
.chat-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-align: center;
  padding: 24px 0;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
  position: relative;
  min-height: 42px;
}

.chat-item:hover {
  background: var(--bg-surface-hover);
}

.chat-item.active {
  background: var(--bg-surface);
}

.chat-item-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.chat-item.active .chat-item-icon {
  background: var(--accent-glow);
  color: var(--accent-light);
}

.chat-item-content {
  flex: 1;
  min-width: 0;
}

.chat-item-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-preview {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.chat-item-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

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

.chat-item-delete:hover {
  color: var(--danger);
  background: var(--danger-glow);
}

.chat-item-highlight {
  background: rgba(124, 111, 247, 0.25);
  border-radius: 2px;
  padding: 0 1px;
}

/* ===================== OVERLAY ===================== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 80;
  backdrop-filter: blur(4px);
}

/* ===================== CHAT MAIN ===================== */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 32px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Welcome */
.welcome-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  gap: 12px;
  animation: fadeInUp 0.6s ease;
}

.welcome-icon {
  font-size: 3rem;
  line-height: 1;
  animation: float 3s ease-in-out infinite;
}

.welcome-title {
  font-size: 1.8rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.7;
}

/* Message Bubbles */
.message-row {
  display: flex;
  gap: 12px;
  max-width: var(--input-max-width);
  width: 100%;
  margin: 0 auto;
  animation: fadeInUp 0.35s ease;
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.ai {
  justify-content: flex-start;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 4px;
}

.message-row.ai .message-avatar {
  background: var(--accent-gradient);
  color: #fff;
}

.message-row.user .message-avatar {
  background: #3b5cf5;
  color: #fff;
  order: 2;
}

.message-bubble {
  padding: 12px 18px;
  border-radius: var(--radius-lg);
  max-width: 75%;
  line-height: 1.65;
  font-size: 0.93rem;
  word-break: break-word;
}

.message-row.user .message-bubble {
  background: var(--bubble-user-bg);
  color: var(--bubble-user-text);
  border-bottom-right-radius: var(--radius-sm);
}

.message-row.ai .message-bubble {
  background: var(--bubble-ai-bg);
  color: var(--bubble-ai-text);
  border-bottom-left-radius: var(--radius-sm);
}

.message-bubble p {
  margin: 0 0 8px;
}

.message-bubble p:last-child {
  margin-bottom: 0;
}

.message-bubble code {
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: 'Fira Code', 'Courier New', monospace;
}

.message-bubble pre {
  background: rgba(0, 0, 0, 0.35);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 10px 0;
  font-size: 0.83rem;
  line-height: 1.55;
}

.message-bubble pre code {
  background: none;
  padding: 0;
}

.message-bubble ul,
.message-bubble ol {
  padding-left: 20px;
  margin: 8px 0;
}

.message-bubble li {
  margin-bottom: 4px;
}

.message-bubble strong {
  font-weight: 700;
  color: #fff;
}

.message-bubble h1,
.message-bubble h2,
.message-bubble h3 {
  margin: 12px 0 6px;
  font-weight: 700;
  color: #fff;
}

.message-bubble h1 {
  font-size: 1.2em;
}

.message-bubble h2 {
  font-size: 1.1em;
}

.message-bubble h3 {
  font-size: 1.0em;
}

/* Loading */
.loading-row {
  display: flex;
  gap: 12px;
  max-width: var(--input-max-width);
  width: 100%;
  margin: 0 auto;
  animation: fadeInUp 0.35s ease;
}

.loading-bubble {
  background: var(--bubble-ai-bg);
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 10px;
}

.loading-text {
  font-size: 0.88rem;
  color: var(--accent-light);
  font-weight: 500;
}

.loading-dots {
  display: flex;
  gap: 4px;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: dotBounce 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

/* ===================== INPUT AREA ===================== */
.input-area {
  padding: 12px 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.input-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: var(--input-max-width);
  padding: 0 4px;
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 100px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.toolbar-btn:hover {
  border-color: var(--text-secondary);
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
}

.toolbar-btn.active {
  border-color: var(--accent);
  color: var(--accent-light);
  background: var(--accent-glow);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.15);
}

.toolbar-btn svg {
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 8px 8px 8px 20px;
  width: 100%;
  max-width: var(--input-max-width);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-wrapper textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  resize: none;
  line-height: 1.55;
  max-height: 150px;
  padding: 6px 0;
}

.input-wrapper textarea::placeholder {
  color: var(--text-muted);
}

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--accent-gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.send-btn:hover {
  transform: scale(1.08);
}

.send-btn:active {
  transform: scale(0.95);
}

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

.input-disclaimer {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
}

/* ===================== DELETE MODAL ===================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 500;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px);
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px 28px;
  min-width: 300px;
  animation: fadeInUp 0.2s ease;
}

.modal-text {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 20px;
  text-align: center;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.modal-btn {
  padding: 9px 24px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-btn-cancel {
  background: var(--bg-surface);
  color: var(--text-secondary);
}

.modal-btn-cancel:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.modal-btn-danger {
  background: var(--danger);
  color: #fff;
}

.modal-btn-danger:hover {
  background: #dc2626;
}

/* ===================== ANIMATIONS ===================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

@keyframes dotBounce {

  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: scale(0.8);
  }

  40% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* ===================== RESPONSIVE ===================== */
@media (max-width:820px) {
  .sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    z-index: 90;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.active {
    display: block;
  }

  .chat-messages {
    padding: 24px 16px 12px;
  }

  .input-area {
    padding: 10px 16px 16px;
  }

  .message-bubble {
    max-width: 88%;
  }

  .param-label {
    display: none;
  }

  .dropdown-trigger {
    padding: 7px 10px;
    font-size: 0.78rem;
  }
}

@media (max-width:480px) {
  :root {
    --sidebar-width: 280px;
  }

  .logo {
    font-size: 1.1rem;
  }

  .dropdown-trigger-text {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .welcome-title {
    font-size: 1.4rem;
  }

  .welcome-subtitle {
    font-size: 0.9rem;
  }

  .message-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.7rem;
  }
}