/* ============ RESET & BASE ============ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a2e;
  --bg-hover: #222240;
  --bg-active: #2a2a4a;
  --surface: #16162a;
  --surface-light: #1e1e36;

  --text-primary: #e8e8f0;
  --text-secondary: #9999b3;
  --text-muted: #666680;

  --accent: #ffffff;
  --accent-hover: #e0e0e0;
  --accent-dim: rgba(255, 255, 255, 0.1);

  --green: #00d26a;
  --green-dim: rgba(0, 210, 106, 0.15);
  --red: #ff4757;
  --red-dim: rgba(255, 71, 87, 0.15);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.15);

  --border: #2a2a40;
  --border-light: #33334d;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --sidebar-width: 280px;
  --topbar-height: 56px;
  --input-height: 72px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100%;
  overflow: hidden;
  display: flex;
  -webkit-font-smoothing: antialiased;
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #0a0a0f;
}

::-webkit-scrollbar-thumb {
  background: #2a2a40;
  border-radius: 4px;
}

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-top: calc(16px + var(--safe-top));
}

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

.wip-icon {
  margin-right: 3px;
}

.wip-text {
  font-weight: 700;
  margin-right: 8px;
  background: linear-gradient(90deg, #ff7a00, #ffb347, #ff7a00);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-icon {
  font-size: 24px;
  color: var(--accent);
  font-weight: 700;
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(2deg, #959595d4, #ffffff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-close {
  display: none;
}

.btn-new-chat {
  margin: 12px 16px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #1a1a2e 0%, #0a0a0f 100%);
  border: 1px solid #33334d;
  border-radius: var(--radius);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: var(--font);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn-new-chat::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #959595d4, #ffffff);
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 1;
}

.btn-new-chat:hover {
  border-color: #444466;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.btn-new-chat .btn-content {
  background: linear-gradient(2deg, #959595d4, #ffffff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-new-chat .btn-content span {
  font-size: 18px;
  font-weight: 700;
  /* Reset the transparent fill so inner span doesn't conflict */
  -webkit-text-fill-color: inherit;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}

.chat-item {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

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

.chat-item.active {
  background: var(--bg-active);
  border-left: 3px solid var(--accent);
}

.chat-item-icon {
  font-size: 14px;
  opacity: 0.5;
  flex-shrink: 0;
}

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

.chat-item-title {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

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

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

.chat-item-delete:hover {
  color: var(--red);
}

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

.btn-settings {
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
  font-family: var(--font);
}

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

/* ============ MAIN ============ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
}

/* ============ TOPBAR ============ */
.topbar {
  height: var(--topbar-height);
  padding: 0 16px;
  padding-top: var(--safe-top);
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-tester-badge {
  background: var(--surface-light);
  border: 1px solid var(--accent);
  color: var(--accent-light);
  font-size: 14px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  display: none;
  /* JS toggles display:inline-flex and .visible */
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
  animation: pulse-glow 2s infinite;
}

.btn-tester-badge.visible {
  display: inline-flex;
}

.btn-tester-badge:hover {
  background: var(--accent);
  color: white;
  transform: scale(1.05);
}

@keyframes pulse-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(77, 171, 245, 0.4);
  }

  70% {
    box-shadow: 0 0 0 10px rgba(77, 171, 245, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(77, 171, 245, 0);
  }
}

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

.context-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface);
  border-radius: 20px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: default;
}

.context-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

.context-dot.warning {
  background: var(--accent);
}

.context-dot.danger {
  background: var(--red);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  line-height: 1;
}

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

#menuBtn {
  display: none;
}

/* ============ MESSAGES ============ */
.messages-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

.messages {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 24px;
}

/* Welcome */
.welcome {
  text-align: center;
  padding: 60px 20px;
}

.welcome-icon {
  font-size: 64px;
  margin-bottom: 20px;
  opacity: 0.3;
}

.welcome h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.welcome p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

.welcome-tips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 32px;
}

.tip {
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.tip:hover {
  background: var(--surface-light);
  color: var(--text-primary);
  border-color: var(--accent);
}

.tip:active {
  transform: scale(0.97);
}

/* Message bubbles */
.message {
  margin-bottom: 20px;
  animation: msgIn 0.3s ease;
}

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.message-user .message-avatar {
  background: var(--blue-dim);
  color: var(--blue);
}

.message-model .message-avatar,
.message-assistant .message-avatar {
  background: var(--accent-dim);
  color: var(--accent);
}

.message-role {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.message-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

.message-body {
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.7;
  overflow-wrap: break-word;
}

.message-user .message-body {
  background: var(--surface);
  border: 1px solid var(--border);
}

.message-model .message-body,
.message-assistant .message-body {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
}

.dev-extraction-highlight {
  background: rgba(255, 171, 0, 0.15);
  border-bottom: 2px dashed var(--warning);
  cursor: help;
  transition: background 0.2s;
  border-radius: 2px;
  padding: 0 2px;
  position: relative;
  display: inline-block;
}

.dev-extraction-highlight:hover {
  background: rgba(255, 171, 0, 0.3);
}

.message-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-start;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.message:hover .message-actions {
  opacity: 1;
}

.btn-action {
  font-size: 14px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-action:hover,
.btn-action.active {
  background: var(--surface-light);
  transform: translateY(-1px);
}

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

/* Hide thumbs feedback buttons as per user request (kept in code) */
.btn-action[title*="odpowiedź"] {
  display: none;
}

/* Error messages and retries */
.error-message {
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: var(--red);
}

.retry-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.btn-retry {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-retry:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.retry-status {
  font-size: 12px;
  color: var(--text-muted);
}

/* Markdown styles within messages */
.message-body h1,
.message-body h2,
.message-body h3 {
  margin: 12px 0 6px;
  color: var(--text-primary);
}

.message-body h1 {
  font-size: 18px;
}

.message-body h2 {
  font-size: 16px;
}

.message-body h3 {
  font-size: 14px;
  color: var(--accent);
}

.message-body p {
  margin-bottom: 6px;
}

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

.message-body ul,
.message-body ol {
  margin: 4px 0;
  padding-left: 24px;
}

.message-body li {
  margin-bottom: 2px;
}

.message-body code {
  font-family: var(--font-mono);
  background: var(--bg-primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--accent);
}

.message-body pre {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin: 10px 0;
  overflow-x: auto;
}

.message-body pre code {
  background: none;
  padding: 0;
  color: var(--text-primary);
}

.message-body strong {
  color: var(--text-primary);
  font-weight: 600;
}

.message-body em {
  color: var(--text-secondary);
}

.message-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 14px;
  margin: 10px 0;
  color: var(--text-secondary);
}

.message-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13px;
}

.message-body th,
.message-body td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
}

.message-body th {
  background: var(--surface);
  font-weight: 600;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 18px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite;
}

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

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

@keyframes typingBounce {

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

  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* ============ INPUT AREA ============ */
.input-area {
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.input-wrapper {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px 8px 8px 18px;
  transition: border-color 0.2s;
}

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

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

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

.btn-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #ffffff;
  border: none;
  color: #000000;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.btn-send:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.btn-send:disabled {
  background: var(--bg-hover);
  color: var(--text-muted);
  cursor: default;
}

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

.input-footer {
  max-width: 800px;
  margin: 4px auto 0;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* ============ MODALS ============ */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.open {
  display: flex;
}

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

.modal-content {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  animation: modalIn 0.3s ease;
}

.modal-large {
  max-width: 600px;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
}

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

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.modal-body {
  padding: 24px;
}

.setting-group {
  margin-bottom: 24px;
}

.setting-group:last-child {
  margin-bottom: 0;
}

.setting-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.setting-group input[type="text"],
.setting-group input[type="password"],
.setting-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.setting-group textarea {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  resize: vertical;
  min-height: 200px;
}

.setting-group input:focus,
.setting-group textarea:focus {
  border-color: var(--accent);
}

.setting-group small {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.input-with-btn {
  display: flex;
  gap: 8px;
}

.input-with-btn input {
  flex: 1;
}

.prompt-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  justify-content: flex-end;
}

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

.btn-sm:hover {
  background: var(--accent-hover);
}

.btn-outline {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

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

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red);
}

.btn-danger:hover {
  background: var(--red);
  color: white;
}

.danger-zone {
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.context-info {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.info-row span:last-child {
  font-weight: 500;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

/* ============ SIDEBAR OVERLAY (mobile) ============ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

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

/* ============ RESPONSIVE / MOBILE ============ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }

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

  .sidebar-close {
    display: block;
  }

  #menuBtn {
    display: block;
  }

  .topbar {
    height: calc(var(--topbar-height) + var(--safe-top));
  }

  .messages {
    padding: 12px;
  }

  .welcome {
    padding: 40px 16px;
  }

  .welcome h1 {
    font-size: 20px;
  }

  .welcome-tips {
    flex-direction: column;
  }

  .tip {
    text-align: left;
  }

  .message-body {
    padding: 12px 14px;
    font-size: 14px;
  }

  .modal-content {
    width: 95%;
    max-height: 90vh;
    margin: 16px;
  }

  .input-wrapper {
    border-radius: var(--radius);
  }

  .context-indicator .context-text {
    display: none;
  }
}

@media (max-width: 380px) {
  .message-body {
    font-size: 13px;
  }

  .message-time {
    display: none;
  }
}

/* ============ LOADING STATES ============ */
.loading-shimmer {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-light) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* ============ TOAST NOTIFICATIONS ============ */
.toast-container {
  position: fixed;
  top: calc(16px + var(--safe-top));
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  animation: toastIn 0.3s ease;
  max-width: 320px;
}

.toast-success {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid var(--green);
}

.toast-error {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red);
}

.toast-info {
  background: var(--blue-dim);
  color: var(--blue);
  border: 1px solid var(--blue);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
}

/* ============ EMPTY STATE ============ */
.empty-chats {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.empty-chats span {
  font-size: 32px;
  display: block;
  margin-bottom: 8px;
}

/* ============ IMAGE PREVIEW ============ */
.image-preview-area {
  max-width: 800px;
  margin: 0 auto 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.image-preview-item {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--border);
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview-item .remove-image {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.image-preview-item .remove-image:hover {
  background: var(--red);
}

.upload-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  z-index: 2;
}

.upload-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.upload-pct {
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

/* ============ ATTACH & MIC BUTTONS ============ */
.btn-attach,
.btn-mic {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 18px;
  padding: 6px;
}

.btn-attach:hover,
.btn-mic:hover {
  color: var(--accent);
}

.btn-mic.recording {
  color: var(--red);
  animation: pulseRec 1s infinite;
}

@keyframes pulseRec {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

.recording-indicator {
  color: var(--red);
  font-size: 12px;
  font-weight: 500;
  animation: pulseRec 1s infinite;
}

.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ============ MESSAGE IMAGES ============ */
.message-images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.message-images img {
  max-width: 200px;
  max-height: 160px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s;
  object-fit: cover;
}

.message-images img:hover {
  transform: scale(1.02);
  border-color: var(--accent);
}

/* Image lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius);
}

/* ============ MODEL SELECTOR ============ */
.topbar-title-area {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.model-selector {
  position: relative;
}

.model-selector-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  font-weight: 500;
}

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

.model-selector-btn .chevron {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.model-selector.open .model-selector-btn .chevron {
  transform: rotate(180deg);
}

.model-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 240px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
  animation: dropdownIn 0.2s ease-out;
}

@keyframes dropdownIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

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

.model-selector.open .model-dropdown {
  display: flex;
}

.model-option {
  padding: 12px;
  cursor: pointer;
  transition: background 0.2s;
  border-bottom: 1px solid var(--border);
}

.model-option:last-child {
  border-bottom: none;
}

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

.model-option.active {
  background: var(--accent-dim);
  border-left: 3px solid var(--accent);
}

.model-option-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.model-option-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============ ERROR & RETRY ============ */
.error-message {
  color: var(--red);
  font-size: 13px;
  background: var(--red-dim);
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--red);
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.retry-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-retry {
  background: var(--accent);
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-retry:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.retry-status {
  font-style: italic;
  color: var(--text-secondary);
  font-size: 12px;
}

/* Developer Mode Styles */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}

.dev-info-bubble {
  background: rgba(0, 191, 165, 0.05);
  border: 1px dashed rgba(0, 191, 165, 0.3);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  display: none;
  /* Shown only in devMode */
}

body.dev-mode .dev-info-bubble {
  display: block;
}

.dev-fact-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  padding-bottom: 2px;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.05);
}

.dev-fact-score {
  font-weight: bold;
  color: var(--warning);
}

.dev-highlight {
  border-bottom: 1px dashed var(--accent);
  cursor: help;
  position: relative;
}

.dev-highlight:hover::after {
  content: attr(data-meta);
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-light);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  font-size: 10px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* ============ INLINE LOGS ============ */
.inline-logs {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 10px;
  padding: 14px;
  font-size: 13px;
  animation: slideDown 0.2s ease-out;
  border-left: 2px solid var(--accent);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

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

.inline-logs h4 {
  margin: 10px 0 6px;
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.log-section {
  margin-bottom: 12px;
}

.log-section:last-child {
  margin-bottom: 0;
}

.log-title {
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  display: block;
}

.log-queries {
  color: var(--text-secondary);
  line-height: 1.4;
  font-style: italic;
}

.log-facts-container {
  background: var(--bg-primary);
  padding: 8px;
  border-radius: 6px;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border-light);
}

.log-fact-item {
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
}

.log-fact-item:last-child {
  border-bottom: none;
}

.log-fact-score {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* Password Overlay */
.password-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 15, 0.98);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.password-card {
  background: var(--bg-secondary);
  padding: 30px;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.password-card .logo {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 20px;
  display: block;
}

.password-card h3 {
  margin-bottom: 10px;
  color: #fff;
}

.password-card p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}

.password-card input {
  width: 100%;
  padding: 12px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: #fff;
  margin-bottom: 15px;
  text-align: center;
}

.masked-input {
  -webkit-text-security: disc;
  text-security: disc;
}

.password-card .btn-primary {
  width: 100%;
  padding: 12px;
  background: #fff;
  color: #000;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.lockout-msg {
  margin-top: 15px;
  color: #ff4d4d;
  font-size: 13px;
  font-weight: 500;
}

/* Backup Actions */
.backup-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.backup-actions .btn-sm {
  flex: 1;
}

/* Video Process Overlay */
.video-process-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-process-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 30px;
  width: 100%;
  max-width: 450px;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.video-process-card h3 {
  margin-bottom: 20px;
  font-weight: 600;
  color: #fff;
}

.video-input-group {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.video-input-group input {
  flex: 1;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  color: #fff;
}

.video-input-group .btn-secondary {
  padding: 0 15px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
}

.video-options {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.video-options label {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

.yt-status {
  margin-top: 15px;
  font-size: 0.9rem;
  min-height: 1.2rem;
}

.yt-status.success {
  color: #10b981;
}

.yt-status.error {
  color: #ef4444;
}

.yt-status.loading {
  color: #3b82f6;
}

.btn-yt {
  color: var(--text-secondary);
  transition: color 0.2s;
}

.btn-yt:hover {
  color: #ff0000;
}

.close-overlay {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}

.close-overlay:hover {
  color: #fff;
}

/* Progress Bar Styles */
.progress-container {
  width: 100%;
  background: var(--bg-main);
  height: 12px;
  border-radius: 6px;
  margin: 20px 0;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

#progressBar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-color), #60a5fa);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#progressTitle {
  background: linear-gradient(135deg, #fff 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700;
}

/* ============ TESTER MODAL ============ */
.modal-tabs {
  display: flex;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.tab-btn {
  padding: 12px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  display: none;
  padding: 10px 0;
}

.tab-content.active {
  display: block;
}

.tester-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  text-align: center;
}

.stat-card label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.stat-card div:not(.status-badge) {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
}

.status-badge.running {
  background: var(--green-dim);
  color: var(--green);
}

.status-badge.offline {
  background: var(--red-dim);
  color: var(--red);
}

.tester-last-trigger,
.tester-last-interaction {
  margin-bottom: 20px;
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.tester-last-trigger h3,
.tester-last-interaction h3 {
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--accent);
}

.trigger-info,
.interaction-preview {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.interactions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 500px;
  overflow-y: auto;
}

.interaction-item {
  background: var(--bg-tertiary);
  padding: 12px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border);
}

.interaction-item.ok {
  border-left-color: var(--green);
}

.interaction-item.error {
  border-left-color: var(--red);
}

.interaction-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.interaction-q {
  font-weight: 600;
  margin-bottom: 4px;
}

.interaction-score {
  font-weight: 700;
  color: var(--accent);
}

.report-view {
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  background: var(--bg-primary);
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}