/* Premium Styling for Kpalabz Admin & Chat */
:root {
  --font-main: 'Plus Jakarta Sans', sans-serif;
  --font-title: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Color Palette */
  --bg-darkest: #07070a;
  --bg-dark: #0f0f18;
  --bg-card: rgba(22, 22, 38, 0.45);
  --bg-input: rgba(13, 13, 23, 0.75);
  
  --primary: #8b5cf6;
  --primary-glow: rgba(139, 92, 246, 0.25);
  --primary-hover: #7c3aed;
  
  --accent: #06b6d4;
  --accent-glow: rgba(6, 182, 212, 0.25);
  
  --text-main: #f3f4f6;
  --text-muted: #8e93a0;
  --text-inverse: #ffffff;
  
  --border-glass: rgba(255, 255, 255, 0.06);
  --border-glass-focus: rgba(139, 92, 246, 0.4);
  
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --warning: #f59e0b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-darkest);
  color: var(--text-main);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  background-image: 
    radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.1) 0px, transparent 40%),
    radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.08) 0px, transparent 40%);
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

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

/* Main Left Navigation Sidebar */
.main-sidebar {
  width: 220px;
  background-color: rgba(10, 10, 18, 0.85);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
  padding: 24px 12px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 24px 12px;
  font-family: var(--font-title);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, #fff 40%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  border-bottom: 1px solid var(--border-glass);
  margin-bottom: 20px;
}

.brand-icon {
  color: var(--primary);
  width: 24px;
  height: 24px;
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
}

.nav-item i {
  width: 18px;
  height: 18px;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
}

.nav-item.active {
  background: rgba(139, 92, 246, 0.12);
  color: #fff;
  font-weight: 600;
  border-color: rgba(139, 92, 246, 0.2);
  box-shadow: inset 0 0 12px rgba(139, 92, 246, 0.05);
}

.sidebar-status-indicator {
  padding: 12px;
  border-top: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.status-label {
  font-weight: 600;
}

/* Secondary Chat Sidebar */
.chat-sidebar {
  width: 260px;
  background-color: rgba(13, 13, 23, 0.55);
  backdrop-filter: blur(15px);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
  animation: fadeIn 0.2s ease-out;
}

.chat-sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-sidebar-header h3 {
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Conversations List */
.conversations-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.conversation-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.conversation-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.conversation-item.active {
  background: rgba(139, 92, 246, 0.08);
  border-color: rgba(139, 92, 246, 0.15);
}

.conversation-details {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.conversation-title {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-muted);
}

.conversation-item.active .conversation-title {
  color: #fff;
  font-weight: 600;
}

.conversation-actions {
  display: flex;
  opacity: 0;
}

.conversation-item:hover .conversation-actions,
.conversation-item.active .conversation-actions {
  opacity: 1;
}

.btn-delete-chat {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  color: var(--text-muted);
}

.btn-delete-chat:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
}

/* Main Content Area */
.main-content {
  flex: 1;
  overflow-y: auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Tab Panels */
.tab-panel {
  padding: 40px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#panel-chat {
  padding: 0;
  max-width: none;
  margin: 0;
  height: 100%;
}

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

.panel-header h1 {
  font-family: var(--font-title);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.stats-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.stats-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.12);
}

.stats-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.stats-icon.primary { background: rgba(139, 92, 246, 0.1); color: var(--primary); }
.stats-icon.success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.stats-icon.accent { background: rgba(6, 182, 212, 0.1); color: var(--accent); }
.stats-icon.warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); }

.stats-info h3 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stats-info p {
  font-family: var(--font-title);
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
}

/* Table Design */
.table-card {
  width: 100%;
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid var(--border-glass);
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.data-table th {
  background-color: rgba(10, 10, 20, 0.6);
  padding: 16px 20px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-glass);
}

.data-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-glass);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background-color: rgba(255, 255, 255, 0.015);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
}

.badge.healthy, .badge.active { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge.exhausted, .badge.paused { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.badge.pending { background: rgba(245, 158, 11, 0.1); color: var(--warning); }

/* Form Cards */
.form-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 28px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-header h3 {
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 600;
}

.max-width-600 { max-width: 600px; }
.w-100 { width: 100%; }

/* Grid columns layout */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 28px;
  align-items: start;
}

.grid-4col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

/* Metric boxes inside modal */
.metric-box {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.metric-box span {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}

.metric-box strong {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  font-family: var(--font-title);
}

/* Charts styling */
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 24px;
}

.chart-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 20px;
}

.chart-wrapper {
  height: 250px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.chart-loading {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Custom SVG Chart aesthetics */
.chart-svg {
  width: 100%;
  height: 100%;
}

.chart-axis-line {
  stroke: rgba(255,255,255,0.06);
  stroke-width: 1px;
}

.chart-grid-line {
  stroke: rgba(255,255,255,0.03);
  stroke-width: 1px;
  stroke-dasharray: 4,4;
}

.chart-bar {
  fill: url(#chart-bar-gradient);
  transition: all 0.3s ease;
  rx: 3;
}

.chart-bar:hover {
  fill: var(--accent);
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

.chart-bar-cyan {
  fill: url(#chart-bar-gradient-cyan);
  rx: 3;
}

.chart-axis-text {
  fill: var(--text-muted);
  font-size: 9px;
  font-family: var(--font-mono);
}

.chart-value-text {
  fill: #fff;
  font-size: 9px;
  font-weight: 600;
  text-anchor: middle;
}

/* Form Controls */
.form-group {
  margin-bottom: 20px;
}

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

.form-control {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.15);
}

textarea.form-control {
  resize: vertical;
}

.form-help {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Input Groups */
.input-group {
  position: relative;
  display: flex;
  width: 100%;
}

.input-group .form-control {
  padding-right: 48px;
}

.btn-icon-inside {
  position: absolute;
  right: 4px;
  top: 4px;
  bottom: 4px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--text-muted);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-inside:hover {
  color: var(--text-main);
  background: rgba(255,255,255,0.03);
}

/* OAuth Wizard UI Steps */
.oauth-steps {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.oauth-step {
  background: rgba(0,0,0,0.15);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 16px;
  position: relative;
  padding-left: 56px;
}

.step-num {
  position: absolute;
  left: 16px;
  top: 16px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

.oauth-status-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.2);
  font-size: 0.85rem;
  color: #67e8f9;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  width: 90%;
  max-width: 500px;
  background: rgba(12, 12, 22, 0.9);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: scaleUp 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal.modal-lg {
  max-width: 800px;
}

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

.modal-header h3 {
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 600;
}

.modal-body {
  padding: 24px;
  max-height: 80vh;
  overflow-y: auto;
}

.usage-info-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border-glass);
  margin-bottom: 20px;
}

.usage-info-header h4 {
  font-family: var(--font-title);
  font-size: 1.2rem;
  font-weight: 600;
}

.usage-info-header code {
  font-family: var(--font-mono);
  background: rgba(255,255,255,0.05);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--accent);
}

/* Glassmorphism glass class helper */
.glass {
  background: rgba(22, 22, 38, 0.45);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
}

/* Chat View Extensions */
.chat-playground-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  height: 70px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(7,7,10, 0.2);
}

.active-chat-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.active-chat-info h2 {
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: 600;
}

.model-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.18);
  font-size: 0.75rem;
  font-weight: 600;
  color: #c084fc;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  background-color: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--success);
  animation: pulse 2s infinite;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Welcome Screen */
.welcome-screen {
  max-width: 500px;
  margin: auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px 20px;
}

.welcome-icon {
  width: 48px;
  height: 48px;
  color: var(--primary);
  filter: drop-shadow(0 0 10px var(--primary-glow));
}

.welcome-screen h1 {
  font-family: var(--font-title);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 40%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-screen p {
  color: var(--text-muted);
  line-height: 1.6;
  font-size: 0.95rem;
}

.quick-setup-card {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 20px;
  margin-top: 15px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quick-setup-card h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}

.setup-detail {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.setup-detail span {
  color: var(--text-muted);
}

.setup-detail code {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Message Rows */
.message-row {
  display: flex;
  width: 100%;
  gap: 16px;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 700;
  font-size: 0.9rem;
}

.user-row .message-avatar {
  display: none;
}

.bot-row .message-avatar {
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.2);
  color: var(--primary);
}

.message-bubble {
  max-width: 75%;
  padding: 16px 20px;
  border-radius: 16px;
  line-height: 1.6;
  font-size: 0.95rem;
  word-wrap: break-word;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.user-row .message-bubble {
  background: linear-gradient(135deg, var(--primary) 0%, rgba(124, 58, 237, 0.85) 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.bot-row .message-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  border-top-left-radius: 4px;
}

.message-bubble p {
  margin-bottom: 12px;
}

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

.message-bubble code {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.25);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.85rem;
  color: #f472b6;
}

/* Code Blocks Container in Messages */
.code-block-container {
  margin: 15px 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-glass);
  box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

.code-header {
  background: rgba(10, 10, 18, 0.9);
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-glass);
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.btn-copy {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
}

.btn-copy:hover {
  color: var(--text-main);
}

.code-block-container pre {
  margin: 0;
  background: #14141e !important;
}

.code-block-container code {
  display: block;
  padding: 16px;
  overflow-x: auto;
  background: transparent !important;
  color: inherit;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* Input Panel */
.input-panel {
  padding: 20px 30px;
  border-top: 1px solid var(--border-glass);
  background: rgba(9, 9, 14, 0.2);
}

.input-container {
  max-width: 800px;
  margin: 0 auto;
  position: relative;
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  display: flex;
  align-items: center;
  padding: 6px 10px 6px 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

#chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.95rem;
  resize: none;
  max-height: 150px;
  min-height: 24px;
  padding: 8px 0;
  line-height: 1.5;
}

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

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

.btn-circle {
  border-radius: 50%;
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  border: none;
}

.btn-circle.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 10px var(--primary-glow);
}

.btn-circle.btn-primary:hover {
  background: var(--primary-hover);
}

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

.btn-circle.btn-danger:hover {
  background: var(--danger-hover);
}

/* Typing Indicator Animation */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background-color: var(--text-muted);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

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

/* Helpers */
.hidden { display: none !important; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }

/* Animations */
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.5; }
}

@keyframes typing {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* --- Rich Attachments and Media Styles --- */

/* Previews container above textarea */
.attachment-preview-container {
  max-width: 800px;
  margin: 0 auto 12px auto;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  animation: slideUp 0.2s ease-out;
}

.attachment-preview-container.hidden {
  display: none !important;
}

/* Individual preview items */
.preview-item {
  position: relative;
  border-radius: 12px;
  border: 1px solid var(--border-glass);
  background: rgba(15, 15, 25, 0.6);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(8px);
}

.preview-item.image-preview {
  padding: 0;
  width: 72px;
  height: 72px;
  overflow: hidden;
  display: block;
}

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

.preview-item .file-icon {
  color: var(--primary);
  display: flex;
  align-items: center;
}

.preview-item .file-info {
  display: flex;
  flex-direction: column;
  max-width: 140px;
}

.preview-item .file-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.preview-item .btn-remove-preview {
  background: rgba(0, 0, 0, 0.6);
  border: none;
  color: var(--text-muted);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.preview-item.image-preview .btn-remove-preview {
  position: absolute;
  top: 4px;
  right: 4px;
}

.preview-item .btn-remove-preview:hover {
  color: #fff;
  background: var(--danger);
  transform: scale(1.1);
}

/* Recording Panel overlay styling */
.recording-panel {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  border-radius: 16px;
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.2);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  margin-bottom: 12px;
  animation: slideUp 0.25s ease-out;
}

.recording-panel.hidden {
  display: none !important;
}

.recording-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
}

.recording-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--danger);
  box-shadow: 0 0 10px var(--danger);
  animation: pulse 1.5s infinite;
}

.recording-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: #fca5a5;
}

.recording-timer {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 8px;
  border-radius: 4px;
}

/* Tool Buttons inside Input Container */
.btn-attach, .btn-mic {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-attach:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.btn-mic:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
}

.btn-mic.recording {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.15);
  animation: pulse 1.8s infinite;
}

/* Rendered items inside user bubble */
.message-attached-image {
  max-width: 100%;
  max-height: 250px;
  border-radius: 12px;
  display: block;
  margin-bottom: 8px;
  object-fit: contain;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
}

.message-attached-doc {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 8px;
  max-width: 320px;
  text-decoration: none;
  transition: background 0.2s ease;
}

.message-attached-doc:hover {
  background: rgba(0, 0, 0, 0.35);
}

.message-attached-doc .doc-icon {
  color: var(--accent);
  display: flex;
  align-items: center;
}

.message-attached-doc .doc-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.message-attached-doc .doc-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-attached-doc .doc-size {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Audio Player Card in Chat Bubble */
.message-attached-audio {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
  width: 280px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.message-attached-audio .audio-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--danger-hover);
}

.message-attached-audio audio {
  width: 100%;
  height: 32px;
  outline: none;
}

/* Custom styling for native HTML audio controls to match dark theme */
.message-attached-audio audio::-webkit-media-controls-panel {
  background-color: #1a1a2e;
}
.message-attached-audio audio::-webkit-media-controls-play-button,
.message-attached-audio audio::-webkit-media-controls-mute-button {
  background-color: var(--danger);
  border-radius: 50%;
}
.message-attached-audio audio::-webkit-media-controls-current-time-display,
.message-attached-audio audio::-webkit-media-controls-time-remaining-display {
  color: #fff;
  font-family: var(--font-mono);
}
