/* ===============================
   THEME CORE (Light + Dark) - ContatAí
   Paleta azul moderna e profissional
   =============================== */

/* ===============================
   PAGE LAYOUT - Global Standards
   =============================== */
.page-wrapper {
  width: 100%;
  max-width: 100%;
}

.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.page-header {
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.page-header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-title i {
  color: var(--color-primary);
  font-size: 1.35rem;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  font-weight: 400;
  margin: 0.25rem 0 0 0;
}

/* ===============================
   SECTION CARDS - Global Standards
   =============================== */
.section-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.section-card:hover {
  box-shadow: var(--shadow);
}

body.dark-mode .section-card {
  background: var(--color-surface-alt);
  border-color: var(--color-border);
}

.section-header {
  padding: 0.875rem 1rem;
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

body.dark-mode .section-header {
  background: rgba(255,255,255,0.02);
  border-bottom-color: var(--color-border-strong);
}

.section-header-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-header-title i {
  font-size: 1rem;
  color: var(--color-primary);
}

.section-body {
  padding: 1rem;
}

/* ===============================
   FORM COMPONENTS - Global Standards
   =============================== */
.form-label-custom {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.5rem;
  display: block;
}

.form-input-custom {
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface-alt);
  color: var(--color-text);
  transition: all 0.2s ease;
  width: 100%;
}

.form-input-custom:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-focus-ring);
  background: var(--color-surface);
  outline: none;
}

body.dark-mode .form-input-custom {
  background: rgba(255,255,255,0.03);
  border-color: var(--color-border);
}

.form-textarea-custom {
  font-family: 'Manrope', 'Segoe UI', system-ui, Arial, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.5;
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface-alt);
  color: var(--color-text);
  transition: all 0.2s ease;
  resize: vertical;
  width: 100%;
}

.form-textarea-custom:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-focus-ring);
  background: var(--color-surface);
  outline: none;
}

body.dark-mode .form-textarea-custom {
  background: rgba(255,255,255,0.03);
  border-color: var(--color-border);
}

.form-hint {
  background: var(--color-surface-alt);
  border-left: 3px solid var(--color-warning);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  color: var(--color-text-soft);
}

body.dark-mode .form-hint {
  background: rgba(255,255,255,0.03);
}

.form-text-custom {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-top: 0.375rem;
  display: block;
}

/* ===============================
   BUTTONS - Global Standards
   =============================== */
.btn-custom {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  cursor: pointer;
}

.btn-custom i {
  font-size: 1rem;
}

.btn-primary-custom {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.btn-primary-custom:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79,110,247,0.3);
}

.btn-secondary-custom {
  background: transparent;
  border-color: var(--color-border-strong);
  color: var(--color-text);
}

.btn-secondary-custom:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-success-custom {
  background: var(--color-success);
  border-color: var(--color-success);
  color: white;
}

.btn-success-custom:hover {
  filter: brightness(1.1);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(22,163,74,0.3);
}

.btn-danger-custom {
  background: transparent;
  border-color: var(--color-danger);
  color: var(--color-danger);
}

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

/* ===============================
   INFO BANNER - Global Standards
   =============================== */
.info-banner {
  background: linear-gradient(135deg, rgba(79,110,247,0.06) 0%, rgba(22,184,212,0.06) 100%);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin-bottom: 1.25rem;
  position: relative;
  overflow: hidden;
}

.info-banner::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--color-primary);
}

body.dark-mode .info-banner {
  background: linear-gradient(135deg, rgba(79,110,247,0.1) 0%, rgba(22,184,212,0.1) 100%);
}

.info-banner-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.info-banner-title i {
  color: var(--color-primary);
  font-size: 1rem;
}

.info-banner-text {
  color: var(--color-text-soft);
  line-height: 1.5;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.info-banner-text:last-child {
  margin-bottom: 0;
}

/* ===============================
   EMPTY STATE - Global Standards
   =============================== */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
}

.empty-state i {
  font-size: 2.5rem;
  color: var(--color-text-faint);
  margin-bottom: 0.75rem;
  display: block;
}

.empty-state h4, .empty-state p {
  margin: 0;
  color: var(--color-text-muted);
}

.empty-state h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.empty-state .btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* ===============================
   ACTION BUTTONS ROW
   =============================== */
.action-buttons {
  display: flex;
  gap: 0.625rem;
  flex-wrap: wrap;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  margin-top: 1rem;
}

/* ===============================
   LIVE INDICATOR
   =============================== */
.live-indicator {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.375rem 0.625rem;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--color-text-soft);
}

/* ===============================
   CHECKBOX/RADIO OPTIONS
   =============================== */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.radio-option,
.checkbox-option {
  display: flex;
  align-items: flex-start;
  padding: 0.75rem;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
}

.radio-option:hover,
.checkbox-option:hover {
  border-color: var(--color-primary);
  background: var(--color-surface);
}

body.dark-mode .radio-option,
body.dark-mode .checkbox-option {
  background: rgba(255,255,255,0.03);
  border-color: var(--color-border);
}

.radio-option input[type="radio"],
.checkbox-option input[type="checkbox"] {
  width: 1.125rem;
  height: 1.125rem;
  margin-right: 0.625rem;
  margin-top: 0.125rem;
  cursor: pointer;
  accent-color: var(--color-primary);
  flex-shrink: 0;
}

.checkbox-content {
  flex: 1;
}

.checkbox-label {
  color: var(--color-text);
  font-weight: 500;
  margin-bottom: 0.125rem;
  cursor: pointer;
  display: block;
  font-size: 0.9375rem;
}

.checkbox-description {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  line-height: 1.4;
  margin: 0;
}

/* ===============================
   CALENDAR STATUS
   =============================== */
.calendar-status {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 2rem;
  font-size: 0.8125rem;
  font-weight: 600;
}

.calendar-status.connected {
  background: rgba(22,163,74,0.1);
  color: var(--color-success);
  border: 1px solid var(--color-success);
}

.calendar-status.disconnected {
  background: rgba(107,114,128,0.1);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border-strong);
}

/* ===============================
   NESTED OPTIONS
   =============================== */
.nested-option {
  margin-left: 1.5rem;
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

body.dark-mode .nested-option {
  background: rgba(255,255,255,0.02);
}

:root {
  /* Light palette - ContatAí com azul */
  --color-bg: #f5f7fa;
  --color-bg-alt: #eef1f5;
  --color-surface: #ffffff;
  --color-surface-alt: #f9fafb;
  --color-border: #e3e8ef;
  --color-border-strong: #cdd5df;
  --color-text: #1e2430;
  --color-text-soft: #4b5563;
  --color-text-muted: #6b7280;
  --color-text-faint: #9ca3af;
  --color-primary: #4f6ef7;
  --color-primary-hover: #3d5eea;
  --color-accent: #16b8d4;
  --color-accent-hover: #0fa2bb;
  --color-success: #16a34a;
  --color-danger: #dc2626;
  --color-warning: #eab308;
  --color-focus-ring: rgba(79,110,247,0.35);
  --radius-sm: .375rem;
  --radius: .75rem;
  --radius-lg: 1.2rem;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
  --shadow: 0 4px 12px -2px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 28px -4px rgba(0,0,0,.12);
  --transition: 120ms cubic-bezier(.4,0,.2,1);
}

/* Dark mode overrides */
body.dark-mode {
  --color-bg: #12141a;
  --color-bg-alt: #181b22;
  --color-surface: #1d2129;
  --color-surface-alt: #222832;
  --color-border: #2b323d;
  --color-border-strong: #3a4552;
  --color-text: #f2f5f9;
  --color-text-soft: #cfd6e0;
  --color-text-muted: #9aa5b4;
  --color-text-faint: #6b7684;
  --color-primary: #5d7dff;
  --color-primary-hover: #4a68eb;
  --color-accent: #15b3cf;
  --color-accent-hover: #0e9fb8;
  --color-success: #22c55e;
  --color-danger: #f87171;
  --color-warning: #facc15;
  --color-focus-ring: rgba(93,125,255,0.4);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 4px 16px -2px rgba(0,0,0,.5);
  --shadow-lg: 0 10px 36px -6px rgba(0,0,0,.55);
}

/* ===============================
   BASE
   =============================== */
html { font-size: 15px; }
@media (min-width: 992px){ html { font-size: 16px; } }

body {
  font-family: 'Manrope','Segoe UI',system-ui,Arial,sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.45;
  margin: 0;
  min-height: 100vh;
}

main.container {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding-top: 1rem;
}

/* Typography helpers */
.text-soft { color: var(--color-text-soft) !important; }
.text-muted { color: var(--color-text-muted) !important; }
.text-faint { color: var(--color-text-faint) !important; }

/* Headings standardization */
h1, h2, h3, h4, h5, h6 { color: var(--color-text); font-weight: 600; }
h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }
.display-5 { font-size: 2.5rem; }

/* Links */
a { color: var(--color-primary); text-decoration: none; transition: color var(--transition); }
a:hover, a:focus { color: var(--color-primary-hover); }

/* ===============================
   NAVBAR
   =============================== */
.navbar-ai { 
  background: var(--color-surface); 
  border-bottom: 1px solid var(--color-border); 
  box-shadow: var(--shadow-sm); 
}
body.dark-mode .navbar-ai { 
  background: var(--color-surface); 
  border-bottom-color: var(--color-border);
}
.navbar-brand { color: var(--color-primary) !important; font-weight:700; letter-spacing:.5px; }
.navbar-nav .nav-link { color: var(--color-text-soft); font-weight:500; padding:.6rem 1rem; border-radius: var(--radius-sm); transition: all var(--transition); }
.navbar-nav .nav-link:hover, .navbar-nav .nav-link:focus { color: var(--color-primary); background: var(--color-bg-alt); }
.navbar-nav .nav-link.active { color: var(--color-primary); background: var(--color-bg-alt); }
body.dark-mode .navbar-nav .nav-link { color: var("--color-text-soft"); }
body.dark-mode .navbar-nav .nav-link:hover, body.dark-mode .navbar-nav .nav-link:focus { color: var(--color-primary); background: var(--color-bg-alt); }
body.dark-mode .navbar-nav .nav-link.active { color: var(--color-primary); background: var(--color-bg-alt); }
.navbar-text { color: var(--color-text-soft) !important; }
body.dark-mode .navbar-text { color: var(--color-text-soft) !important; }
body.dark-mode .navbar-toggler { border-color: var(--color-border); }
body.dark-mode .navbar-toggler-icon { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%23f2f5f9' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='m4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e"); }

/* ===============================
   COMPONENTS
   =============================== */
.card, .list-group-item, .modal-content { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); color: var(--color-text); }
.list-group-flush > .list-group-item { border-left: none; border-right:none; }
body.dark-mode .card, body.dark-mode .list-group-item, body.dark-mode .modal-content { background: var(--color-surface-alt); }
.card-header { background: var(--color-surface-alt); border-bottom: 1px solid var(--color-border); color: var(--color-text); font-weight: 600; }
body.dark-mode .card-header { background: #262d38; border-bottom-color: var(--color-border-strong); }
.badge { font-weight:500; letter-spacing:.25px; }
.badge.bg-secondary { background: var(--color-accent) !important; }
.badge.unread-count { background: var(--color-primary); }
body.dark-mode .badge.unread-count { background: var(--color-primary); }

/* Unread badge over avatar */
.avatar-wrapper { position: relative; }
.unread-count { position:absolute; top:-4px; right:-4px; background: var(--color-danger); color:#fff; font-size:.65rem; font-weight:600; padding:2px 5px; line-height:1; border-radius:12px; min-width:20px; text-align:center; box-shadow:0 0 0 2px var(--color-surface); }
body.dark-mode .unread-count { box-shadow:0 0 0 2px var(--color-surface-alt); }

/* Buttons */
.btn { border-radius: var(--radius-sm); font-weight:500; letter-spacing:.3px; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--color-focus-ring); }
.btn-primary { background: var(--color-primary); border:1px solid var(--color-primary); box-shadow: var(--shadow-sm); }
.btn-primary:hover, .btn-primary:focus { background: var(--color-primary-hover); border-color: var(--color-primary-hover); transform: translateY(-2px); }
.btn-outline-primary { color: var(--color-primary); border:1px solid var(--color-primary); background: transparent; }
.btn-outline-primary:hover { background: var(--color-primary); color:#fff; }
.btn-outline-accent { color: var(--color-accent); border:1px solid var(--color-accent); }
.btn-outline-accent:hover { background: var(--color-accent); color:#fff; }
.btn-success { background: var(--color-success); border:1px solid var(--color-success); }
.btn-success:hover { filter: brightness(.92); }
.btn-danger { background: var(--color-danger); border:1px solid var(--color-danger); }
.btn-danger:hover { filter: brightness(.9); }
.btn-link { color: var(--color-primary); }
.btn-link:hover { color: var(--color-primary-hover); text-decoration: underline; }

/* Forms */
input.form-control, select.form-select, textarea.form-control { border-radius: var(--radius); border:1px solid var(--color-border); background: var(--color-surface-alt); color: var(--color-text); padding:.65rem .9rem; line-height:1.35; transition: background var(--transition), border-color var(--transition), box-shadow var(--transition); }
input.form-control:focus, select.form-select:focus, textarea.form-control:focus { background: var(--color-surface); border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-focus-ring); outline: none; }
body.dark-mode input.form-control, body.dark-mode select.form-select, body.dark-mode textarea.form-control { background: #1f2530; border-color: var(--color-border); color: var(--color-text); }
body.dark-mode input.form-control:focus { background:#262d38; }
.form-check-input:checked { background-color: var(--color-primary); border-color: var(--color-primary); }
.form-check-input:focus { box-shadow: 0 0 0 0.15rem var(--color-focus-ring); }
body.dark-mode .form-check-input { background-color: var(--color-surface-alt); border-color: var(--color-border); }
body.dark-mode .form-check-label { color: var(--color-text); }

/* Placeholder text fix for all themes - FORCED */
input::placeholder, textarea::placeholder { color: var(--color-text-muted) !important; opacity: 1 !important; }
input::-webkit-input-placeholder, textarea::-webkit-input-placeholder { color: var(--color-text-muted) !important; }
input::-moz-placeholder, textarea::-moz-placeholder { color: var(--color-text-muted) !important; opacity: 1 !important; }
input:-ms-input-placeholder, textarea:-ms-input-placeholder { color: var(--color-text-muted) !important; }
input::-ms-input-placeholder, textarea::-ms-input-placeholder { color: var(--color-text-muted) !important; }
.validation-summary-valid { display: none !important; }

/* Extra override for specific input themes */
.input-theme input::placeholder { color: var(--color-text-muted) !important; }
.input-theme input::-webkit-input-placeholder { color: var(--color-text-muted) !important; }
.input-theme input::-moz-placeholder { color: var(--color-text-muted) !important; opacity: 1 !important; }
.input-theme input:-ms-input-placeholder { color: var(--color-text-muted) !important; }
.input-theme input::-ms-input-placeholder { color: var(--color-text-muted) !important; }
/* Alerts */
.alert { border-radius: var(--radius); border: none; }
.alert-info { background: rgba(22,184,212,0.12); color: var(--color-text); border-left: 4px solid var(--color-accent); }
.alert-warning { background: rgba(234,179,8,0.12); color: var(--color-text); border-left: 4px solid var(--color-warning); }
.alert-danger { background: rgba(220,38,38,0.12); color: var(--color-text); border-left: 4px solid var(--color-danger); }
.alert-success { background: rgba(22,163,74,0.12); color: var(--color-text); border-left: 4px solid var(--color-success); }
body.dark-mode .alert-info { background: #0e2832; }
body.dark-mode .alert-warning { background: #2a2610; }
body.dark-mode .alert-danger { background: #2a1414; }
body.dark-mode .alert-success { background: #142a18; }
/* Tables */
.table { color: var(--color-text); background: var(--color-surface); }
.table thead th { background: var(--color-surface-alt); border-bottom:2px solid var(--color-border); color: var(--color-text); font-weight:600; }
.table tbody tr { background: var(--color-surface); }
.table tbody td { border-color: var(--color-border); color: var(--color-text); }
.table-hover tbody tr:hover { background: var(--color-bg-alt); }
body.dark-mode .table { background: var(--color-surface-alt); }
body.dark-mode .table thead th { background:#262d38; border-color: var(--color-border-strong); color: var(--color-text); }
body.dark-mode .table tbody tr { background: var(--color-surface-alt); }
body.dark-mode .table tbody td { border-color: var(--color-border); color: var(--color-text); }
body.dark-mode .table-hover tbody tr:hover { background:#252c37; }

/* Table unified theme to sync with CSS vars */
.table-unified { 
  --bs-table-bg: var(--color-surface-alt); 
  --bs-table-color: var(--color-text); 
  --bs-table-border-color: var(--color-border); 
  --bs-table-striped-bg: var(--color-surface); 
  --bs-table-hover-bg: var(--color-bg-alt); 
  --bs-table-striped-color: var(--color-text); 
  --bs-table-hover-color: var(--color-text); 
}
body.dark-mode .table-unified { 
  --bs-table-bg: var(--color-surface-alt); 
  --bs-table-color: var(--color-text); 
  --bs-table-border-color: var(--color-border); 
  --bs-table-striped-bg: #262d38; 
  --bs-table-hover-bg: #252c37; 
  --bs-table-striped-color: var(--color-text); 
  --bs-table-hover-color: var(--color-text); 
}
.table-unified tbody tr { background: var(--bs-table-bg); }
.table-unified tbody tr:hover { background: var(--bs-table-hover-bg); }
.table-unified tbody td, .table-unified thead th { border-color: var(--bs-table-border-color); }

/* Chat filters / inputs themed */
.input-theme .input-group-text { background: var(--color-surface-alt); color: var(--color-text-soft); border-color: var(--color-border); }
.input-theme .form-control { background: var(--color-surface-alt); border-color: var(--color-border); color: var(--color-text); }
.input-theme .form-control:focus { background: var(--color-surface); }
body.dark-mode .input-theme .input-group-text { background: #262d38; color: var(--color-text-soft); border-color: var(--color-border); }
body.dark-mode .input-theme .form-control { background: #262d38; border-color: var(--color-border); color: var(--color-text); }
body.dark-mode .input-theme .form-control:focus { background:#1f2530; }

.filter-bar { background: var(--color-surface-alt); border:1px solid var(--color-border); }
body.dark-mode .filter-bar { background:#262d38; border-color: var(--color-border-strong); }

/* Utility */
.shadow-hover { transition: box-shadow var(--transition), transform var(--transition); }
.shadow-hover:hover { box-shadow: var(--shadow-lg); transform: translateY(-4px); }
.divider { height:1px; background: var(--color-border); margin:1.5rem 0; }
body.dark-mode .divider { background: var(--color-border-strong); }
.blinking-dot { width:.6rem; height:.6rem; border-radius:50%; background: var(--color-primary); display:inline-block; animation: blink 1s step-start infinite; }
body.dark-mode .blinking-dot { background: var(--color-accent); }
@keyframes blink { 50% { opacity:0; } }

/* Scrollbars */
::-webkit-scrollbar { width:8px; background: var(--color-bg-alt); }
::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-primary); }
body.dark-mode ::-webkit-scrollbar { background:#1a1f27; }
body.dark-mode ::-webkit-scrollbar-thumb { background:#2f3a46; }
body.dark-mode ::-webkit-scrollbar-thumb:hover { background: var(--color-primary); }

/* Avatar */
.avatar { background: linear-gradient(145deg, var(--color-primary) 0%, #3d56de 45%, var(--color-accent) 100%); border:2px solid var(--color-surface); box-shadow: 0 2px 4px rgba(0,0,0,.18), 0 0 0 2px rgba(255,255,255,.55); }
.avatar-text { color:#ffffff !important; text-shadow:0 1px 2px rgba(0,0,0,.55); font-weight:700; letter-spacing:.5px; }
body.dark-mode .avatar-text { text-shadow:0 1px 2px rgba(0,0,0,.35); }
body.dark-mode .avatar { border:2px solid var(--color-surface-alt); box-shadow:0 2px 6px rgba(0,0,0,.55), 0 0 0 2px rgba(0,0,0,.25); }

/* Chat specific */
.chat-item { 
  position: relative !important; 
  overflow: hidden !important; 
}
.chat-item:hover { background: var(--color-bg-alt); }
body.dark-mode .chat-item:hover { background:#252c37; }

/* Modal */
.modal-content { backdrop-filter: blur(2px); }

/* Code */
code { background: var(--color-surface-alt); padding:.15rem .4rem; border-radius: var(--radius-sm); font-size:.85em; color: var(--color-text); }
body.dark-mode code { background:#262d38; color: var(--color-text); }

/* Lists */
.list-group-item { transition: background var(--transition); }
.list-group-item:hover { background: var(--color-surface-alt); }
body.dark-mode .list-group-item:hover { background:#262d38; }

/* Accessibility */
:focus-visible { outline: 2px solid var(--color-primary); outline-offset:2px; }
body.dark-mode .text-secondary { color: var(--color-text-muted) !important; }
body.dark-mode .text-body { color: var(--color-text) !important; }
body.dark-mode .fw-semibold, body.dark-mode .fw-bold { color: var(--color-text) !important; }
.spinner-border { color: var(--color-primary); }
/* Chat filters / inputs themed */
.input-theme .input-group-text { background: var(--color-surface-alt); color: var(--color-text-soft); border-color: var(--color-border); }
.input-theme .form-control { background: var(--color-surface-alt); border-color: var(--color-border); color: var(--color-text); }
.input-theme .form-control:focus { background: var(--color-surface); }
/* placeholder colors */
.input-theme .form-control::placeholder { color: var(--color-text-faint) !important; opacity: 1; }
body.dark-mode .input-theme .form-control::placeholder { color: var(--color-text-muted) !important; }
body.dark-mode .input-theme .input-group-text { background: #262d38; color: var(--color-text-soft); border-color: var(--color-border); }
body.dark-mode .input-theme .form-control { background: #262d38; border-color: var(--color-border); color: var(--color-text); }
body.dark-mode .input-theme .form-control:focus { background:#1f2530; }

.filter-bar { background: var(--color-surface-alt); border:1px solid var(--color-border); }
body.dark-mode .filter-bar { background:#262d38; border-color: var(--color-border-strong); }

/* Placeholder theming (improved specificity) */
:root { --placeholder-color-light: var(--color-text-faint); --placeholder-color-dark: var(--color-text-muted); }
body.dark-mode { --placeholder-color-light: var(--color-text-muted); }
/* Base generic (kept for other inputs) */
.input-theme .form-control::placeholder { color: var(--placeholder-color-light) !important; opacity: 1; }
/* High-specificity override for chat search */
.input-theme input#chatSearch.form-control::placeholder { color: var(--placeholder-color-light) !important; }
body.dark-mode .input-theme input#chatSearch.form-control::placeholder { color: var(--placeholder-color-dark) !important; }
/* Vendor prefixed with specificity */
.input-theme input#chatSearch.form-control::-webkit-input-placeholder { color: var(--placeholder-color-light) !important; }
body.dark-mode .input-theme input#chatSearch.form-control::-webkit-input-placeholder { color: var(--placeholder-color-dark) !important; }
.input-theme input#chatSearch.form-control::-moz-placeholder { color: var(--placeholder-color-light) !important; }
body.dark-mode .input-theme input#chatSearch.form-control::-moz-placeholder { color: var(--placeholder-color-dark) !important; }
.input-theme input#chatSearch.form-control:-ms-input-placeholder { color: var(--placeholder-color-light) !important; }
body.dark-mode .input-theme input#chatSearch.form-control:-ms-input-placeholder { color: var(--placeholder-color-dark) !important; }
.input-theme input#chatSearch.form-control::-ms-input-placeholder { color: var(--placeholder-color-light) !important; }
body.dark-mode .input-theme input#chatSearch.form-control::-ms-input-placeholder { color: var(--placeholder-color-dark) !important; }
/* Specific override for chat search input text & placeholder */
.chat-search-input { color: var(--color-text) !important; }
.chat-search-input::placeholder { color: var(--color-text-faint) !important; }
body.dark-mode .chat-search-input { color: var(--color-text) !important; }
body.dark-mode .chat-search-input::placeholder { color: var(--color-text-muted) !important; }
/* Login page specific styles */
.login-wrapper {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
  position: relative;
}
.login-wrapper::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 20% 80%, rgba(255,255,255,0.1) 0%, transparent 50%),
              radial-gradient(circle at 80% 20%, rgba(255,255,255,0.08) 0%, transparent 50%);
}
.login-card {
  position: relative;
  z-index: 1;
  max-width: 400px;
  width: 100%;
  border-radius: 1.5rem;
  border: none;
  background: var(--color-surface);
  backdrop-filter: blur(10px);
}
body.dark-mode .login-card {
  background: var(--color-surface);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.login-logo .logo-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  border-radius: 18px;
  font-size: 1.6rem;
  color: white;
  box-shadow: 0 8px 28px rgba(79,110,247,0.3);
  position: relative;
  overflow: hidden;
}
.login-logo .logo-icon::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255,255,255,0.1), transparent);
  transform: rotate(45deg);
  animation: shimmer 3s infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
  50% { transform: translateX(100%) translateY(100%) rotate(45deg); }
  100% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
}

body.dark-mode .login-wrapper {
  background: linear-gradient(135deg, #1a1d2e 0%, #16213e 100%);
}

  /* ===============================
     FEEDBACK SYSTEM
     =============================== */

  #feedbackBtn {
    border: 2px solid var(--color-border-strong);
  }

  body.dark-mode #feedbackBtn {
    border-color: var(--color-border);
  }

  .feedback-form {
  width: 340px;
  background: var(--color-surface);
  border: 2px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: feedbackSlideIn 0.3s ease-out;
  overflow: hidden;
  backdrop-filter: blur(8px);
  z-index: 2000;
}

body.dark-mode .feedback-form {
  background: var(--color-surface);
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(8px);
}

.feedback-header {
  padding: 1.5rem 1.5rem 1rem;
  background: var(--color-surface-alt);
  border-bottom: 2px solid var(--color-border);
}

body.dark-mode .feedback-header {
  background: var(--color-surface-alt);
  border-bottom-color: var(--color-border);
}

.feedback-body {
  padding: 1.5rem;
  background: var(--color-surface);
}

body.dark-mode .feedback-body {
  background: var(--color-surface);
}

.feedback-success {
  padding: 2.5rem 1.5rem;
  background: var(--color-surface);
}

body.dark-mode .feedback-success {
  background: var(--color-surface);
}

.feedback-form .form-label {
  color: var(--color-text);
  margin-bottom: 0.75rem;
  font-weight: 500;
  font-size: 0.9rem;
}

.feedback-form .form-control {
  border-radius: var(--radius);
  border: 2px solid var(--color-border);
  background: var(--color-surface-alt);
  color: var(--color-text);
  font-size: 0.9rem;
  padding: 0.75rem;
  transition: all var(--transition);
  margin-bottom: 0.5rem;
}

.feedback-form .form-control:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-focus-ring);
  background: var(--color-surface);
}

.feedback-form .form-text {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  margin-top: 0.25rem;
  margin-bottom: 1rem;
}

body.dark-mode .feedback-form .form-control {
  background: var(--color-surface-alt);
  border-color: var(--color-border);
  color: var(--color-text);
}

body.dark-mode .feedback-form .form-control:focus {
  background: var(--color-surface);
  border-color: var(--color-primary);
}

.feedback-form .btn {
  padding: 0.75rem 1.25rem;
  font-weight: 500;
  border-radius: var(--radius);
  transition: all var(--transition);
  border: 2px solid transparent;
  margin-top: 0.5rem;
}

.feedback-form .btn-primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.feedback-form .btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  transform: translateY(-1px);
}

.feedback-form .btn-outline-secondary {
  color: var(--color-text-soft);
  border-color: var(--color-border);
  background: transparent;
}

.feedback-form .btn-outline-secondary:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-border-strong);
  color: var(--color-text);
}

.feedback-form .mb-3 {
  margin-bottom: 1.5rem !important;
}

.feedback-form .d-flex.gap-2 {
  gap: 0.75rem !important;
  margin-top: 1rem;
}

/* Backdrop overlay for better visibility */
.feedback-form::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.1);
  z-index: -1;
  pointer-events: none;
}

body.dark-mode .feedback-form::before {
  background: rgba(0, 0, 0, 0.3);
}

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

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

.feedback-form.hiding {
  animation: feedbackSlideOut 0.3s ease-in;
}

@media (max-width: 768px) {
  .feedback-form {
    width: calc(100vw - 2rem);
    right: 1rem !important;
    left: 1rem !important;
  }
  
  .feedback-header {
    padding: 1.25rem 1.25rem 0.75rem;
  }
  
  .feedback-body {
    padding: 1.25rem;
  }
  
  .feedback-success {
    padding: 2rem 1.25rem;
  }
}

/* ===============================
   BOT THINKING ANIMATION
   =============================== */
.bot-thinking-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    var(--color-primary),
    var(--color-accent),
    var(--color-primary)
  );
  background-size: 200% 100%;
  animation: shimmerGradient 2s ease-in-out infinite;
  border-radius: var(--radius-lg);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  opacity: 0.95;
  pointer-events: none;
}

body.dark-mode .bot-thinking-overlay {
  opacity: 0.98;
}

@keyframes shimmerGradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.bot-thinking-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: white;
  font-weight: 600;
  font-size: 1rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  animation: fadeInScale 0.4s ease-out;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.bot-thinking-icon {
  width: 24px;
  height: 24px;
  border: 3px solid white;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.bot-thinking-dots {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.bot-thinking-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: white;
  animation: thinkingDot 1.4s ease-in-out infinite;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

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

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

@keyframes thinkingDot {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.5;
  }
  40% {
    transform: scale(1.2);
    opacity: 1;
  }
}

.bot-thinking-overlay.fade-out {
  animation: fadeOutOverlay 0.4s ease-out forwards;
}

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

/* ===============================
   BOT TEST MODAL
   =============================== */
.bot-test-bubble {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

body.dark-mode .bot-test-bubble {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border-color: var(--color-border);
}

/* File chips in bot test messages */
.bot-test-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  margin: 2px 4px;
  vertical-align: middle;
}
.bot-test-file-chip.image {
  background: rgba(34, 197, 94, 0.15);
  color: #16a34a;
  border: 1px solid rgba(34, 197, 94, 0.3);
}
.bot-test-file-chip.document {
  background: rgba(59, 130, 246, 0.15);
  color: #2563eb;
  border: 1px solid rgba(59, 130, 246, 0.3);
}
.bot-test-file-chip.unknown {
  background: rgba(234, 179, 8, 0.15);
  color: #ca8a04;
  border: 1px solid rgba(234, 179, 8, 0.3);
}
.bot-test-file-chip i {
  font-size: 0.75rem;
}
body.dark-mode .bot-test-file-chip.image {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
}
body.dark-mode .bot-test-file-chip.document {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}
body.dark-mode .bot-test-file-chip.unknown {
  background: rgba(234, 179, 8, 0.2);
  color: #facc15;
}
