/* ─── NMS Core Admin Panel ─────────────────────────────────────── */

:root {
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 68px;
    --sidebar-bg: #212529;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 0.9rem;
    background-color: #f5f6fa;
}

/* ─── Sidebar ─────────────────────────────────────────────────── */

#sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    position: sticky;
    top: 0;
    transition: width 0.25s ease;
    overflow: hidden;
}

#sidebar .nav-link {
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 2px;
    white-space: nowrap;
}

#sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

#sidebar .nav-link.active {
    background-color: #0d6efd;
}

/* ─── Sidebar collapsed ──────────────────────────────────────── */

#sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

#sidebar.collapsed .sidebar-text,
#sidebar.collapsed .sidebar-brand-text,
#sidebar.collapsed .dropdown,
#sidebar.collapsed #theme-toggle,
#sidebar.collapsed hr {
    display: none;
}

#sidebar.collapsed .nav-link {
    text-align: center;
    padding: 0.5rem;
    justify-content: center;
}

#sidebar.collapsed .nav-link i {
    margin-right: 0 !important;
    font-size: 1.2rem;
}

#sidebar.collapsed .nav-link .badge {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.55rem;
    padding: 0.15em 0.35em;
}

#sidebar.collapsed .nav-item,
#sidebar.collapsed li {
    position: relative;
}

#sidebar.collapsed .sidebar-toggle-btn {
    width: 100%;
    text-align: center;
}

#sidebar.collapsed > .d-flex {
    justify-content: center;
}

#sidebar.collapsed > .d-flex > a {
    margin-right: 0;
}

/* Toggle button */
.sidebar-toggle-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.6);
    border-radius: 0.375rem;
    padding: 0.3rem 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}
.sidebar-toggle-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

/* ─── Chat Layout ─────────────────────────────────────────────── */

.chat-container {
    background: #fff;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chat-list {
    background: #fafbfc;
}

.chat-list-item {
    transition: background 0.15s;
    cursor: pointer;
    color: inherit;
}

.chat-list-item:hover {
    background-color: #e9ecef;
}

.chat-list-item.active {
    background-color: #e3f2fd;
    border-left: 3px solid #0d6efd;
}

.chat-header {
    background: #fff;
}

/* ─── Messages ────────────────────────────────────────────────── */

#messages-area {
    background: #f0f2f5;
}

.message {
    display: flex;
}

.message-incoming {
    justify-content: flex-start;
}

.message-outgoing {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 70%;
    padding: 0.5rem 0.75rem;
    border-radius: 0.75rem;
    word-wrap: break-word;
    position: relative;
}

.message-incoming .message-bubble {
    border-bottom-left-radius: 0.25rem;
}

.message-outgoing .message-bubble {
    border-bottom-right-radius: 0.25rem;
}

.message-time {
    font-size: 0.7rem;
    text-align: right;
    margin-top: 2px;
}

.message-sender {
    opacity: 0.85;
}

/* ─── Delete button on manager messages ──────────────────────── */

.msg-delete-btn {
    opacity: 0;
    color: rgba(255,255,255,0.7);
    transition: opacity 0.15s;
    flex-shrink: 0;
    align-self: flex-start;
    line-height: 1;
}

.message-bubble:hover .msg-delete-btn {
    opacity: 1;
}

.msg-delete-btn:hover {
    color: #fff !important;
}

/* ─── Chat Input ──────────────────────────────────────────────── */

.chat-input {
    background: #fff;
}

/* ─── User Card ───────────────────────────────────────────────── */

.chat-user-card {
    background: #fafbfc;
}

.chat-user-card table td {
    padding: 0.2rem 0.4rem;
    font-size: 0.8rem;
}

/* ─── Cards ───────────────────────────────────────────────────── */

.card {
    border-radius: 0.5rem;
    border: 1px solid #e3e6ef;
}

/* ─── Badges ──────────────────────────────────────────────────── */

.badge-sm {
    font-size: 0.65rem;
    padding: 0.2em 0.5em;
}

/* ─── Responsive ──────────────────────────────────────────────── */

@media (max-width: 992px) {
    #sidebar {
        width: var(--sidebar-collapsed-width);
    }

    #sidebar .sidebar-text,
    #sidebar .sidebar-brand-text,
    #sidebar strong {
        display: none;
    }

    .chat-user-card {
        display: none;
    }
}

/* ─── Page fade-in ────────────────────────────────────────────── */

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

#page-content main {
    animation: fadeSlideIn 0.35s ease-out;
}

/* ─── Card lift on hover ──────────────────────────────────────── */

.card {
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.3s ease, border-color 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* ─── Footer ──────────────────────────────────────────────────── */

.nms-footer {
    border-top: 1px solid rgba(0,0,0,0.08);
    padding: 0.4rem 1rem;
    font-size: 0.75rem;
    color: #8c95a0;
    background: transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ─── Dark Mode overrides ─────────────────────────────────────── */

[data-bs-theme="dark"] body {
    background-color: #111318 !important;
    color: #c9d1d9 !important;
}

[data-bs-theme="dark"] #page-content {
    background-color: #111318 !important;
}

/* Bootstrap utility backgrounds */
[data-bs-theme="dark"] .bg-light {
    background-color: #1a1d23 !important;
}

[data-bs-theme="dark"] .bg-white {
    background-color: #1a1d23 !important;
}

[data-bs-theme="dark"] .bg-body {
    background-color: #111318 !important;
}

[data-bs-theme="dark"] .bg-body-secondary {
    background-color: #1a1d23 !important;
}

[data-bs-theme="dark"] .bg-body-tertiary {
    background-color: #21262d !important;
}

/* Cards */
[data-bs-theme="dark"] .card {
    background-color: #1a1d23 !important;
    border-color: #2a2d35 !important;
    color: #c9d1d9 !important;
}

[data-bs-theme="dark"] .card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.3) !important;
}

[data-bs-theme="dark"] .card-body {
    background-color: transparent !important;
    color: #c9d1d9 !important;
}

[data-bs-theme="dark"] .card-header {
    background-color: #1e2128 !important;
    border-bottom-color: #2a2d35 !important;
    color: #c9d1d9 !important;
}

[data-bs-theme="dark"] .card-footer {
    background-color: #1e2128 !important;
    border-top-color: #2a2d35 !important;
    color: #c9d1d9 !important;
}

/* Tables */
[data-bs-theme="dark"] .table {
    color: #c9d1d9 !important;
    --bs-table-bg: transparent !important;
    --bs-table-hover-bg: rgba(255,255,255,0.04) !important;
    --bs-table-striped-bg: rgba(255,255,255,0.02) !important;
}

[data-bs-theme="dark"] .table-light,
[data-bs-theme="dark"] thead.table-light th,
[data-bs-theme="dark"] thead th {
    background-color: #1e2128 !important;
    color: #8b949e !important;
    border-color: #2a2d35 !important;
}

[data-bs-theme="dark"] .table td,
[data-bs-theme="dark"] .table th {
    border-color: #21262d !important;
    color: #c9d1d9 !important;
}

[data-bs-theme="dark"] .table-hover tbody tr:hover {
    background-color: rgba(255,255,255,0.04) !important;
    color: #c9d1d9 !important;
}

/* Text overrides */
[data-bs-theme="dark"] .text-dark {
    color: #c9d1d9 !important;
}

[data-bs-theme="dark"] .text-body {
    color: #c9d1d9 !important;
}

[data-bs-theme="dark"] .text-muted {
    color: #6e7681 !important;
}

[data-bs-theme="dark"] h1, [data-bs-theme="dark"] h2, [data-bs-theme="dark"] h3,
[data-bs-theme="dark"] h4, [data-bs-theme="dark"] h5, [data-bs-theme="dark"] h6,
[data-bs-theme="dark"] .h1, [data-bs-theme="dark"] .h2, [data-bs-theme="dark"] .h3,
[data-bs-theme="dark"] .h4, [data-bs-theme="dark"] .h5, [data-bs-theme="dark"] .h6 {
    color: #e6edf3 !important;
}

[data-bs-theme="dark"] p, [data-bs-theme="dark"] span, [data-bs-theme="dark"] label,
[data-bs-theme="dark"] small, [data-bs-theme="dark"] div {
    color: inherit;
}

/* Forms */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #1a1d23 !important;
    border-color: #2a2d35 !important;
    color: #c9d1d9 !important;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: #21262d !important;
    border-color: #388bfd !important;
    color: #c9d1d9 !important;
    box-shadow: 0 0 0 0.2rem rgba(56,139,253,0.25) !important;
}

[data-bs-theme="dark"] .form-control::placeholder {
    color: #484f58 !important;
}

[data-bs-theme="dark"] .form-control:disabled,
[data-bs-theme="dark"] .form-control[readonly] {
    background-color: #161b22 !important;
    color: #6e7681 !important;
}

[data-bs-theme="dark"] .form-label {
    color: #c9d1d9 !important;
}

[data-bs-theme="dark"] .form-check-input {
    background-color: #21262d !important;
    border-color: #3d4148 !important;
}

[data-bs-theme="dark"] .form-check-label {
    color: #c9d1d9 !important;
}

[data-bs-theme="dark"] .input-group-text {
    background-color: #21262d !important;
    border-color: #2a2d35 !important;
    color: #8b949e !important;
}

/* Buttons */
[data-bs-theme="dark"] .btn-outline-primary {
    border-color: #388bfd !important;
    color: #58a6ff !important;
}

[data-bs-theme="dark"] .btn-outline-secondary {
    border-color: #3d4148 !important;
    color: #8b949e !important;
}

[data-bs-theme="dark"] .btn-outline-danger {
    border-color: #f85149 !important;
    color: #f85149 !important;
}

[data-bs-theme="dark"] .btn-light {
    background-color: #21262d !important;
    border-color: #3d4148 !important;
    color: #c9d1d9 !important;
}

[data-bs-theme="dark"] .btn-close {
    filter: invert(1) !important;
}

/* Alerts */
[data-bs-theme="dark"] .alert-danger {
    background-color: rgba(248,81,73,0.1) !important;
    border-color: rgba(248,81,73,0.2) !important;
    color: #f8a4a0 !important;
}

[data-bs-theme="dark"] .alert-success {
    background-color: rgba(63,185,80,0.1) !important;
    border-color: rgba(63,185,80,0.2) !important;
    color: #7ee787 !important;
}

[data-bs-theme="dark"] .alert-warning {
    background-color: rgba(210,153,34,0.1) !important;
    border-color: rgba(210,153,34,0.2) !important;
    color: #e3b341 !important;
}

[data-bs-theme="dark"] .alert-info {
    background-color: rgba(56,139,253,0.1) !important;
    border-color: rgba(56,139,253,0.2) !important;
    color: #58a6ff !important;
}

/* List group */
[data-bs-theme="dark"] .list-group-item {
    background-color: #1a1d23 !important;
    border-color: #21262d !important;
    color: #c9d1d9 !important;
}

[data-bs-theme="dark"] .list-group-item:hover {
    background-color: #21262d !important;
}

[data-bs-theme="dark"] .list-group-item.active {
    background-color: #388bfd !important;
    border-color: #388bfd !important;
}

/* Modal */
[data-bs-theme="dark"] .modal-content {
    background-color: #1a1d23 !important;
    border-color: #2a2d35 !important;
    color: #c9d1d9 !important;
}

[data-bs-theme="dark"] .modal-header {
    border-bottom-color: #21262d !important;
}

[data-bs-theme="dark"] .modal-footer {
    border-top-color: #21262d !important;
}

/* Chat */
[data-bs-theme="dark"] .chat-container {
    background-color: #1a1d23 !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3) !important;
}

[data-bs-theme="dark"] .chat-header,
[data-bs-theme="dark"] .chat-input {
    background-color: #1a1d23 !important;
    border-color: #2a2d35 !important;
}

[data-bs-theme="dark"] .chat-list {
    background-color: #151820 !important;
}

[data-bs-theme="dark"] .chat-list-item {
    color: #c9d1d9 !important;
}

[data-bs-theme="dark"] .chat-list-item:hover {
    background-color: #1e2128 !important;
}

[data-bs-theme="dark"] .chat-list-item.active {
    background-color: #182440 !important;
    border-left-color: #388bfd !important;
}

[data-bs-theme="dark"] #messages-area {
    background-color: #0d1117 !important;
}

[data-bs-theme="dark"] .message-bubble.bg-light {
    background-color: #21262d !important;
    color: #c9d1d9 !important;
}

[data-bs-theme="dark"] .message-bubble.bg-primary {
    color: #fff !important;
}

[data-bs-theme="dark"] .chat-user-card {
    background-color: #151820 !important;
    color: #c9d1d9 !important;
}

/* Sidebar */
[data-bs-theme="dark"] #sidebar {
    background-color: #0d1117 !important;
}

/* Borders */
[data-bs-theme="dark"] .border,
[data-bs-theme="dark"] .border-bottom,
[data-bs-theme="dark"] .border-top,
[data-bs-theme="dark"] .border-end,
[data-bs-theme="dark"] .border-start {
    border-color: #21262d !important;
}

[data-bs-theme="dark"] hr {
    border-color: #21262d !important;
    color: #21262d !important;
}

[data-bs-theme="dark"] .card.border-primary { border-color: #388bfd !important; }
[data-bs-theme="dark"] .card.border-warning { border-color: #d29922 !important; }
[data-bs-theme="dark"] .card.border-success { border-color: #3fb950 !important; }
[data-bs-theme="dark"] .card.border-info    { border-color: #58a6ff !important; }
[data-bs-theme="dark"] .card.border-secondary { border-color: #484f58 !important; }
[data-bs-theme="dark"] .card.border-dark    { border-color: #3d4148 !important; }
[data-bs-theme="dark"] .card.border-danger  { border-color: #f85149 !important; }

/* Badges */
[data-bs-theme="dark"] .badge.bg-light {
    background-color: #21262d !important;
    color: #c9d1d9 !important;
}

[data-bs-theme="dark"] .badge.bg-secondary {
    background-color: #3d4148 !important;
}

[data-bs-theme="dark"] code {
    color: #79c0ff !important;
}

/* Dropdown */
[data-bs-theme="dark"] .dropdown-menu {
    background-color: #1a1d23 !important;
    border-color: #2a2d35 !important;
}

[data-bs-theme="dark"] .dropdown-item {
    color: #c9d1d9 !important;
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
    background-color: #21262d !important;
    color: #e6edf3 !important;
}

[data-bs-theme="dark"] .dropdown-divider {
    border-color: #21262d !important;
}

/* Footer */
[data-bs-theme="dark"] .nms-footer {
    border-top-color: #21262d !important;
    color: #484f58 !important;
}

/* Pipeline kanban */
[data-bs-theme="dark"] .card .card.text-dark {
    color: #c9d1d9 !important;
    background-color: #21262d !important;
}

/* Sticky table header */
[data-bs-theme="dark"] thead.sticky-top th {
    background-color: #1e2128 !important;
}

/* Table row highlights */
[data-bs-theme="dark"] .table-danger {
    --bs-table-bg: rgba(248,81,73,0.08) !important;
    color: #f8a4a0 !important;
}

[data-bs-theme="dark"] .table-warning {
    --bs-table-bg: rgba(210,153,34,0.08) !important;
    color: #e3b341 !important;
}

[data-bs-theme="dark"] .table-secondary {
    --bs-table-bg: rgba(110,118,129,0.08) !important;
    color: #8b949e !important;
}

[data-bs-theme="dark"] .table-success {
    --bs-table-bg: rgba(63,185,80,0.08) !important;
    color: #7ee787 !important;
}

[data-bs-theme="dark"] .table-info {
    --bs-table-bg: rgba(56,139,253,0.08) !important;
    color: #58a6ff !important;
}

/* Pagination */
[data-bs-theme="dark"] .page-link {
    background-color: #1a1d23 !important;
    border-color: #2a2d35 !important;
    color: #58a6ff !important;
}

[data-bs-theme="dark"] .page-link:hover {
    background-color: #21262d !important;
}

[data-bs-theme="dark"] .page-item.active .page-link {
    background-color: #388bfd !important;
    border-color: #388bfd !important;
    color: #fff !important;
}

[data-bs-theme="dark"] .page-item.disabled .page-link {
    background-color: #161b22 !important;
    color: #484f58 !important;
}

/* Hover on table rows */
[data-bs-theme="dark"] tbody tr:hover {
    background-color: rgba(255,255,255,0.03) !important;
}

/* Breadcrumb */
[data-bs-theme="dark"] .breadcrumb {
    background-color: transparent !important;
}

[data-bs-theme="dark"] .breadcrumb-item a {
    color: #58a6ff !important;
}

[data-bs-theme="dark"] .breadcrumb-item.active {
    color: #8b949e !important;
}

/* Nav tabs / pills */
[data-bs-theme="dark"] .nav-tabs {
    border-bottom-color: #21262d !important;
}

[data-bs-theme="dark"] .nav-tabs .nav-link {
    color: #8b949e !important;
}

[data-bs-theme="dark"] .nav-tabs .nav-link.active {
    background-color: #1a1d23 !important;
    border-color: #21262d #21262d #1a1d23 !important;
    color: #e6edf3 !important;
}

/* Accordion */
[data-bs-theme="dark"] .accordion-item {
    background-color: #1a1d23 !important;
    border-color: #21262d !important;
}

[data-bs-theme="dark"] .accordion-button {
    background-color: #1a1d23 !important;
    color: #c9d1d9 !important;
}

[data-bs-theme="dark"] .accordion-button:not(.collapsed) {
    background-color: #1e2128 !important;
    color: #58a6ff !important;
}

/* Tooltip & Popover */
[data-bs-theme="dark"] .tooltip-inner {
    background-color: #21262d !important;
    color: #c9d1d9 !important;
}

/* Progress bar bg */
[data-bs-theme="dark"] .progress {
    background-color: #21262d !important;
}

/* Offcanvas */
[data-bs-theme="dark"] .offcanvas {
    background-color: #1a1d23 !important;
    color: #c9d1d9 !important;
}

/* Leads details: chat bubbles bg-light override */
[data-bs-theme="dark"] .rounded-3.bg-light {
    background-color: #21262d !important;
    color: #c9d1d9 !important;
}

[data-bs-theme="dark"] .bg-primary.bg-opacity-10 {
    background-color: rgba(56,139,253,0.12) !important;
}

/* Any remaining white utility overrides */
[data-bs-theme="dark"] .shadow-sm {
    box-shadow: 0 1px 3px rgba(0,0,0,0.3) !important;
}

[data-bs-theme="dark"] .shadow {
    box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
}

[data-bs-theme="dark"] .border-secondary {
    border-color: #3d4148 !important;
}

/* ─── Pulsing online indicator ────────────────────────────────── */

@keyframes pulse-green {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.pulse-online {
    animation: pulse-green 2s ease-in-out infinite;
}

/* ─── Theme transition ────────────────────────────────────────── */

body,
.chat-container,
.chat-list,
#messages-area {
    transition: background-color 0.3s ease, border-color 0.3s ease;
}
