/* ==========================================================================
   ChatGPT PWA - Modern Design System (Dark & Light Theme)
   ========================================================================== */

:root {
  /* Dark Theme (Default) */
  --bg-primary: #212121;
  --bg-secondary: #171717;
  --bg-tertiary: #2f2f2f;
  --bg-hover: #2b2b2b;
  --bg-input: #2f2f2f;
  --bg-card: #282828;
  --border-color: #383838;
  --border-subtle: #2d2d2d;
  --text-primary: #ececec;
  --text-secondary: #b4b4b4;
  --text-muted: #737373;
  --accent-emerald: #10a37f;
  --accent-emerald-hover: #1a7f64;
  --accent-blue: #3b82f6;
  --danger-color: #ef4444;
  --sidebar-width: 260px;
  --header-height: 56px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'Fira Code', 'Cascadia Code', Consolas, Monaco, 'Courier New', monospace;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 26px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f9f9f9;
  --bg-tertiary: #f0f0f0;
  --bg-hover: #e5e5e5;
  --bg-input: #f4f4f4;
  --bg-card: #ffffff;
  --border-color: #e5e5e5;
  --border-subtle: #f0f0f0;
  --text-primary: #0d0d0d;
  --text-secondary: #5d5d5d;
  --text-muted: #8e8e8e;
  --accent-emerald: #10a37f;
  --accent-emerald-hover: #0d8a6b;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
}

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

html, body {
  width: 100%;
  height: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  outline: none;
}

input, textarea, select {
  font-family: inherit;
  color: inherit;
  outline: none;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Layout App Container */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s ease, margin-left 0.3s ease;
  z-index: 50;
  position: relative;
}

.sidebar.collapsed {
  margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-header {
  padding: 14px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-new-chat {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}

.btn-new-chat:hover {
  background-color: var(--bg-tertiary);
  border-color: var(--border-color);
}

.btn-new-chat-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-chatgpt-small {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.btn-sidebar-toggle {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
}

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

/* Search Chats Bar */
.search-container {
  padding: 0 12px 8px 12px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 13px;
}

.search-box input {
  background: transparent;
  border: none;
  width: 100%;
  font-size: 13px;
  color: var(--text-primary);
}

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

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

.chat-group-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 10px 6px 10px;
}

.chat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
  position: relative;
  group: hover;
  cursor: pointer;
}

.chat-item:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.chat-item.active {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 500;
}

.chat-item-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  padding-right: 6px;
}

.chat-item-actions {
  display: none;
  align-items: center;
  gap: 4px;
}

.chat-item:hover .chat-item-actions,
.chat-item.active .chat-item-actions {
  display: flex;
}

.chat-action-btn {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: var(--transition);
}

.chat-action-btn:hover {
  color: var(--text-primary);
  background-color: var(--border-color);
}

.chat-action-btn.delete:hover {
  color: var(--danger-color);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.footer-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--transition);
  width: 100%;
}

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

.provider-pill {
  margin-left: auto;
  font-size: 11px;
  padding: 2px 7px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--accent-emerald);
  font-weight: 600;
}

/* ==========================================================================
   Main Chat Area
   ========================================================================== */
.main-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  background-color: var(--bg-primary);
  overflow: hidden;
}

/* Header */
.chat-header {
  height: var(--header-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid transparent;
  z-index: 10;
  position: relative;
}

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

.header-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
}

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

/* Model Selector Dropdown Trigger */
.model-selector-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  transition: var(--transition);
}

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

.model-selector-btn svg {
  color: var(--text-muted);
  transition: transform 0.2s;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-install-pwa {
  display: none;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--accent-emerald);
  transition: var(--transition);
}

.btn-install-pwa:hover {
  background-color: var(--accent-emerald);
  color: white;
}

/* ==========================================================================
   Chat Messages Scroll Window
   ========================================================================== */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0 140px 0;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}

/* Empty State / Welcome Screen */
.welcome-screen {
  margin: auto;
  max-width: 720px;
  width: 100%;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: fadeIn 0.4s ease;
}

.welcome-logo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10a37f 0%, #0d8a6b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  box-shadow: 0 4px 20px rgba(16, 163, 127, 0.3);
}

.welcome-logo svg {
  width: 36px;
  height: 36px;
  color: white;
}

.welcome-title {
  font-size: 26px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.welcome-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 32px;
  max-width: 500px;
}

.preset-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
}

.preset-card {
  padding: 16px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
}

.preset-card:hover {
  background-color: var(--bg-tertiary);
  border-color: var(--accent-emerald);
  transform: translateY(-2px);
}

.preset-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.preset-card-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Message Rows */
.message-row {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 12px 16px;
  animation: fadeIn 0.25s ease;
}

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

.message-wrapper {
  max-width: 800px;
  width: 100%;
  display: flex;
  gap: 16px;
}

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

.user-bubble {
  max-width: 80%;
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: var(--radius-xl);
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}

.user-bubble-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.user-bubble-img {
  max-width: 220px;
  max-height: 220px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 1px solid var(--border-color);
}

.assistant-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  margin-top: 2px;
}

.assistant-content {
  flex: 1;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-primary);
  overflow-x: auto;
  word-break: break-word;
}

/* Markdown Elements Styling */
.assistant-content p {
  margin-bottom: 14px;
}
.assistant-content p:last-child {
  margin-bottom: 0;
}

.assistant-content h1, 
.assistant-content h2, 
.assistant-content h3, 
.assistant-content h4 {
  margin: 20px 0 10px 0;
  font-weight: 600;
  color: var(--text-primary);
}
.assistant-content h1 { font-size: 22px; }
.assistant-content h2 { font-size: 19px; }
.assistant-content h3 { font-size: 17px; }
.assistant-content h4 { font-size: 15px; }

.assistant-content ul, 
.assistant-content ol {
  margin: 10px 0 14px 24px;
}
.assistant-content li {
  margin-bottom: 6px;
}

.assistant-content blockquote {
  border-left: 3px solid var(--accent-emerald);
  padding: 6px 16px;
  margin: 12px 0;
  color: var(--text-secondary);
  background-color: rgba(16, 163, 127, 0.05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.assistant-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 14px;
}
.assistant-content th, 
.assistant-content td {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  text-align: left;
}
.assistant-content th {
  background-color: var(--bg-tertiary);
  font-weight: 600;
}

.assistant-content a {
  color: var(--accent-emerald);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.inline-code {
  background-color: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 13.5px;
}

/* Code Block Container */
.code-block-container {
  margin: 14px 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background-color: #111111;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background-color: #1e1e1e;
  border-bottom: 1px solid #2a2a2a;
  font-size: 12px;
  color: #999;
}

.code-lang-tag {
  font-family: var(--font-mono);
  font-weight: 600;
  text-transform: uppercase;
}

.btn-copy-code {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  color: #bbb;
  transition: var(--transition);
}

.btn-copy-code:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.btn-copy-code.copied {
  color: var(--accent-emerald);
}

.code-block-container pre {
  padding: 14px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.55;
  color: #d4d4d4;
}

/* Thinking Reasoning Box */
.thinking-wrapper {
  margin-bottom: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: rgba(255, 255, 255, 0.02);
  overflow: hidden;
}

.thinking-details summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--text-secondary);
  transition: var(--transition);
}

.thinking-details summary::-webkit-details-marker {
  display: none;
}

.thinking-details summary:hover {
  background-color: rgba(255, 255, 255, 0.04);
}

.thinking-icon {
  color: var(--accent-blue);
  display: flex;
  align-items: center;
}

.thinking-title {
  font-weight: 600;
  color: var(--text-primary);
}

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

.thinking-arrow {
  margin-left: auto;
  transition: transform 0.2s;
  display: flex;
  align-items: center;
}

.thinking-details[open] .thinking-arrow {
  transform: rotate(180deg);
}

.thinking-body {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-secondary);
  font-style: italic;
  background-color: rgba(0, 0, 0, 0.15);
}

/* Streaming Cursor */
.streaming-cursor {
  display: inline-block;
  width: 8px;
  height: 17px;
  background-color: var(--text-primary);
  margin-left: 4px;
  vertical-align: -2px;
  animation: blink 0.8s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Message Actions Bar (under assistant message) */
.message-actions-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  opacity: 0.85;
}

.btn-msg-action {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: var(--transition);
}

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

/* ==========================================================================
   Floating Input Bar
   ========================================================================== */
.input-floating-wrapper {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px 14px 16px;
  background: linear-gradient(180deg, transparent 0%, var(--bg-primary) 35%);
  pointer-events: none;
  z-index: 20;
}

.input-container {
  width: 100%;
  max-width: 780px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-container:focus-within {
  border-color: #555;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
}

/* Image Attachment Previews */
.input-attachments-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 4px;
}

.attachment-chip {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.attachment-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachment-remove-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.input-main-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.btn-attach {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
  flex-shrink: 0;
}

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

#chatInput {
  flex: 1;
  background: transparent;
  border: none;
  resize: none;
  font-size: 15px;
  line-height: 1.5;
  max-height: 200px;
  min-height: 24px;
  padding: 6px 4px;
  color: var(--text-primary);
}

#chatInput::placeholder {
  color: var(--text-muted);
}

.btn-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--text-primary);
  color: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-send.active {
  opacity: 1;
  cursor: pointer;
}

.btn-send.stop-mode {
  background-color: var(--text-primary);
  color: var(--bg-primary);
  opacity: 1;
  cursor: pointer;
}

.input-footer-note {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: center;
}

/* ==========================================================================
   Modals (Settings, Model Chooser)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(5px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal-backdrop.active {
  display: flex;
}

.modal-content {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
}

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

.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 12px;
  background-color: rgba(0, 0, 0, 0.1);
  overflow-x: auto;
  scrollbar-width: none;
}

.modal-tabs::-webkit-scrollbar {
  display: none;
}

.modal-tab-btn {
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}

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

.modal-tab-btn.active {
  color: var(--accent-emerald);
  border-bottom-color: var(--accent-emerald);
  font-weight: 600;
}

.tab-pane {
  display: none;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.tab-pane.active {
  display: flex !important;
  flex-direction: column !important;
}

.modal-body {
  padding: 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
}

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

.form-input, .form-select, .form-textarea {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent-emerald);
}

.input-password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-password-wrapper input {
  width: 100%;
  padding-right: 40px;
}

.btn-toggle-pwd {
  position: absolute;
  right: 8px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

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

/* Preset Provider Selection Grid */
.provider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 6px;
}

.provider-card-btn {
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-primary);
  text-align: center;
  font-size: 12.5px;
  font-weight: 500;
  transition: var(--transition);
}

.provider-card-btn:hover {
  background-color: var(--bg-tertiary);
}

.provider-card-btn.active {
  border-color: var(--accent-emerald);
  background-color: rgba(16, 163, 127, 0.12);
  color: var(--accent-emerald);
  font-weight: 600;
}

/* Test Connection Banner */
.test-conn-result {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: none;
}

.test-conn-result.success {
  display: block;
  background-color: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.test-conn-result.error {
  display: block;
  background-color: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.modal-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.btn-secondary {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  transition: var(--transition);
}

.btn-secondary:hover {
  background-color: var(--bg-tertiary);
}

.btn-primary {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  background-color: var(--accent-emerald);
  font-size: 13.5px;
  font-weight: 500;
  color: white;
  transition: var(--transition);
}

.btn-primary:hover {
  background-color: var(--accent-emerald-hover);
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight 0.25s ease;
  pointer-events: auto;
}

.toast.success {
  border-left: 4px solid var(--accent-emerald);
}
.toast.error {
  border-left: 4px solid var(--danger-color);
}

/* ==========================================================================
   API Vault & Device Transfer (Kho API & Chuyển máy)
   ========================================================================== */
.sync-banner-card {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sync-banner-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.sync-banner-icon {
  font-size: 22px;
  background-color: rgba(16, 163, 127, 0.15);
  color: var(--accent-emerald);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sync-banner-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.sync-banner-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.sync-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.btn-sync-action {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  text-align: left;
  transition: var(--transition);
  cursor: pointer;
}

.btn-sync-action:hover {
  background-color: var(--bg-hover);
  border-color: var(--accent-emerald);
  transform: translateY(-1px);
}

.btn-sync-action.highlight {
  border-color: rgba(16, 163, 127, 0.4);
  background-color: rgba(16, 163, 127, 0.08);
}

.btn-sync-action.highlight:hover {
  background-color: rgba(16, 163, 127, 0.15);
  border-color: var(--accent-emerald);
}

.sync-btn-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.sync-btn-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.sync-btn-text strong {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.sync-btn-text small {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.sync-code-box {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 4px;
  animation: fadeIn 0.2s ease;
}

/* API Profiles List */
.api-profiles-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 250px;
  overflow-y: auto;
  margin-top: 6px;
  padding-right: 4px;
}

.api-profile-empty {
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
}

.api-profile-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: var(--transition);
}

.api-profile-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.api-profile-card.active-profile {
  border-color: var(--accent-emerald);
  background-color: rgba(16, 163, 127, 0.04);
}

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

.api-profile-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.api-profile-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.api-profile-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 500;
  border: 1px solid var(--border-subtle);
}

.api-profile-active-badge {
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background-color: rgba(16, 185, 129, 0.2);
  color: #34d399;
  font-weight: 600;
}

.api-profile-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.api-profile-key {
  font-family: 'Fira Code', monospace;
  background-color: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.api-profile-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.api-profile-time {
  font-size: 11px;
  color: var(--text-muted);
}

.api-profile-btn-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-profile-act {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border-color);
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  transition: var(--transition);
  cursor: pointer;
}

.btn-profile-act:hover {
  background-color: var(--bg-hover);
}

.btn-profile-act.btn-use {
  background-color: var(--accent-emerald);
  border-color: var(--accent-emerald);
  color: white;
}

.btn-profile-act.btn-use:hover {
  background-color: var(--accent-emerald-hover);
}

.btn-profile-act.btn-delete {
  color: var(--danger-color);
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-profile-act.btn-delete:hover {
  background-color: rgba(239, 68, 68, 0.15);
}

/* ==========================================================================
   Animations & Responsive Breakpoints
   ========================================================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Mobile Screens (< 768px) */
@media (max-width: 768px) {
  .sync-actions-grid {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    margin-left: 0 !important;
  }

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

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 40;
  }

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

  .preset-cards-grid {
    grid-template-columns: 1fr;
  }

  .user-bubble {
    max-width: 90%;
  }

  .messages-container {
    padding-bottom: 160px;
  }
}
