/* ===============================================
   AGENTES PORTAL DARK THEME CUSTOM STYLES
   =============================================== */

/* === DARK THEME OVERRIDES === */
[data-bs-theme="dark"] {
  --bs-body-bg: #111827;
  --bs-body-color: #e9ecef;
  --bs-secondary-bg: #2d2d2d;
  --bs-tertiary-bg: #404040;
  --bs-border-color: #404040;
  --bs-secondary-color: #adb5bd;
}

/* === HEADER AND NAVIGATION === */
[data-bs-theme="dark"] .navbar {
  background-color: #212529 !important;
  border-bottom: 1px solid #404040;
}

[data-bs-theme="dark"] .nav-link {
  color: #adb5bd !important;
}

[data-bs-theme="dark"] .nav-link:hover,
[data-bs-theme="dark"] .nav-link:focus {
  color: #fff !important;
}

[data-bs-theme="dark"] .navbar-brand {
  color: #fff !important;
}

/* === CARDS AND CONTAINERS === */
[data-bs-theme="dark"] .card {
  background-color: #2d2d2d;
  border-color: #404040;
  color: #e9ecef;
}

[data-bs-theme="dark"] .card-header {
  background-color: #343a40;
  border-bottom-color: #404040;
  color: #fff;
}

[data-bs-theme="dark"] .card-body {
  background-color: #2d2d2d;
}

/* === CHAT MESSAGE LIST BACKGROUND === */
[data-bs-theme="dark"] #messageList {
  background: #3a3d5d !important;
}

[data-bs-theme="dark"] .message-row.inbound .message-bubble {
  background-color: #114a6b;
  border-bottom-left-radius: 0.25rem;
}

[data-bs-theme="dark"] .message-row.outbound .message-bubble {
  background-color: #114a6b;
  border-bottom-left-radius: 0.25rem;
}

/* === CONVERSATION CARDS === */
[data-bs-theme="dark"] .conversation-card {
  background: rgba(30, 30, 40, 0.9) !important;
  color: #e9ecef;
}

/* === CONVERSATION ELEMENTS === */
[data-bs-theme="dark"] .conversation-item {
  background-color: #2d2d2d;
  border-color: #404040;
  color: #e9ecef;
}

[data-bs-theme="dark"] .conversation-item:hover {
  background-color: #343a40;
  border-color: #495057;
}

[data-bs-theme="dark"] .user-message {
  color: #adb5bd;
  background-color: #343a40;
  border-left: 3px solid #0d6efd;
}

[data-bs-theme="dark"] .llm-response {
  color: #e9ecef;
  background-color: #2d2d2d;
}

/* === MESSAGE BUBBLES === */
[data-bs-theme="dark"] .message-bubble {
  background-color: #343a40;
  border-color: #495057;
  color: #e9ecef;
}

[data-bs-theme="dark"] .message-bubble.user-message {
  background-color: #0d6efd;
  color: #fff;
}

[data-bs-theme="dark"] .message-bubble.assistant-message {
  background-color: #2d2d2d;
  border: 1px solid #404040;
  color: #e9ecef;
}

/* === STATUS BADGES === */
[data-bs-theme="dark"] .badge {
  color: #fff;
}

[data-bs-theme="dark"] .badge.bg-success {
  background-color: #198754 !important;
}

[data-bs-theme="dark"] .badge.bg-warning {
  background-color: #fd7e14 !important;
  color: #000;
}

[data-bs-theme="dark"] .badge.bg-danger {
  background-color: #dc3545 !important;
}

[data-bs-theme="dark"] .badge.bg-info {
  background-color: #0dcaf0 !important;
  color: #000;
}

/* === FORM ELEMENTS === */
[data-bs-theme="dark"] .form-control {
  background-color: #2d2d2d;
  border-color: #495057;
  color: #e9ecef;
}

[data-bs-theme="dark"] .form-control:focus {
  background-color: #2d2d2d;
  border-color: #86b7fe;
  color: #e9ecef;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

[data-bs-theme="dark"] .form-select {
  background-color: #2d2d2d;
  border-color: #495057;
  color: #e9ecef;
}

[data-bs-theme="dark"] .form-check-input {
  background-color: #2d2d2d;
  border-color: #495057;
}

[data-bs-theme="dark"] .form-check-input:checked {
  background-color: #0d6efd;
  border-color: #0d6efd;
}

/* === BUTTONS === */
[data-bs-theme="dark"] .btn-outline-primary {
  color: #86b7fe;
  border-color: #86b7fe;
}

[data-bs-theme="dark"] .btn-outline-primary:hover,
[data-bs-theme="dark"] .btn-outline-primary:focus {
  background-color: #0d6efd;
  border-color: #0d6efd;
  color: #fff;
}

[data-bs-theme="dark"] .btn-outline-secondary {
  color: #adb5bd;
  border-color: #6c757d;
}

[data-bs-theme="dark"] .btn-outline-secondary:hover,
[data-bs-theme="dark"] .btn-outline-secondary:focus {
  background-color: #6c757d;
  border-color: #6c757d;
  color: #fff;
}

/* === MODALS === */
[data-bs-theme="dark"] .modal-content {
  background-color: #2d2d2d;
  border-color: #404040;
}

[data-bs-theme="dark"] .modal-header {
  background-color: #343a40;
  border-bottom-color: #404040;
  color: #fff;
}

[data-bs-theme="dark"] .modal-body {
  background-color: #2d2d2d;
  color: #e9ecef;
}

[data-bs-theme="dark"] .modal-footer {
  background-color: #2d2d2d;
  border-top-color: #404040;
}

/* === DROPDOWN MENUS === */
[data-bs-theme="dark"] .dropdown-menu {
  background-color: #2d2d2d;
  border-color: #404040;
}

[data-bs-theme="dark"] .dropdown-item {
  color: #e9ecef;
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
  background-color: #343a40;
  color: #fff;
}

[data-bs-theme="dark"] .dropdown-divider {
  border-top-color: #404040;
}

/* === ULTRA-COMPACT HEADER STYLES === */
[data-bs-theme="dark"] .sidebar-header-compact {
  background-color: #252a31;
  border-bottom: 1px solid #2d3748;
  min-height: 64px;
  padding: 8px 12px !important;
}

/* === TABLES === */
[data-bs-theme="dark"] .btn-sm {
  padding: 0.2rem 0.4rem;
}

[data-bs-theme="dark"] .btn-xs {
  padding: 0.1rem 0.3rem;
  font-size: 0.7rem;
  line-height: 1.2;
}

[data-bs-theme="dark"] .header-actions .btn-xs {
  padding: 0.25rem 0.4rem;
  font-size: 0.75rem;
  line-height: 1.2;
}

[data-bs-theme="dark"] .btn-micro {
  padding: 0.1rem 0.2rem;
  font-size: 0.65rem;
  line-height: 1;
}

/* === SORT DROPDOWN OPTGROUP STYLING === */
[data-bs-theme="dark"] #sortFilter optgroup {
  background-color: #3a4149 !important;
  font-weight: 600 !important;
  font-style: normal !important;
  color: #e9ecef !important;
  padding: 4px 8px !important;
}

[data-bs-theme="dark"] #sortFilter option {
  background-color: #252a31 !important;
  color: #e9ecef !important;
  padding-left: 16px !important;
}

/* Icon-only delete button - no border, no background */
[data-bs-theme="dark"] .delete-client {
  background: none !important;
  border: none !important;
  padding: 0 !important;
  color: #dc3545;
  font-size: 0.85rem;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

[data-bs-theme="dark"] .delete-client:hover {
  opacity: 1;
  color: #dc3545;
  background: none !important;
}

/* === COMPACT TABLE-LIKE CLIENT LIST === */
[data-bs-theme="dark"] .client-item-micro {
  border-bottom: 1px solid #2d3748;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 28px;
  padding: 0;
}

[data-bs-theme="dark"] .client-item-micro:hover {
  background-color: #2d3339;
}

[data-bs-theme="dark"] .client-item-micro.active {
  background-color: #1e3a5f;
}

[data-bs-theme="dark"] .client-row-compact {
  display: grid;
  grid-template-columns: 1fr 50px minmax(200px, auto);
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  min-height: 40px;
  width: 100%;
  overflow: visible;
}

[data-bs-theme="dark"] .client-name-compact {
  font-weight: 500;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  line-height: 1.4;
  color: #e9ecef;
}

[data-bs-theme="dark"] .client-owner-compact {
  min-width: 50px;
  width: 50px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

[data-bs-theme="dark"] .client-badges-compact {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: visible;
  overflow-y: hidden;
  scrollbar-width: none;
  min-width: 200px;
}

[data-bs-theme="dark"] .client-badges-compact::-webkit-scrollbar {
  display: none;
}

/* Fixed column widths for perfect alignment */
[data-bs-theme="dark"] .col-time {
  font-size: 0.75rem;
  min-width: 35px;
  display: inline-block;
  text-align: left;
}

[data-bs-theme="dark"] .col-phone {
  font-size: 0.75rem;
  min-width: 90px;
  display: inline-block;
}

[data-bs-theme="dark"] .col-sentiment {
  font-size: 0.9rem;
  min-width: 22px;
  display: inline-block;
  text-align: center;
}

[data-bs-theme="dark"] .col-priority {
  font-size: 0.6rem;
  min-width: 45px;
  display: inline-block;
}

[data-bs-theme="dark"] .col-complaint {
  font-size: 0.6rem;
  min-width: 50px;
  display: inline-block;
}

[data-bs-theme="dark"] .col-vip {
  font-size: 0.6rem;
  min-width: 35px;
  display: inline-block;
}

[data-bs-theme="dark"] .col-clienttype {
  font-size: 0.6rem;
  min-width: 55px;
  display: inline-block;
}

[data-bs-theme="dark"] .col-lang {
  font-size: 0.65rem;
  min-width: 30px;
  display: inline-block;
}

[data-bs-theme="dark"] .col-delete {
  padding: 2px 4px;
  border: none;
  background: none;
  color: #dc3545;
  opacity: 0.5;
  font-size: 0.8rem;
  min-width: 24px;
  width: 24px;
  flex-shrink: 0;
  transition: opacity 0.2s;
}

[data-bs-theme="dark"] .col-delete:hover {
  opacity: 1;
}

/* Status-based background colors for dark theme */
[data-bs-theme="dark"] .client-item-micro.status-new {
  background-color: #1e2328;
}

[data-bs-theme="dark"] .client-item-micro.status-pending {
  background-color: #3d3420;
  border-left: 3px solid #ffc107;
}

[data-bs-theme="dark"] .client-item-micro.status-active {
  background-color: #30536b;
  border-left: 3px solid #17a2b8;
}

[data-bs-theme="dark"] .client-item-micro.status-urgent {
  background-color: #3d2328;
  border-left: 3px solid #dc3545;
}

[data-bs-theme="dark"] .client-item-micro.status-completed {
  background-color: #1e3428;
  border-left: 3px solid #28a745;
}

[data-bs-theme="dark"] .status-indicator-micro {
  width: 16px;
  text-align: center;
  font-size: 0.8rem;
}

[data-bs-theme="dark"] .client-info-micro {
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: 1.1;
}

[data-bs-theme="dark"] .client-name-micro {
  font-weight: 500;
  font-size: 0.8rem;
  line-height: 1;
  margin-bottom: 1px;
  color: #e9ecef;
}

[data-bs-theme="dark"] .client-phone-micro {
  font-size: 0.7rem;
  line-height: 1;
  color: #94a3b8;
}

[data-bs-theme="dark"] .client-time-micro {
  font-size: 0.65rem;
  line-height: 1;
}

[data-bs-theme="dark"] .badge-micro {
  font-size: 0.55rem;
  padding: 0.1rem 0.25rem;
  line-height: 1;
  margin-right: 1px;
}

[data-bs-theme="dark"] .table th,
[data-bs-theme="dark"] .table td {
  border-color: #404040;
}

[data-bs-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > td,
[data-bs-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > th {
  background-color: #2d2d2d;
}

/* === CHAT CONTAINERS === */
[data-bs-theme="dark"] .chat-container {
  background-color: #111827;
  border-color: #404040;
}

[data-bs-theme="dark"] .chat-header {
  background-color: #212529;
  border-bottom-color: #404040;
  color: #fff;
}

[data-bs-theme="dark"] .chat-messages {
  background-color: #111827;
}

[data-bs-theme="dark"] .chat-input-container {
  background-color: #212529;
  border-top-color: #404040;
}

/* === ALERTS === */
[data-bs-theme="dark"] .alert-info {
  background-color: #0dcaf0;
  border-color: #b6effb;
  color: #055160;
}

[data-bs-theme="dark"] .alert-success {
  background-color: #198754;
  border-color: #badbcc;
  color: #0f5132;
}

[data-bs-theme="dark"] .alert-warning {
  background-color: #ffc107;
  border-color: #ffecb5;
  color: #664d03;
}

[data-bs-theme="dark"] .alert-danger {
  background-color: #dc3545;
  border-color: #f5c2c7;
  color: #842029;
}

/* === SCROLLBAR STYLING === */
[data-bs-theme="dark"] ::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

[data-bs-theme="dark"] ::-webkit-scrollbar-track {
  background: #2d2d2d;
  border-radius: 4px;
}

[data-bs-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #495057;
  border-radius: 4px;
}

[data-bs-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: #6c757d;
}

/* === THEME TOGGLE BUTTON === */
[data-bs-theme="dark"] .theme-toggle {
  background-color: #2d2d2d;
  border-color: #495057;
  color: #e9ecef;
}

[data-bs-theme="dark"] .theme-toggle:hover {
  background-color: #343a40;
  border-color: #6c757d;
  color: #fff;
}

/* === STATS CARDS === */
[data-bs-theme="dark"] .stats-card {
  background-color: #2d2d2d;
  border-color: #404040;
}

[data-bs-theme="dark"] .stats-value {
  color: #fff;
}

[data-bs-theme="dark"] .stats-label {
  color: #adb5bd;
}

/* === SIDEBAR === */
[data-bs-theme="dark"] .sidebar {
  background-color: #212529;
  border-right-color: #404040;
}

[data-bs-theme="dark"] .sidebar-item {
  color: #adb5bd;
}

[data-bs-theme="dark"] .sidebar-item:hover,
[data-bs-theme="dark"] .sidebar-item.active {
  background-color: #2d2d2d;
  color: #fff;
}

/* === LOADING STATES === */
[data-bs-theme="dark"] .loading-overlay {
  background-color: rgba(26, 26, 26, 0.8);
}

[data-bs-theme="dark"] .spinner-border {
  border-color: #495057;
  border-top-color: #0d6efd;
}

/* === PAGINATION === */
[data-bs-theme="dark"] .page-link {
  background-color: #2d2d2d;
  border-color: #495057;
  color: #adb5bd;
}

[data-bs-theme="dark"] .page-link:hover,
[data-bs-theme="dark"] .page-link:focus {
  background-color: #343a40;
  border-color: #6c757d;
  color: #fff;
}

[data-bs-theme="dark"] .page-item.active .page-link {
  background-color: #0d6efd;
  border-color: #0d6efd;
  color: #fff;
}

/* === CONVERSATION CARDS STYLING (DARK THEME) === */
[data-bs-theme="dark"] .active-threads-card {
  background-color: #2a3038;
  border-radius: 12px;
  border: 1px solid #3d4450;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-bs-theme="dark"] .active-threads-card .card-body {
  padding: 1.5rem;
}

/* Grouped threads section */
[data-bs-theme="dark"] .grouped-threads-section {
  margin-top: 2rem;
}

[data-bs-theme="dark"] .grouped-threads-section .accordion-item {
  background-color: #2d3339;
  border: 1px solid #3d4450;
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

[data-bs-theme="dark"] .grouped-threads-section .accordion-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
  border-color: #4a5361;
}

[data-bs-theme="dark"] .grouped-threads-section .accordion-button {
  padding: 1rem 1.25rem;
  font-size: 0.95rem;
  border: none;
  background-color: #2d3339;
  color: #d1d5db;
}

[data-bs-theme="dark"] .grouped-threads-section .accordion-button:not(.collapsed) {
  background-color: #353b43;
  box-shadow: none;
  color: #e5e7eb;
}

[data-bs-theme="dark"] .grouped-threads-section .accordion-button:focus {
  box-shadow: none;
  border: none;
}

[data-bs-theme="dark"] .grouped-threads-section .accordion-body {
  padding: 1.25rem;
  background-color: #2a3038;
}

/* Manual response box dark theme */
[data-bs-theme="dark"] .manual-response-box {
  background-color: #2a3038 !important;
  border-color: #3d4450 !important;
}

[data-bs-theme="dark"] .manual-response-box .form-control {
  background-color: #353b43;
  border-color: #3d4450;
  color: #e5e7eb;
}

[data-bs-theme="dark"] .manual-response-box .form-control:focus {
  background-color: #353b43;
  border-color: #4a90e2;
  color: #e5e7eb;
}
