/* ==========================================================================
   FayezAI Web - Design System & Stylesheet (Arabic RTL)
   Matches Official FayezAI Mobile App Color Palette & Typography
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@300;400;500;600;700;800&family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&display=swap');

:root {
  /* Brand Core Palette */
  --primary-blue: #0284c7;
  --primary-sky: #38bdf8;
  --accent-indigo: #6366f1;
  --accent-cyan: #06b6d4;

  /* Functional Colors */
  --color-error: #ef4444;
  --color-success: #10b981;
  --color-warning: #f59e0b;

  /* Fonts - Matches ChatGPT typographic system with Arabic font fallback hierarchy */
  --font-family-arabic: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'SF Pro Arabic', 'Noto Sans Arabic', 'IBM Plex Sans Arabic', Tahoma, sans-serif;
  --font-family-mono: 'Fira Code', 'Cascadia Code', Consolas, Monaco, monospace;

  /* Dimensions & Spacing */
  --sidebar-width: 290px;
  --header-height: 64px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

/* Dark Theme (Default FayezAI Theme - Preserved 100% Unchanged) */
[data-theme='dark'],
:root {
  --bg-color: #0b0f19;
  --surface-color: #131a29;
  --surface-elevated: #1e293b;
  --border-color: #233047;
  --border-hover: #334155;

  --user-bubble: #0369a1;
  --user-bubble-text: #f8fafc;
  --user-bubble-border: transparent;
  --user-bubble-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  --assistant-bubble: #162032;
  --assistant-bubble-text: #f1f5f9;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --input-bg: #131a29;
  --composer-bg: #131a29;
  --composer-border: #233047;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 12px -1px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.6);
  --brand-glow: 0 0 20px rgba(56, 189, 248, 0.25);
}

/* Light Theme Support - Pure White Background & ChatGPT Light Ice-Blue Bubble */
[data-theme='light'] {
  --bg-color: #ffffff;
  --surface-color: #ffffff;
  --surface-elevated: #f8fafc;
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;

  --user-bubble: #e9f3fd;
  --user-bubble-text: #1b2a3d;
  --user-bubble-border: rgba(2, 132, 199, 0.14);
  --user-bubble-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  --assistant-bubble: transparent;
  --assistant-bubble-text: #0d0d0d;

  --text-primary: #0d0d0d;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --input-bg: #ffffff;
  --composer-bg: #ffffff;
  --composer-border: #e2e8f0;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
  --brand-glow: 0 0 15px rgba(2, 132, 199, 0.15);
}

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

html, body {
  width: 100%;
  height: 100%;
  direction: rtl;
  text-align: right;
  font-family: var(--font-family-arabic);
  font-size: 15px;
  line-height: 1.55;
  background-color: var(--bg-color);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* App Container */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
  background-color: var(--bg-color);
  max-width: 100vw;
  overflow: hidden;
}

/* ==========================================================================
   Sidebar Drawer (RTL Right side)
   ========================================================================== */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background-color: var(--surface-color);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-normal);
  z-index: 50;
  flex-shrink: 0;
}

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

.sidebar-collapse-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.sidebar-collapse-btn:hover {
  color: var(--text-primary);
  background-color: var(--surface-elevated);
}

/* Desktop Collapsed Sidebar State */
.app-container.sidebar-collapsed .sidebar {
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  overflow: hidden !important;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: width var(--transition-normal), opacity var(--transition-normal);
}

@media (min-width: 769px) {
  .app-container.sidebar-collapsed .menu-toggle-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: var(--surface-elevated);
    border: 1px solid var(--border-color);
  }

  .app-container.sidebar-collapsed .header-brand {
    display: flex !important;
    align-items: center;
  }
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand-logo-img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  object-fit: cover;
  flex-shrink: 0;
}

.brand-text-container {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-sky), var(--primary-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.new-chat-btn {
  margin: 14px 16px;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--primary-blue), var(--accent-indigo));
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.new-chat-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: var(--brand-glow);
}

.new-chat-btn:active {
  transform: translateY(0);
}

/* Conversation List */
.conversation-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conversation-list-title {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 8px 10px 4px;
  font-weight: 600;
}

.conversation-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  position: relative;
  border: 1px solid transparent;
}

.conversation-item:hover {
  background-color: var(--surface-elevated);
  color: var(--text-primary);
}

.conversation-item.active {
  background-color: var(--surface-elevated);
  color: var(--primary-sky);
  border-color: var(--border-color);
  font-weight: 600;
}

.conversation-item-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  flex: 1;
}

.conversation-item-icon {
  font-size: 1rem;
  opacity: 0.8;
  flex-shrink: 0;
}

.conversation-item-title {
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

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

.conv-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}

.conv-action-btn:hover {
  color: var(--color-error);
}

/* Sidebar Footer & User Profile */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--surface-color);
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  flex: 1;
  overflow: hidden;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast);
}

.user-profile-badge:hover {
  background-color: var(--surface-elevated);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-blue), var(--accent-indigo));
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-email {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-status {
  font-size: 0.72rem;
  color: var(--color-success);
}

.user-status.guest {
  color: var(--text-muted);
}

/* ==========================================================================
   Main Chat Viewport
   ========================================================================== */
.main-chat-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  background-color: var(--bg-color);
  overflow: hidden;
  min-width: 0;
  max-width: 100%;
}

/* Chat Header */
.chat-header {
  height: var(--header-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--surface-color);
  z-index: 10;
}

.chat-header-start {
  display: flex;
  align-items: center;
  gap: 12px;
}

.menu-toggle-btn {
  display: none;
  background: none;
  border: 1px solid transparent;
  color: var(--text-primary);
  cursor: pointer;
  padding: 7px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.menu-toggle-btn:hover {
  background-color: var(--surface-elevated);
  border-color: var(--border-hover);
}

/* Header Brand (Shown when sidebar is collapsed or on mobile) */
.header-brand {
  display: none;
  align-items: center;
  gap: 9px;
  user-select: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.header-brand:hover {
  opacity: 0.9;
}

.header-brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  object-fit: cover;
}

.header-brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-sky), var(--primary-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

/* Chat Title: Hidden completely from top header bar as per specification */
.current-chat-title {
  display: none !important;
}

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

.sync-status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: var(--radius-full);
  background-color: var(--surface-elevated);
}

.sync-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-muted);
  transition: background-color 0.2s ease;
}

.sync-status-dot.synced {
  background-color: var(--color-success);
}

.sync-status-dot.syncing {
  background-color: var(--color-warning);
  animation: pulse 1s infinite alternate;
}

.sync-status-dot.failed {
  background-color: var(--color-error);
}

.sync-status-dot.idle,
.sync-status-dot.guest {
  background-color: var(--text-muted);
  opacity: 0.6;
}

@keyframes pulse {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

.header-icon-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.header-icon-btn:hover {
  background-color: var(--surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

/* Chat Messages Stream Area */
.chat-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

/* Empty State / Welcome Screen */
.empty-chat-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: auto;
  max-width: 620px;
  text-align: center;
  padding: 30px 16px;
}

.welcome-logo {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
  object-fit: cover;
}

.welcome-title {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 10px;
  background: linear-gradient(135deg, var(--primary-sky), var(--primary-blue), var(--accent-indigo));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-desc {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 30px;
  line-height: 1.6;
}

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

.prompt-card {
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  text-align: right;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.prompt-card:hover {
  background-color: var(--surface-elevated);
  border-color: var(--primary-sky);
  color: var(--text-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.prompt-card strong {
  color: var(--primary-sky);
  font-size: 0.95rem;
}

/* Chat Message Rows & Bubbles */
.message-row {
  display: flex;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  gap: 14px;
}

.message-row.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.message-avatar.assistant {
  background: linear-gradient(135deg, var(--primary-sky), var(--primary-blue));
  color: #ffffff;
}

.message-avatar.user {
  background: linear-gradient(135deg, var(--accent-indigo), var(--primary-blue));
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 700;
}

.message-content-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 76%;
  position: relative;
}

.message-row.user .message-content-wrapper {
  align-items: flex-start;
}

.message-bubble {
  width: fit-content;
  max-width: 100%;
  padding: 7px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.55;
  word-break: break-word;
  position: relative;
  letter-spacing: normal;
  font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1;
}

.message-row.user .message-bubble {
  background-color: var(--user-bubble);
  color: var(--user-bubble-text);
  border: 1px solid var(--user-bubble-border, transparent);
  box-shadow: var(--user-bubble-shadow, var(--shadow-sm));
  border-radius: 18px;
  font-weight: 400;
}

.message-row.assistant .message-bubble,
.message-row.assistant.has-generated-image .message-bubble,
.message-row.assistant:has(.generated-image-card) .message-bubble {
  background-color: transparent !important;
  color: var(--text-primary) !important;
  border: none !important;
  box-shadow: none !important;
  padding: 2px 0 0 0 !important;
  border-radius: 0 !important;
  font-size: 15px;
  line-height: 1.55;
  width: 100%;
}

.message-row.assistant .markdown-body,
.message-row.assistant.has-generated-image .markdown-body,
.message-row.assistant:has(.generated-image-card) .markdown-body {
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: normal;
  font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1;
}

.message-row.assistant .markdown-body > p:first-child,
.message-row.assistant.has-generated-image .markdown-body > p:first-child,
.message-row.assistant:has(.generated-image-card) .markdown-body > p:first-child {
  margin-bottom: 8px;
  font-size: 15px;
  line-height: 1.55;
}

/* Stable Message Footer Row (Timestamp & Hover Actions) - Zero Layout Shift */
.message-footer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  min-height: 28px;
}

.message-row.user .message-footer-row {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

.message-row.assistant .message-footer-row {
  flex-direction: row;
  justify-content: flex-start;
}

.message-timestamp {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0 4px;
  flex-shrink: 0;
}

.message-row.user .message-timestamp {
  text-align: left;
}

/* ChatGPT-Style Hover Action Bar */
.message-actions-bar {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-fast), visibility var(--transition-fast);
}

.message-row:hover .message-actions-bar,
.message-row:focus-within .message-actions-bar,
.message-row.show-actions .message-actions-bar,
.message-actions-bar.is-active {
  opacity: 1;
  visibility: visible;
}

.msg-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  transition: all var(--transition-fast);
}

.msg-action-btn:hover,
.msg-action-btn:focus-visible {
  color: var(--text-primary);
  background-color: var(--surface-elevated);
}

.msg-action-btn.active {
  color: var(--primary-sky);
  background-color: rgba(56, 189, 248, 0.12);
}

.msg-action-btn.success {
  color: var(--color-success);
}

/* Three Dots Dropdown Menu */
.msg-action-menu-wrapper {
  position: relative;
  display: inline-block;
}

.message-dropdown-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  min-width: 215px;
  z-index: 200;
  animation: fadeIn 0.15s ease-out;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-align: right;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.message-dropdown-item:hover,
.message-dropdown-item:focus-visible {
  background-color: var(--surface-elevated);
  color: var(--primary-sky);
}

/* User Message Inline Editor */
.message-inline-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  min-width: 280px;
  background-color: var(--surface-color);
  border: 1.5px solid var(--primary-sky);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  box-shadow: var(--shadow-md);
  animation: fadeIn 0.15s ease-out;
}

.inline-edit-textarea {
  width: 100%;
  min-height: 60px;
  max-height: 220px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.55;
  resize: vertical;
  outline: none;
  direction: rtl;
}

.inline-edit-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.inline-edit-cancel-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.inline-edit-cancel-btn:hover {
  background-color: var(--surface-elevated);
  color: var(--text-primary);
}

.inline-edit-save-btn {
  background-color: var(--primary-blue);
  border: none;
  color: #ffffff;
  padding: 6px 16px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.inline-edit-save-btn:hover {
  background-color: var(--primary-sky);
}

/* Typing Indicator */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--primary-sky);
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   Chat Composer & Bottom Bar
   ========================================================================== */
.chat-composer-container {
  padding: 16px 20px 20px;
  background-color: var(--bg-color);
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

.composer-start-actions {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.attach-menu-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background-color: var(--surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.attach-menu-btn:hover {
  color: var(--primary-sky);
  border-color: var(--primary-sky);
  background-color: rgba(56, 189, 248, 0.12);
  transform: scale(1.06);
  box-shadow: var(--brand-glow);
}

.attach-menu-btn.active {
  background: linear-gradient(135deg, var(--primary-blue), var(--accent-indigo));
  color: #ffffff;
  border-color: transparent;
  transform: rotate(45deg);
}

/* ChatGPT-Style Dropup Menu */
.chatgpt-menu {
  position: absolute;
  bottom: calc(100% + 14px);
  right: 0;
  width: 290px;
  background-color: var(--surface-color);
  border: 1.5px solid var(--border-color);
  border-radius: 18px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 100;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.04);
  animation: menuDropup 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(16px);
}

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

.chatgpt-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: 12px;
  cursor: pointer;
  text-align: right;
  font-family: inherit;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.chatgpt-menu-item:hover {
  background-color: var(--surface-elevated);
  transform: translateX(-2px);
}

.menu-item-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.menu-item-icon.files-icon {
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary-sky);
}

.menu-item-icon.image-icon {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
}

.menu-item-icon.search-icon {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
}

.menu-item-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.menu-item-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.menu-item-subtitle {
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.2;
}

/* Attachment Previews Strip */
.composer-attachments-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 4px 12px;
  width: 100%;
}

.attachment-preview-card {
  position: relative;
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 220px;
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.15s ease-out;
}

.attachment-preview-card.image-card {
  padding: 4px;
  width: 64px;
  height: 64px;
  justify-content: center;
  overflow: hidden;
}

.attachment-preview-card.image-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.att-preview-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.att-preview-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 2px;
}

.att-preview-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.att-preview-size {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.att-preview-remove-btn {
  position: absolute;
  top: -6px;
  left: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: #ef4444;
  color: #ffffff;
  border: 2px solid var(--bg-color);
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--transition-fast);
  box-shadow: var(--shadow-sm);
  z-index: 5;
}

.att-preview-remove-btn:hover {
  transform: scale(1.15);
}

/* User-Attached Direct Images: Frameless, borderless, soft rounded corners */
.user-images-gallery {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 100%;
  margin-bottom: 6px;
  align-items: flex-start;
}

.user-attached-image-wrapper {
  position: relative;
  display: inline-block;
  cursor: pointer;
  border-radius: var(--radius-lg);
  overflow: hidden;
  max-width: 340px;
  max-height: 340px;
  background: transparent;
  border: none;
  box-shadow: none;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.user-attached-image-wrapper:hover {
  transform: scale(1.015);
  box-shadow: var(--shadow-md);
}

.user-attached-img {
  display: block;
  width: 100%;
  max-width: 340px;
  max-height: 340px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  border: none;
  outline: none;
}

/* Drag and Drop Upload Overlay */
.drag-drop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(2, 132, 199, 0.1);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 2px dashed var(--primary-sky);
  border-radius: var(--radius-lg);
  margin: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 500;
  pointer-events: none;
  animation: fadeIn 0.15s ease-out;
}

.drag-drop-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background-color: var(--surface-color);
  padding: 28px 40px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  text-align: center;
  max-width: 90%;
}

.drag-drop-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(2, 132, 199, 0.12);
  color: var(--primary-sky);
  display: flex;
  align-items: center;
  justify-content: center;
}

.drag-drop-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.drag-drop-subtitle {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

/* Chat Bubble Attachment Rendering */
.bubble-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.bubble-attachment-img {
  max-width: 320px;
  max-height: 320px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.bubble-attachment-img:hover {
  transform: scale(1.02);
}

.bubble-attachment-doc {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background-color: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  max-width: 260px;
}

.bubble-attachment-doc .doc-icon {
  font-size: 1.3rem;
}

.bubble-attachment-doc .doc-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bubble-attachment-doc .doc-name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bubble-attachment-doc .doc-size {
  font-size: 0.72rem;
  opacity: 0.75;
}

.composer-box {
  background-color: var(--composer-bg);
  border: 1.5px solid var(--composer-border);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  box-shadow: var(--shadow-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.composer-box:focus-within {
  border-color: var(--primary-sky);
  box-shadow: var(--brand-glow), var(--shadow-md);
}

.composer-textarea {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  max-height: 160px;
  outline: none;
  padding: 4px 6px;
  direction: rtl;
}

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

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

/* Microphone Button */
.mic-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background-color: var(--surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.mic-btn:hover {
  color: var(--primary-sky);
  border-color: var(--primary-sky);
  transform: scale(1.05);
  box-shadow: var(--brand-glow);
}

.mic-btn.recording {
  background-color: #ef4444;
  border-color: #ef4444;
  color: #ffffff;
  animation: pulseRecording 1.2s infinite;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.5);
}

@keyframes pulseRecording {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1.08); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Voice Recording Active Bar */
.voice-recording-bar {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 6px;
  animation: fadeIn 0.2s ease;
}

.recording-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  overflow: hidden;
}

.recording-pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #ef4444;
  animation: pulseDot 1s infinite alternate;
  flex-shrink: 0;
}

@keyframes pulseDot {
  from { opacity: 0.3; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1.2); }
}

.recording-timer {
  font-family: var(--font-family-mono);
  font-size: 0.92rem;
  font-weight: 700;
  color: #ef4444;
  flex-shrink: 0;
}

.recording-waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 22px;
  flex-shrink: 0;
}

.wave-bar {
  width: 3px;
  height: 8px;
  background-color: var(--primary-sky);
  border-radius: 2px;
  animation: waveMotion 1.2s infinite ease-in-out;
  transition: height 0.1s ease;
}

.wave-bar:nth-child(1) { animation-delay: 0.1s; }
.wave-bar:nth-child(2) { animation-delay: 0.25s; }
.wave-bar:nth-child(3) { animation-delay: 0.4s; }
.wave-bar:nth-child(4) { animation-delay: 0.2s; }
.wave-bar:nth-child(5) { animation-delay: 0.35s; }

@keyframes waveMotion {
  0%, 100% { height: 6px; }
  50% { height: 20px; }
}

.recording-transcript-preview {
  font-size: 0.88rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  font-style: italic;
}

.recording-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.recording-cancel-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: #ef4444;
  padding: 7px 12px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.recording-cancel-btn:hover {
  background-color: rgba(239, 68, 68, 0.12);
  border-color: #ef4444;
}

.recording-send-btn {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border: none;
  color: #ffffff;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.35);
}

.recording-send-btn:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

/* In-message Voice Note Player */
.voice-player-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: rgba(0, 0, 0, 0.18);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 6px;
  min-width: 250px;
  direction: rtl;
}

[data-theme='light'] .message-row.user .voice-player-card {
  background-color: rgba(255, 255, 255, 0.22);
}

.voice-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ffffff;
  color: var(--primary-blue);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast);
}

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

.voice-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.voice-waveform-track {
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
}

[data-theme='light'] .message-row.assistant .voice-waveform-track {
  background: rgba(0, 0, 0, 0.15);
}

.voice-waveform-progress {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  background: var(--primary-sky);
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s linear;
}

.voice-info-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  opacity: 0.85;
}

.voice-transcript-text {
  margin-top: 6px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-sky), var(--primary-blue));
  border: none;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: var(--brand-glow);
}

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

.composer-footer-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

/* ==========================================================================
   Modals & Overlays (Auth & Settings)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 90%;
  max-width: 440px;
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform var(--transition-normal);
  position: relative;
}

.modal-overlay.open .modal-card {
  transform: translateY(0);
}

.modal-close-btn {
  position: absolute;
  top: 18px;
  left: 18px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
}

.modal-header {
  text-align: center;
  margin-bottom: 22px;
}

.modal-header h3 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.modal-header p {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

/* Tab Switcher */
.auth-tabs {
  display: flex;
  background-color: var(--surface-elevated);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 20px;
}

.auth-tab-btn {
  flex: 1;
  padding: 8px 12px;
  background: none;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.auth-tab-btn.active {
  background-color: var(--surface-color);
  color: var(--primary-sky);
  box-shadow: var(--shadow-sm);
}

.form-group {
  margin-bottom: 16px;
  text-align: right;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  background-color: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  direction: ltr;
  text-align: right;
  transition: border-color var(--transition-fast);
}

.form-input:focus {
  border-color: var(--primary-sky);
}

.modal-action-btn {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, var(--primary-blue), var(--accent-indigo));
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 10px;
  box-shadow: var(--shadow-sm);
  transition: opacity var(--transition-fast);
}

.modal-action-btn:hover {
  opacity: 0.94;
}

.modal-alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 14px;
  display: none;
}

.modal-alert.error {
  display: block;
  background-color: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--color-error);
  color: #fca5a5;
}

.modal-alert.success {
  display: block;
  background-color: rgba(16, 185, 129, 0.15);
  border: 1px solid var(--color-success);
  color: #86efac;
}

/* Toast Notifications Container */
.toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background-color: var(--surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInToast 0.3s ease;
}

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

@keyframes slideInToast {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Responsive Drawer for Mobile Devices (< 768px) */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    transform: translateX(100%);
    box-shadow: var(--shadow-lg);
  }

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

  .menu-toggle-btn {
    display: flex;
  }

  .header-brand {
    display: flex;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 40;
  }

  .sidebar.open + .sidebar-backdrop {
    display: block;
  }

  .prompt-suggestions-grid {
    grid-template-columns: 1fr;
  }

  .message-content-wrapper {
    max-width: 90%;
  }

  .generated-image-card {
    max-width: 100%;
  }
}

/* ==========================================================================
   Generated AI Image Cards in Chat Bubbles
   ========================================================================== */
.generated-image-card {
  margin-top: 12px;
  background-color: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
  box-shadow: none;
  max-width: 520px;
  width: 100%;
}

.generated-image-wrapper {
  position: relative;
  width: 100%;
  min-height: 200px;
  max-height: 520px;
  background-color: var(--surface-elevated);
  border-radius: 16px;
  overflow: hidden;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.generated-image-wrapper:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.generated-image {
  width: 100%;
  height: auto;
  max-height: 500px;
  object-fit: cover;
  display: block;
  border-radius: 16px;
  border: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.generated-image-card.loaded .generated-image {
  opacity: 1;
}

/* Image Shimmer / Loading Placeholder */
.image-shimmer-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.88rem;
  background: linear-gradient(90deg, var(--surface-elevated) 25%, var(--border-color) 50%, var(--surface-elevated) 75%);
  background-size: 200% 100%;
  animation: imgShimmer 1.5s infinite;
  border-radius: 16px;
  z-index: 1;
  transition: opacity 0.3s ease;
}

.generated-image-card.loaded .image-shimmer-placeholder {
  opacity: 0;
  pointer-events: none;
}

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

.image-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary-sky);
  border-radius: 50%;
  animation: imgSpin 0.8s linear infinite;
}

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

.image-error-placeholder {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  align-items: center;
  justify-content: center;
  color: var(--color-error);
  font-size: 0.9rem;
  background-color: var(--surface-elevated);
  border-radius: 16px;
  z-index: 2;
}

.generated-image-card.error .image-error-placeholder {
  display: flex;
}

.generated-image-card.error .image-shimmer-placeholder {
  display: none;
}

/* Image Hover Toolbar */
.image-hover-toolbar {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  gap: 8px;
  opacity: 0;
  transform: translateY(6px);
  transition: all var(--transition-fast);
  z-index: 5;
}

.generated-image-wrapper:hover .image-hover-toolbar {
  opacity: 1;
  transform: translateY(0);
}

.image-toolbar-btn {
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.82rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.image-toolbar-btn:hover {
  background: rgba(15, 23, 42, 0.95);
  border-color: var(--primary-sky);
  transform: translateY(-1px);
}

/* Standalone Image Caption (Outside & Below Image) */
.generated-image-caption {
  margin-top: 8px;
  padding: 4px 2px;
  background-color: transparent;
  border: none;
  font-size: 0.88rem;
  color: var(--text-secondary);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.5;
}

.caption-icon {
  font-size: 1rem;
  flex-shrink: 0;
  opacity: 0.85;
  margin-top: 1px;
}

.caption-text {
  flex: 1;
  white-space: normal;
  word-break: break-word;
  color: var(--text-secondary);
  font-weight: 400;
}

/* ==========================================================================
   Lightbox Modal
   ========================================================================== */
.lightbox-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 3000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.lightbox-modal-overlay.show {
  display: flex;
}

.lightbox-container {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.lightbox-close-btn {
  position: absolute;
  top: -42px;
  left: 0;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  z-index: 10;
}

.lightbox-close-btn:hover {
  background: rgba(255, 255, 255, 0.35);
  transform: scale(1.08);
}

.lightbox-image-wrapper {
  max-width: 88vw;
  max-height: 75vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--radius-md);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.lightbox-image {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.lightbox-bottom-bar {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 88vw;
  gap: 16px;
}

.lightbox-caption {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.lightbox-download-btn {
  background: linear-gradient(135deg, var(--primary-blue), var(--accent-indigo));
  color: #ffffff;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: 0.88rem;
  font-family: inherit;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.lightbox-download-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}
