/* Dark Mode bridge styles
 * -----------------------
 * Този файл вече НЕ дефинира пълна тема, а само мостови стилове върху
 * Bootstrap, които не са покрити от rs-* променливите и rea-* layout в app.css.
 */

/* Table light theme – use design tokens */
[data-bs-theme="light"] .table {
    --bs-table-bg: var(--bg-surface);
    --bs-table-striped-bg: var(--rs-color-surface-muted);
    --bs-table-hover-bg: var(--rs-layer-brand-soft);
}

[data-bs-theme="light"] .table > :not(caption) > * > * {
    border-bottom-color: var(--border-subtle);
}

[data-bs-theme="light"] .table thead th {
    background-color: var(--rs-color-surface-muted);
    color: var(--text-primary) !important;
}

[data-bs-theme="light"] .table thead.table-light th {
    background-color: var(--rs-color-surface-muted);
    color: var(--text-primary) !important;
}

/* Table dark mode tweaks – коригират Bootstrap table променливите */
[data-bs-theme="dark"] .table {
    --bs-table-bg: var(--bg-surface, #161c32);
    --bs-table-striped-bg: rgba(30, 36, 48, 0.85);
    --bs-table-hover-bg: rgba(220, 53, 69, 0.12);
}

[data-bs-theme="dark"] .table > :not(caption) > * > * {
    border-bottom-color: var(--border-subtle, #1a2133);
}

[data-bs-theme="dark"] .table thead th {
    background-color: #121620;
    color: var(--text-primary, #f1f5f9) !important;
}

/* Override Bootstrap .table-light when used on thead in dark mode (e.g. contact searches table) */
[data-bs-theme="dark"] .table thead.table-light th {
    background-color: #121620;
    color: var(--text-primary, #f1f5f9) !important;
}

/* Form controls – light theme: design tokens and focus ring */
[data-bs-theme="light"] .form-control,
[data-bs-theme="light"] .form-select {
    background-color: var(--bg-surface);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}

[data-bs-theme="light"] .form-control:focus,
[data-bs-theme="light"] .form-select:focus {
    border-color: var(--nav-link-active-color);
    box-shadow: 0 0 0 3px var(--rs-focus-ring);
}

/* Form controls – тъмен фон и фокус пръстен за Bootstrap полета */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: var(--bg-surface, #161c32);
    border-color: var(--border-subtle, #1a2133);
    color: var(--text-primary, #f1f5f9);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    border-color: var(--nav-link-active-color, var(--rs-color-primary));
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.28);
}

/* Alert – light theme: consistent panel look */
[data-bs-theme="light"] .alert {
    background-color: var(--bg-card);
    border-color: var(--border-subtle);
}

/* Alert – по-четим фон в dark режим */
[data-bs-theme="dark"] .alert {
    background-color: rgba(30, 36, 48, 0.92);
    border-color: var(--border-subtle, #1a2133);
}

/* Card header light theme */
[data-bs-theme="light"] .card-header {
    background-color: var(--rs-color-surface-muted);
    border-bottom-color: var(--border-subtle);
}

/* Card header dark mode */
[data-bs-theme="dark"] .card-header {
    background-color: rgba(255, 255, 255, 0.05);
    border-bottom-color: var(--border-color);
}

/* Dropdown light theme */
[data-bs-theme="light"] .dropdown-menu {
    background-color: var(--bg-card);
    border-color: var(--border-color);
}

[data-bs-theme="light"] .dropdown-item {
    color: var(--text-primary);
}

[data-bs-theme="light"] .dropdown-item:focus {
    background-color: var(--nav-link-active-bg);
    color: var(--text-primary);
}

/* Dropdown dark mode */
[data-bs-theme="dark"] .dropdown-menu {
    background-color: var(--bg-card);
    border-color: var(--border-color);
}

[data-bs-theme="dark"] .dropdown-item {
    color: var(--text-primary);
}

[data-bs-theme="dark"] .dropdown-item:focus {
    background-color: var(--nav-link-active-bg);
    color: var(--text-primary);
}

/* Modal light theme */
[data-bs-theme="light"] .modal-content {
    background-color: var(--bg-card);
    border-color: var(--border-subtle);
}

[data-bs-theme="light"] .modal-header {
    border-bottom-color: var(--border-subtle);
}

[data-bs-theme="light"] .modal-footer {
    border-top-color: var(--border-subtle);
}

/* Modal dark mode */
[data-bs-theme="dark"] .modal-content {
    background-color: var(--bg-card);
    border-color: var(--border-subtle);
}

[data-bs-theme="dark"] .modal-header {
    border-bottom-color: var(--border-subtle);
}

[data-bs-theme="dark"] .modal-footer {
    border-top-color: var(--border-subtle);
}

/* REA Call Modal */
#reaCallModal .modal-header {
    background-color: #dc3545 !important;
    color: #fff !important;
    border-bottom: none !important;
}

#reaCallModal .modal-header .modal-title {
    color: #fff !important;
}

#reaCallModal .modal-header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%) !important;
}

/* REA Call Modal - styled like sidebar nav items */
#reaCallModal .list-group-flush .list-group-item,
#reaCallModal .list-group-item {
    background: transparent !important;
    border: none !important;
    border-radius: 0.5rem !important;
    padding: 0.65rem 1rem !important;
    margin: 0.175rem 0 !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    color: rgba(0, 0, 0, 0.85) !important;
    font-weight: 500 !important;
}

[data-bs-theme="dark"] #reaCallModal .list-group-flush .list-group-item,
[data-bs-theme="dark"] #reaCallModal .list-group-item {
    color: rgba(255, 255, 255, 0.85) !important;
}

#reaCallModal .list-group-flush .list-group-item-action {
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.75rem !important;
}

#reaCallModal .list-group-flush .list-group-item-action:hover,
#reaCallModal .list-group-item-action:hover {
    background: linear-gradient(135deg, rgba(255, 248, 220, 0.18), rgba(250, 240, 200, 0.22)) !important;
    color: #000000 !important;
    box-shadow: 0 4px 12px rgba(198, 40, 40, 0.15) !important;
}

[data-bs-theme="dark"] #reaCallModal .list-group-flush .list-group-item-action:hover,
[data-bs-theme="dark"] #reaCallModal .list-group-item-action:hover {
    background: linear-gradient(135deg, rgba(255, 248, 220, 0.2), rgba(250, 240, 200, 0.25)) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(198, 40, 40, 0.18) !important;
}

#reaCallModal .list-group-flush .list-group-item-action:focus {
    background: linear-gradient(135deg, rgba(255, 248, 220, 0.2), rgba(250, 240, 200, 0.25)) !important;
    color: #000000 !important;
    outline: none !important;
    box-shadow:
        0 0 0 2px rgba(255, 248, 220, 0.5),
        0 4px 12px rgba(198, 40, 40, 0.15) !important;
}

[data-bs-theme="dark"] #reaCallModal .list-group-flush .list-group-item-action:focus {
    background: linear-gradient(135deg, rgba(255, 248, 220, 0.22), rgba(250, 240, 200, 0.28)) !important;
    color: #ffffff !important;
    box-shadow:
        0 0 0 2px rgba(255, 248, 220, 0.55),
        0 4px 12px rgba(198, 40, 40, 0.2) !important;
}

#reaCallModal .list-group-flush .list-group-item-action:active {
    background: linear-gradient(135deg, rgba(255, 248, 220, 0.15), rgba(250, 240, 200, 0.18)) !important;
}

[data-bs-theme="dark"] #reaCallModal .list-group-flush .list-group-item-action:active {
    background: linear-gradient(135deg, rgba(255, 248, 220, 0.18), rgba(250, 240, 200, 0.22)) !important;
}

#reaCallModal .list-group-flush .list-group-item.disabled,
#reaCallModal .list-group-item.disabled {
    background: transparent !important;
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

[data-bs-theme="dark"] #reaCallModal .list-group-flush .list-group-item.disabled,
[data-bs-theme="dark"] #reaCallModal .list-group-item.disabled {
    opacity: 0.5 !important;
}

#reaCallModal .list-group-flush .list-group-item i {
    font-size: 1.1rem !important;
    color: inherit !important;
    opacity: 0.85 !important;
    width: 1.25rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* REA Call Modal - light theme background */
[data-bs-theme="light"] #reaCallModal .modal-content {
    background-color: var(--bg-card);
}

/* REA Call Modal - dark mode background */
[data-bs-theme="dark"] #reaCallModal .modal-content {
    background-color: var(--bg-card, #161c32);
}

/* Smooth transitions */
body,
.sidebar,
.card,
.nav-link,
.form-control,
.form-select {
    transition:
        background-color var(--rs-transition),
        color var(--rs-transition),
        border-color var(--rs-transition),
        box-shadow var(--rs-transition);
}

/* Organization cards improvements */
.card.h-100 {
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.card.h-100:focus-within {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: rgba(220, 53, 69, 0.22);
}

[data-bs-theme="dark"] .card.h-100:focus-within {
    box-shadow: var(--shadow-md);
}

/* Page header improvements */
.border-bottom {
    border-bottom-color: var(--border-subtle) !important;
}

/* Button group improvements */
.btn-group .btn {
    border-color: var(--border-subtle);
}

/* ============================================
   Button System
   ============================================ */
.btn {
    border-radius: var(--rs-radius-sm);
    font-weight: 600;
    letter-spacing: 0.01em;
    transition:
        background-color var(--rs-transition),
        border-color var(--rs-transition),
        color var(--rs-transition),
        box-shadow var(--rs-transition);
}

.btn:not(.btn-link):focus {
    /* Removed transform to prevent element movement on click */
}

.btn-primary {
    background-color: var(--rs-color-primary);
    border-color: rgba(220, 53, 69, 0.85);
    color: #ffffff;
    box-shadow: 0 16px 34px rgba(220, 53, 69, 0.35);
}

.btn-primary:focus {
    background-color: var(--rs-color-primary-strong);
    border-color: var(--rs-color-primary-strong);
    color: #ffffff;
}

.btn-secondary {
    background-color: var(--bg-surface);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}

[data-bs-theme="light"] .btn-secondary:hover {
    background-color: var(--rs-color-surface-muted);
    border-color: rgba(220, 53, 69, 0.25);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.12);
}

[data-bs-theme="light"] .btn-secondary:focus {
    background-color: var(--rs-color-surface-muted);
    border-color: rgba(220, 53, 69, 0.35);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px var(--rs-focus-ring);
}

[data-bs-theme="dark"] .btn-secondary:hover {
    background-color: rgba(30, 36, 48, 0.85);
    border-color: rgba(220, 53, 69, 0.2);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.15);
}

[data-bs-theme="dark"] .btn-secondary:focus {
    background-color: rgba(30, 36, 48, 0.9);
    border-color: rgba(220, 53, 69, 0.35);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.2);
}

.btn-outline-primary {
    color: var(--rs-color-primary);
    border-color: rgba(220, 53, 69, 0.45);
    background-color: transparent;
}

.btn-outline-primary:focus {
    background-color: rgba(220, 53, 69, 0.18);
    border-color: var(--rs-color-primary);
    color: #ffffff;
}

.btn-outline-secondary {
    color: var(--text-muted);
    border-color: var(--border-subtle);
    background-color: transparent;
}

[data-bs-theme="light"] .btn-outline-secondary:hover {
    background-color: var(--rs-layer-muted-soft);
    border-color: rgba(220, 53, 69, 0.25);
    color: var(--text-primary);
}

[data-bs-theme="light"] .btn-outline-secondary:focus {
    background-color: var(--rs-layer-muted-soft);
    border-color: rgba(220, 53, 69, 0.35);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px var(--rs-focus-ring);
}

[data-bs-theme="dark"] .btn-outline-secondary:focus {
    background-color: rgba(30, 36, 48, 0.75);
    border-color: rgba(220, 53, 69, 0.2);
    color: var(--text-primary);
}

.btn-outline-success {
    color: var(--rs-color-success);
    border-color: rgba(45, 194, 107, 0.5);
}

.btn-outline-success:focus {
    background-color: rgba(45, 194, 107, 0.1);
    border-color: var(--rs-color-success);
    color: #0f1b26;
}

.btn-success {
    background-color: var(--rs-color-success);
    border-color: rgba(45, 194, 107, 0.9);
    color: #0f1b26;
}

.btn-success:focus {
    background-color: #26aa5f;
    border-color: #26aa5f;
    color: #041610;
}

.btn-danger {
    background-color: var(--rs-color-danger);
    border-color: rgba(181, 22, 22, 0.85);
    color: #fff4f4;
}

.btn-danger:focus {
    background-color: #991010;
    border-color: #991010;
    color: #fff6f6;
}

.btn-warning {
    background-color: var(--rs-color-warning);
    border-color: rgba(255, 111, 111, 0.85);
    color: #111826;
}

.btn-warning:focus {
    background-color: #ff8c8c;
    border-color: #ff8c8c;
    color: #111826;
}

.btn-info {
    background-color: var(--rs-color-info);
    border-color: rgba(255, 140, 135, 0.85);
    color: #2c0707;
}

.btn-info:focus {
    background-color: #ff9f9a;
    border-color: #ff9f9a;
    color: #2c0707;
}

.btn-dark {
    background-color: rgba(26, 32, 48, 0.95);
    border-color: rgba(17, 25, 43, 0.9);
    color: var(--text-primary);
}

.btn-dark:focus {
    background-color: #161d2d;
    border-color: rgba(220, 53, 69, 0.22);
    color: var(--text-primary);
}

.btn-link {
    color: var(--rs-color-primary);
}

.btn-link:focus {
    color: var(--rs-color-primary-strong);
    text-decoration: none;
}

/* Login/Auth pages dark mode */
[data-bs-theme="dark"] .bg-light {
    background-color: var(--bg-card) !important;
}

/*
 * Remap Bootstrap .text-dark on dark UI surfaces — but not on bright warning/yellow,
 * where we need real dark ink (badge.bg-warning.text-dark; stat cards).
 */
[data-bs-theme="dark"] .text-dark:not(.bg-warning) {
    color: var(--text-primary) !important;
}

[data-bs-theme="dark"] .bg-warning .text-dark {
    color: #111827 !important;
}

/* List group light theme */
[data-bs-theme="light"] .list-group-item {
    background-color: transparent;
    border-color: var(--border-subtle);
    color: var(--text-primary);
    border-radius: var(--rs-radius-sm);
    transition:
        background-color var(--rs-transition),
        border-color var(--rs-transition);
}

[data-bs-theme="light"] .list-group-item:focus {
    background-color: var(--rs-layer-muted-soft);
    border-color: rgba(220, 53, 69, 0.25);
}

/* List group dark mode */
[data-bs-theme="dark"] .list-group-item {
    background-color: transparent;
    border-color: var(--border-subtle);
    color: var(--text-primary);
    border-radius: var(--rs-radius-sm);
    transition:
        background-color var(--rs-transition),
        border-color var(--rs-transition);
}

[data-bs-theme="dark"] .list-group-item:focus {
    background-color: rgba(30, 36, 48, 0.7);
    border-color: rgba(220, 53, 69, 0.2);
}

/* Nav link icons */
.nav-link i {
    margin-right: 0.5rem;
}

/* Sidebar theming */
.rea-offcanvas {
    background: var(--rs-color-danger, #b91c1c);
    border-right: 1px solid rgba(0, 0, 0, 0.1);
}

.rea-offcanvas .offcanvas-body {
    background: transparent;
}

/* Auth pages styling */
.container.mt-5 .card.shadow {
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.1) !important;
}

[data-bs-theme="dark"] .container.mt-5 .card.shadow {
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.4) !important;
}

/* HR improvements */
hr {
    border-color: var(--border-subtle);
    opacity: 0.4;
}

/* Link colors in dark mode */
[data-bs-theme="dark"] a {
    color: var(--rs-color-primary);
}

[data-bs-theme="dark"] a:focus {
    color: var(--rs-color-primary-strong);
}

/* Button text treatments */
.btn a,
.btn a:focus {
    color: inherit !important;
    text-decoration: none;
}

a.btn {
    text-decoration: none !important;
}

/* Checkbox and form-check light theme */
[data-bs-theme="light"] .form-check-input {
    background-color: var(--bg-surface);
    border-color: var(--border-subtle);
    border-radius: 6px;
}

[data-bs-theme="light"] .form-check-input:checked {
    background-color: var(--rs-color-primary);
    border-color: var(--rs-color-primary);
    box-shadow: 0 0 0 3px var(--rs-focus-ring);
}

/* Checkbox and form-check dark mode */
[data-bs-theme="dark"] .form-check-input {
    background-color: var(--bg-surface);
    border-color: var(--border-subtle);
    border-radius: 6px;
}

[data-bs-theme="dark"] .form-check-input:checked {
    background-color: var(--rs-color-primary);
    border-color: var(--rs-color-primary);
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.18);
}

/* Disabled button state */
.btn:disabled,
.btn.disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Badge dark mode: keep dark label on warning/yellow for contrast */
[data-bs-theme="dark"] .badge.bg-warning {
    color: #111827 !important;
}

/* Improve card footer */
.card-footer.bg-transparent {
    background-color: transparent !important;
    border-top-color: var(--border-subtle);
}

/* Organization show page improvements */
/* Оставяме Bootstrap danger за картите, без да го пренастройваме към rs-color-danger */
