:root {
    --sidebar-bg: #000;
    --sidebar-active-bg: #f3ef88;
    --sidebar-active-color: #000;
    --sidebar-color: #a0a8a3;
    --bg-color: #000000;
    --text-main: #ffffff;
    --text-muted: #8c8c8c;
    --border-color: #222222;
    --badge-active-bg: #f3ef88;
    --badge-active-color: #000;
    --badge-inactive-bg: #222222;
    --badge-inactive-color: #ffffff;
    --font-family: Arial, sans-serif;
    --font-size-base: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Top App Header */
.app-header {
    height: 44px;
    background-color: var(--sidebar-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px 0 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1020;
    flex-shrink: 0;
}

/* Logo */
.app-header .header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--sidebar-active-bg);
    font-size: 20px;
    font-weight: bold;
}

.app-header .header-logo i {
    font-size: 22px;
}

.app-header .brand-name {
    color: #fff;
    font-size: 16px;
    letter-spacing: 0.5px;
}

/* Nav links */
.app-header .header-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 100%;
}

.app-header .nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: var(--sidebar-color);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-header .nav-item i {
    font-size: 16px;
}

.app-header .nav-item:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.08);
}

.app-header .nav-item.active {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-active-color);
    font-weight: 600;
}

/* Right Section: User & Logout */
.app-header .header-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.app-header .user-details {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.app-header .user-name {
    color: #fff;
    font-weight: 600;
    font-size: 12px;
}

.app-header .user-role {
    color: var(--sidebar-color);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.app-header .btn-logout {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    color: var(--sidebar-color);
    text-decoration: none;
    font-size: 18px;
    transition: all 0.3s;
}

.app-header .btn-logout:hover {
    background-color: rgba(224, 82, 96, 0.2);
    color: #e05260;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 10px;
    position: sticky;
    top: 0;
    background-color: var(--bg-color);
    z-index: 1010;
    border-bottom: 1px solid var(--border-color);
}

.dataTables_length {
    margin-bottom: 4px !important;
}

.header h1 {
    font-size: 24px;
    font-weight: 600;
}

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

.search-box {
    position: relative;
}

.search-box input {
    padding: 10px 15px;
    padding-right: 35px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    outline: none;
    width: 400px !important;
}

.search-box i {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    cursor: pointer;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--sidebar-bg);
    color: #fff;
}

.btn-primary:hover {
    background-color: #000;
}

.btn-success {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-active-color);
}

.btn-danger {
    background-color: #e05260;
    color: #fff;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn-danger:hover {
    background-color: #cb3d4b;
}

.btn-danger:active {
    transform: scale(0.97);
}

/* Table */
.data-container {
    padding: 0px 10px 10px 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    padding: 15px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

table th {
    background-color: #222121;
    color: #FFF;
    font-weight: bold;
}

table td {
    font-size: 14px;
}

table td .subtext {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.badge {
    padding: 6px 12px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 11px;
    text-align: center;
    display: inline-block;
}

.badge.active {
    background-color: var(--badge-active-bg);
    color: var(--badge-active-color);
}

.badge.inactive {
    background-color: var(--badge-inactive-bg);
    color: var(--badge-inactive-color);
}

.badge.restringido {
    background-color: #dc3545;
    color: #fff;
}

.badge.asesor-aut {
    background-color: #007bff;
    color: #fff;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    width: 400px;
    max-width: 90%;
}

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

.modal-header h2 {
    font-size: 18px;
}

.close-modal {
    cursor: pointer;
    font-size: 20px;
    color: var(--text-muted);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    outline: none;
}

/* Auth Pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, var(--sidebar-bg) 0%, #0a110d 100%);
    width: 100%;
}

.auth-box {
    width: 400px;
    padding: 50px 40px;
    background: #ffffff;
    border: none;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-box h2 {
    margin-bottom: 30px;
    text-align: center;
    font-size: 28px;
    color: var(--text-main);
}

.auth-box .form-group label {
    font-weight: bold;
    font-size: 13px;
    color: var(--text-main);
}

.auth-box .form-group input {
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    transition: all 0.3s ease;
    font-size: 14px;
}

.auth-box .form-group input:focus {
    border-color: var(--sidebar-bg);
    box-shadow: 0 0 0 3px rgba(17, 28, 22, 0.1);
}

.auth-box .btn {
    width: 100%;
    justify-content: center;
    margin-top: 20px;
    padding: 12px;
    font-size: 15px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.auth-box .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* Utility */
.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.d-none {
    display: none !important;
}

.mt-20 {
    margin-top: 20px;
}

/* GLOBAL DARK MODE OVERRIDES (White Text & Black Background) */
body,
html {
    background-color: #000000 !important;
    background: #000000 !important;
    color: #ffffff !important;
}

/* Override all headers, text containers, cards, tables, search boxes, inputs and panels */
h1,
h2,
h3,
h4,
h5,
h6,
.header,
.header h1,
.header-actions-container,
.bottom-layout,
.table-wrapper,
table,
table td,
.data-container,
.main-content,
.kpi-card,
.chart-container,
.modal-content,
.auth-box,
.custom-multiselect-content,
.custom-multiselect-content label,
#notification-dropdown,
#notification-items-list,
#floating-chat-drawer,
#float-contacts-view,
#float-thread-view,
#float-messages-log,
.float-chat-item,
.modal-header,
.modal-footer,
#scroll-indicator-top,
#scroll-indicator-bottom,
#asesores-checkbox-list,
#migration-drop-zone,
#error-summary-card,
.card,
.card-body,
.card-header,
.card-footer,
.chat-wrapper,
.chat-sidebar,
.chat-main,
.chat-no-active,
.chat-header,
.chat-messages-container,
.chat-input-container,
.sidebar-actions,
.members-select-list,
.member-select-item,
.dashboard-container,
.dashboard-header-area,
.metric-pill,
.extension-card,
.modal-content-premium,
.modal-header-premium,
.modal-left-panel,
.modal-right-panel,
.call-item-card,
.metric-card-premium,
.chart-box-premium,
.insight-card-premium,
.terminal-panel,
.terminal-header,
.terminal-body,
#detailsActivityForm textarea,
#detailsActivityForm input,
#detailsReminderForm select,
#detailsReminderForm input,
#live-call-status-bar,
#deviceForm,
table tr,
table.dataTable thead th,
table.dataTable thead td,
.dataTables_wrapper,
.dataTables_info,
.dataTables_length,
.dataTables_filter,
.paginate_button {
    background-color: #000000 !important;
    background: #000000 !important;
    color: #ffffff !important;
    border-color: #222222 !important;
}

/* Border styling overrides */
table td,
table th,
.header,
.header-actions-container,
.bottom-layout,
.modal-header,
.modal-footer,
.form-group input,
.form-group select,
.form-group textarea,
.custom-multiselect-content,
#notification-dropdown,
#floating-chat-drawer,
#asesores-checkbox-list,
.chat-sidebar,
.chat-header,
.chat-input-container,
.sidebar-actions,
.members-select-list,
.member-select-item,
.sidebar-search-container,
.dashboard-header-area,
.metric-pill,
.extension-card,
.modal-content-premium,
.modal-header-premium,
.modal-left-panel,
.modal-right-panel,
.call-item-card,
.metric-card-premium,
.chart-box-premium,
.insight-card-premium,
.terminal-panel,
.terminal-header,
.terminal-body,
#deviceForm {
    border-color: #222222 !important;
}

/* Specific KPI value text */
.kpi-card .value {
    color: #ffffff !important;
}

/* Links and brand active tags */
a,
table td a,
.brand-name,
.close-modal,
.filter-icon:hover,
.chat-item-name,
.chat-header-title {
    color: #ffffff !important;
}

/* Gold details */
.brand-logo,
.brand-name {
    color: var(--sidebar-active-bg) !important;
}

/* Force specific nested text labels to white */
.metric-value,
.chart-box-title,
.call-phone,
.call-duration,
.advisor-ext,
.advisor-ext strong,
.panel-section-title,
.metric-label,
.advisor-event-log,
.advisor-stat-col,
.empty-feed,
table td a,
table td span,
.terminal-header-title,
.terminal-body,
.close-modal,
.header-subtitle,
label,
.advisor-name,
.advisor-ext strong {
    color: #ffffff !important;
}

/* Inputs, textareas, selects */
input,
select,
textarea,
.form-group input,
.form-group select,
.form-group textarea,
#contactosDT_filter input,
#float-search-input,
#float-message-input,
.search-box input,
.sidebar-search-box input,
.chat-input-field {
    background-color: #111111 !important;
    background: #111111 !important;
    color: #ffffff !important;
    border: 1px solid #333333 !important;
}

input:focus,
select:focus,
textarea:focus,
.chat-input-field:focus {
    border-color: var(--sidebar-active-bg) !important;
    box-shadow: 0 0 0 2px rgba(243, 239, 136, 0.2) !important;
    background-color: #000000 !important;
}

input::placeholder,
textarea::placeholder {
    color: #666666 !important;
}

/* Buttons */
.btn-primary {
    background-color: #111111 !important;
    color: #ffffff !important;
    border: 1px solid #333333 !important;
}

.btn-primary:hover {
    background-color: #222222 !important;
    border-color: #444444 !important;
}

.chat-input-btn {
    background-color: #111111 !important;
    color: #ffffff !important;
}

.chat-input-btn:hover {
    background-color: #222222 !important;
    color: var(--sidebar-active-bg) !important;
}

/* DataTables pagination */
.dataTables_wrapper .dataTables_paginate .paginate_button {
    color: #ffffff !important;
    background: #111111 !important;
    border: 1px solid #222222 !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #222222 !important;
    color: #ffffff !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--sidebar-active-bg) !important;
    color: #000000 !important;
    font-weight: bold;
}

/* Table header */
table th,
#contactosDT thead th {
    background-color: #111111 !important;
    color: #ffffff !important;
    border-bottom: 2px solid #333333 !important;
}

/* Hover effects */
.float-chat-item:hover,
.chat-item:hover {
    background-color: #222222 !important;
}

.chat-item.active {
    background-color: #2a2a2a !important;
}

/* Header and action icons hover overrides */
.header-icon:hover,
.filter-icon:hover {
    color: var(--sidebar-active-bg) !important;
}

/* Chat bubble styling (self vs other) */
.float-message-row.self .float-message-bubble,
.message-row.self .message-bubble {
    background-color: var(--sidebar-active-bg) !important;
    color: #000000 !important;
}

.float-message-row.other .float-message-bubble,
.message-row.other .message-bubble,
.typing-indicator-bubble {
    background-color: #fcfcfc !important;
    color: #ffffff !important;
    border: 1px solid #222222 !important;
}

/* Audio recording overlay and file attachment */
.recording-overlay {
    background-color: #000000 !important;
}

.message-media-file {
    background: rgba(0, 0, 0, 0.4) !important;
    border-color: #222222 !important;
}

.message-media-file:hover {
    background: rgba(0, 0, 0, 0.7) !important;
}

.message-media-file i {
    color: #ffffff !important;
}

/* Chat message canvas styling */
.chat-messages-container {
    background-image: radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 0) !important;
}

/* Scrollbar thumbs in dark mode */
.chat-messages-container::-webkit-scrollbar-thumb,
#float-list-scroll::-webkit-scrollbar-thumb,
#float-messages-log::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2) !important;
}

/* Muted subtexts */
.text-muted,
.subtext,
.chat-item-lastmsg,
.chat-item-time,
.chat-header-status {
    color: #8c8c8c !important;
}

/* Preserve active Call State indicator metrics in webhook panel */
.extension-card.state-talking {
    background-color: #22c55e !important;
    background: #22c55e !important;
    color: #ffffff !important;
}

.extension-card.state-ringing {
    background-color: #fbbf24 !important;
    background: #fbbf24 !important;
    color: #000000 !important;
}

.extension-card.state-hungup {
    background-color: #ef4444 !important;
    background: #ef4444 !important;
    color: #ffffff !important;
}

.state-talking .advisor-ext,
.state-hungup .advisor-ext {
    background: rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
}

.state-ringing .advisor-ext {
    background: rgba(0, 0, 0, 0.1) !important;
    color: #000000 !important;
}

.state-talking .advisor-ext strong,
.state-hungup .advisor-ext strong {
    color: #ffffff !important;
}

.state-ringing .advisor-ext strong {
    color: #000000 !important;
}

.state-talking .advisor-event-log,
.state-hungup .advisor-event-log {
    color: #ffffff !important;
}

.state-ringing .advisor-event-log {
    color: #000000 !important;
}

.state-talking .advisor-stat-col,
.state-hungup .advisor-stat-col {
    color: #ffffff !important;
}

.state-ringing .advisor-stat-col {
    color: #000000 !important;
}

/* Restore styling for warning buttons and warning badges */
.btn-warning {
    background-color: #ffc107 !important;
    background: #ffc107 !important;
    color: #000000 !important;
}

.btn-warning:hover {
    background-color: #e0a800 !important;
    background: #e0a800 !important;
    color: #000000 !important;
}

/* FORCE BLACK TEXT ON ALL YELLOW BACKGROUND CONTROLS AND THEIR CHILDREN */
.btn-warning,
.btn-warning *,
.badge.active,
.badge.active *,
.nav-item.active,
.nav-item.active *,
.extension-card.state-ringing,
.extension-card.state-ringing *,
.float-message-row.self .float-message-bubble,
.float-message-row.self .float-message-bubble *,
.message-row.self .message-bubble,
.message-row.self .message-bubble *,
.chat-item.active,
.chat-item.active * {
    color: #000000 !important;
}

/* Ensure chat contact names in direct messaging (both main chat and float chat) are white */
.chat-item-name,
.float-item-name {
    color: #ffffff !important;
}

/* SAFETY-NET WILDCARD OVERRIDES FOR LEGACY INLINE BACKGROUNDS */
[style*="background: #ffffff"],
[style*="background:#ffffff"],
[style*="background: #fff"],
[style*="background:#fff"],
[style*="background: white"],
[style*="background:white"],
[style*="background: #f8fafc"],
[style*="background:#f8fafc"],
[style*="background: #fafafa"],
[style*="background:#fafafa"],
[style*="background: #f5f5f5"],
[style*="background:#f5f5f5"],
[style*="background-color: #ffffff"],
[style*="background-color:#ffffff"],
[style*="background-color: #fff"],
[style*="background-color:#fff"],
[style*="background-color: white"],
[style*="background-color:white"],
[style*="background-color: #f8fafc"],
[style*="background-color:#f8fafc"],
[style*="background-color: #fafafa"],
[style*="background-color:#fafafa"],
[style*="background-color: #f5f5f5"],
[style*="background-color:#f5f5f5"] {
    background-color: #000000 !important;
    background: #000000 !important;
}

/* SAFETY-NET WILDCARD OVERRIDES FOR LEGACY INLINE COLOR RULES */
[style*="color: #000000"],
[style*="color:#000000"],
[style*="color: #000"],
[style*="color:#000"],
[style*="color: black"],
[style*="color:black"],
[style*="color: #1e293b"],
[style*="color:#1e293b"],
[style*="color: #0f172a"],
[style*="color:#0f172a"],
[style*="color: #475569"],
[style*="color:#475569"],
[style*="color: #64748b"],
[style*="color:#64748b"],
[style*="color: #333"],
[style*="color:#333"],
[style*="color: #333333"],
[style*="color:#333333"] {
    color: #ffffff !important;
}

/* SAFETY-NET OVERRIDES TO FORCE BLACK TEXT ON ALL ELEMENTS WITH INLINE YELLOW BACKGROUNDS */
[style*="background: #fffbeb"],
[style*="background:#fffbeb"],
[style*="background: #fde68a"],
[style*="background:#fde68a"],
[style*="background-color: #fffbeb"],
[style*="background-color:#fffbeb"],
[style*="background-color: #fde68a"],
[style*="background-color:#fde68a"],
[style*="background: #fefcd7"],
[style*="background:#fefcd7"],
[style*="background-color: #fefcd7"],
[style*="background-color:#fefcd7"] {
    color: #000000 !important;
}

[style*="background: #fffbeb"] *,
[style*="background:#fffbeb"] *,
[style*="background: #fde68a"] *,
[style*="background:#fde68a"] *,
[style*="background-color: #fffbeb"] *,
[style*="background-color:#fffbeb"] *,
[style*="background-color: #fde68a"] *,
[style*="background-color:#fde68a"] *,
[style*="background: #fefcd7"] *,
[style*="background:#fefcd7"] *,
[style*="background-color: #fefcd7"] *,
[style*="background-color:#fefcd7"] * {
    color: #000000 !important;
}