html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
  background-color: #000000; /* dark background */
  color: #ffffff;
}

/* Dashboard cards */
.dash-card { transition: transform 0.15s ease, box-shadow 0.15s ease; border: none; }
.dash-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,.12); }

/* Chart containers */
.chart-slot { min-height: 280px; position: relative; }
.chart-slot.empty-slot {
  display: flex; align-items: center; justify-content: center;
  border: 2px dashed #dee2e6; border-radius: 0.5rem; background: #f8f9fa;
}

/* Admin cards */
.admin-stat { border-left: 4px solid; }
.admin-stat.ok { border-color: #198754; }
.admin-stat.warn { border-color: #ffc107; }
.admin-stat.err { border-color: #dc3545; }

/* Connection string parsed display */
.cs-field { font-family: 'Cascadia Code', 'Consolas', monospace; font-size: 0.875rem; }
.cs-label { font-weight: 600; color: #6c757d; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; }

/* Floating settings button */
.settings-fab {
  position: fixed; bottom: 80px; right: 24px; z-index: 1050;
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  font-size: 1.25rem; transition: transform 0.2s;
}
.settings-fab:hover { transform: scale(1.1); }

/* Pulse animation for live status */
.pulse { display: inline-block; width: 10px; height: 10px; border-radius: 50%; animation: pulse-ring 1.5s infinite; }
.pulse.green { background: #198754; }
.pulse.red { background: #dc3545; }
@@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(25,135,84,.5); }
  70% { box-shadow: 0 0 0 8px rgba(25,135,84,0); }
  100% { box-shadow: 0 0 0 0 rgba(25,135,84,0); }
}

/* Toast */
.toast-container { position: fixed; top: 80px; right: 20px; z-index: 1060; }

/* Light theme overrides when body has .theme-light */
body.theme-light {
  background-color: #f4f6f9 !important;
  color: #212529 !important;
}

body.theme-light a { color: #0d6efd !important; }
body.theme-light .navbar-dark .navbar-nav .nav-link { color: #495057 !important; }
body.theme-light .navbar-dark .navbar-nav .nav-link:hover { color: #0d6efd !important; }
body.theme-light .btn-primary { color: #fff; background-color: #1b6ec2; border-color: #145aa1; }
body.theme-light .container, body.theme-light .card, body.theme-light .card-body { background-color: #ffffff !important; color: #212529 !important; }

/* Smooth transition when switching themes */
html, body { transition: background-color 200ms ease, color 200ms ease; }

/* Dark theme table and component overrides (default dark body) */
.table { color: #ffffff; --bs-table-color: #ffffff; --bs-table-bg: transparent; }
.table thead { color: #ffffff; }
.table-striped > tbody > tr:nth-of-type(odd) > * { --bs-table-color-state: #ffffff; --bs-table-bg-type: rgba(255,255,255,0.03); }
.table-striped > tbody > tr:nth-of-type(even) > * { --bs-table-color-state: #ffffff; }
.table-hover > tbody > tr:hover > * { --bs-table-color-state: #ffffff; --bs-table-bg-state: rgba(255,255,255,0.07); }
.table td, .table th { color: #ffffff; }
.card { background-color: #1a1a2e; color: #ffffff; border-color: #2d2d44; }
.card-header { background-color: #16213e; color: #ffffff; border-color: #2d2d44; }
.card-body { color: #ffffff; }
.form-control, .form-select { background-color: #1a1a2e; color: #ffffff; border-color: #444; }
.form-control:focus, .form-select:focus { background-color: #1a1a2e; color: #ffffff; }
.form-label { color: #e0e0e0; }
.text-muted { color: #adb5bd !important; }
.modal-content { background-color: #1a1a2e; color: #ffffff; }
.dropdown-menu { background-color: #1a1a2e; border-color: #2d2d44; }
.dropdown-item { color: #ffffff; }
.dropdown-item:hover, .dropdown-item:focus { background-color: #16213e; color: #ffffff; }
.footer { color: #adb5bd; }

/* Light theme: reset everything back */
body.theme-light .table { color: #212529; --bs-table-color: #212529; }
body.theme-light .table td, body.theme-light .table th { color: #212529; }
body.theme-light .table-striped > tbody > tr:nth-of-type(odd) > * { --bs-table-color-state: #212529; --bs-table-bg-type: rgba(0,0,0,0.05); }
body.theme-light .table-hover > tbody > tr:hover > * { --bs-table-color-state: #212529; }
body.theme-light .card { background-color: #ffffff; color: #212529; border-color: #dee2e6; }
body.theme-light .card-header { background-color: #f8f9fa; color: #212529; border-color: #dee2e6; }
body.theme-light .form-control, body.theme-light .form-select { background-color: #ffffff; color: #212529; border-color: #ced4da; }
body.theme-light .form-control:focus, body.theme-light .form-select:focus { background-color: #ffffff; color: #212529; }
body.theme-light .form-label { color: #212529; }
body.theme-light .dropdown-menu { background-color: #ffffff; border-color: #dee2e6; }
body.theme-light .dropdown-item { color: #212529; }
body.theme-light .dropdown-item:hover { background-color: #e9ecef; color: #212529; }
body.theme-light .modal-content { background-color: #ffffff; color: #212529; }
body.theme-light .footer { color: #6c757d; }

/* Ed AI floating button & chat panel */
#edFloatingBtn {
  position: fixed; bottom: 24px; right: 24px; z-index: 1100;
  padding: 10px 22px; border-radius: 28px;
  background: linear-gradient(135deg, #0d6efd, #6610f2);
  color: #fff; border: none; font-size: 1rem; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
  box-shadow: 0 4px 16px rgba(13,110,253,.4);
  cursor: pointer; transition: transform 0.2s;
  white-space: nowrap;
}
#edFloatingBtn:hover { transform: scale(1.05); }

#edChatPanel {
  display: none; flex-direction: column;
  position: fixed; bottom: 90px; right: 24px; z-index: 1100;
  width: 360px; max-height: 480px;
  background: #1a1a2e; border: 1px solid #2d2d44;
  border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,.5);
  overflow: hidden;
  transition: width 0.3s ease, max-height 0.3s ease, bottom 0.3s ease;
}
#edChatPanel.ed-expanded {
  width: min(680px, calc(100vw - 48px)); max-height: min(720px, calc(100vh - 120px)); bottom: 24px;
}
body.theme-light #edChatPanel { background: #fff; border-color: #dee2e6; box-shadow: 0 8px 32px rgba(0,0,0,.15); }

#edChatPanel .ed-header {
  padding: 12px 16px; background: linear-gradient(135deg, #0d6efd, #6610f2);
  color: #fff; display: flex; align-items: center; justify-content: space-between;
  font-weight: 600;
}
#edChatPanel .ed-header button { background: none; border: none; color: #fff; font-size: 1.2rem; cursor: pointer; }
#edChatPanel .ed-header .ed-tts-btn { opacity: 0.85; transition: opacity 0.2s; }
#edChatPanel .ed-header .ed-tts-btn:hover { opacity: 1; }
#edChatPanel .ed-header .ed-tts-btn.muted { opacity: 0.5; }

#edChatMessages {
  flex: 1; overflow-y: auto; padding: 12px; display: flex;
  flex-direction: column; gap: 8px; min-height: 200px; max-height: 320px;
  transition: max-height 0.3s ease;
}
#edChatPanel.ed-expanded #edChatMessages { max-height: none; }

.ed-msg {
  padding: 8px 12px; border-radius: 12px; max-width: 85%;
  font-size: 0.875rem; word-wrap: break-word; line-height: 1.4;
}
.ed-msg-user { background: #0d6efd; color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.ed-msg-ed { background: #2d2d44; color: #e0e0e0; align-self: flex-start; border-bottom-left-radius: 4px; position: relative; }
body.theme-light .ed-msg-ed { background: #f0f0f0; color: #212529; }

/* Voice replay button on Ed messages */
.ed-msg-voice-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; color: #8ab4f8; cursor: pointer;
  font-size: 0.8rem; padding: 2px 6px; margin-left: 6px;
  border-radius: 4px; vertical-align: middle;
  opacity: 0.6; transition: opacity 0.2s, color 0.2s;
}
.ed-msg-voice-btn:hover { opacity: 1; color: #0d6efd; }
body.theme-light .ed-msg-voice-btn { color: #495057; }
body.theme-light .ed-msg-voice-btn:hover { color: #0d6efd; }
.ed-msg-loading { color: #adb5bd; align-self: flex-start; display: flex; gap: 4px; padding: 12px 16px; }
.ed-msg-loading .dot {
  width: 8px; height: 8px; border-radius: 50%; background: #adb5bd;
  animation: edDotHop 1.4s infinite ease-in-out both;
}
.ed-msg-loading .dot:nth-child(1) { animation-delay: 0s; }
.ed-msg-loading .dot:nth-child(2) { animation-delay: 0.16s; }
.ed-msg-loading .dot:nth-child(3) { animation-delay: 0.32s; }
@keyframes edDotHop {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-10px); opacity: 1; }
}

#edChatPanel .ed-input-row {
  display: flex; padding: 8px 12px; gap: 6px; border-top: 1px solid #2d2d44;
}
body.theme-light #edChatPanel .ed-input-row { border-color: #dee2e6; }
#edChatInput {
  flex: 1; border: none; outline: none; padding: 6px 10px; border-radius: 8px;
  background: #16213e; color: #fff; font-size: 0.875rem;
}
body.theme-light #edChatInput { background: #f8f9fa; color: #212529; }
#edChatSend, #edChatMic { background: none; border: none; color: #0d6efd; font-size: 1.1rem; cursor: pointer; }
