/* MovenSoft CRM — визуална тема (светла + тъмна) */

:root {
    --brand-dark: #151a2d;
    --brand-mid: #1f2a4d;
    --brand-accent: #4f7cff;
    --sidebar-w: 240px;
    --topbar-h: 60px;
    --radius: .75rem;
    --surface: #ffffff;
    --surface-2: #f5f7fb;
    --app-bg: #f0f2f7;
    --line: #e7eaf1;
    --muted: #7a8195;
    --row-hover: #f5f8ff;
    --shadow: 0 1px 2px rgba(21, 26, 45, .04), 0 2px 8px rgba(21, 26, 45, .05);
    --shadow-lg: 0 .5rem 1.5rem rgba(21, 26, 45, .12);
}

[data-bs-theme="dark"] {
    --surface: #1b2133;
    --surface-2: #222a40;
    --app-bg: #121624;
    --line: #2a3350;
    --muted: #8f97ad;
    --row-hover: #232c45;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 .5rem 1.5rem rgba(0, 0, 0, .45);
    --bs-body-bg: #121624;
    --bs-body-color: #dfe3ee;
    --bs-border-color: #2a3350;
    --bs-secondary-color: #8f97ad;
    --bs-tertiary-bg: #222a40;
}

:root, body {
    --bs-body-font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --bs-body-font-size: .9rem;
}

body {
    font-family: var(--bs-body-font-family);
    background: var(--app-bg);
    -webkit-font-smoothing: antialiased;
}

.tooltip, .popover, .btn, .form-control, .form-select, .dropdown-menu, .badge {
    font-family: var(--bs-body-font-family);
}

h1, h2, h3, h4, h5 { font-weight: 600; letter-spacing: -.01em; }
h3 { font-size: 1.4rem; }

/* --- Обвивка: странично меню + съдържание --- */

.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--brand-dark) 0%, var(--brand-mid) 100%);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .2s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    height: var(--topbar-h);
    padding: 0 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.brand-logo {
    height: 32px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .4));
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: .75rem .75rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .55rem .75rem;
    margin-bottom: 2px;
    border-radius: .5rem;
    color: rgba(255, 255, 255, .68);
    text-decoration: none;
    font-size: .875rem;
    transition: background-color .15s ease, color .15s ease;
}

.sidebar-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.sidebar-link span:first-of-type { flex: 1; }
.sidebar-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }

.sidebar-link.active {
    background: rgba(79, 124, 255, .22);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--brand-accent);
}

.sidebar-count {
    font-size: .7rem;
    font-weight: 600;
    min-width: 1.5rem;
    text-align: center;
    padding: .1rem .4rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, .12);
    color: #fff;
}

.sidebar-count.is-alert { background: #e5484d; }

.sidebar-section {
    margin: 1rem .75rem .4rem;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255, 255, 255, .38);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .9rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, .06);
}

.sidebar-logout { color: rgba(255, 255, 255, .55); text-decoration: none; }
.sidebar-logout:hover { color: #fff; }

.app-main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1.5rem;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}

.app-content { padding: 1.5rem; flex: 1; }

.topbar-search {
    position: relative;
    flex: 0 1 440px;
}

.topbar-search > .bi-search {
    position: absolute;
    left: .8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}

.topbar-search .form-control {
    padding-left: 2.2rem;
    padding-right: 2.2rem;
    background: var(--surface-2);
    border-color: transparent;
}

.topbar-search kbd {
    position: absolute;
    right: .6rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: .7rem;
    background: var(--line);
    color: var(--muted);
}

.topbar-timer {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .25rem .4rem .25rem .75rem;
    border-radius: 2rem;
    background: rgba(255, 193, 7, .15);
    font-size: .85rem;
}

.topbar-timer a { color: inherit; text-decoration: none; }

.pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f59f00;
    animation: pulse 1.4s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(245, 159, 0, .6); }
    70% { box-shadow: 0 0 0 8px rgba(245, 159, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 159, 0, 0); }
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: .5rem;
    color: var(--muted);
    position: relative;
}

.btn-icon:hover { background: var(--surface-2); color: var(--bs-body-color); }

.theme-icon-dark { display: none; }
[data-bs-theme="dark"] .theme-icon-dark { display: inline; }
[data-bs-theme="dark"] .theme-icon-light { display: none; }

.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-main { margin-left: 0; }
    .sidebar-open .app-sidebar { transform: none; }
    .sidebar-open .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .4);
        z-index: 1035;
    }
    .app-topbar { padding: 0 1rem; }
    .app-content { padding: 1rem; }
}

/* --- Аватари --- */

.avatar {
    --av: var(--brand-accent);
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .72rem;
    font-weight: 600;
    color: #fff;
    background: var(--av);
}

.avatar-sm { width: 26px; height: 26px; flex-basis: 26px; font-size: .65rem; }

/* --- Карти --- */

.card {
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow) !important;
    transition: box-shadow .15s ease, transform .15s ease;
}

.card .card-header {
    border-radius: var(--radius) var(--radius) 0 0 !important;
    border-bottom: 1px solid var(--line);
    padding: .85rem 1.1rem;
}

a + .card:hover,
a > .card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg) !important;
}

.stat-card .stat-icon {
    width: 46px;
    height: 46px;
    border-radius: .75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

.stat-card .stat-value { font-size: 1.6rem; font-weight: 600; line-height: 1.1; }

/* --- Вход --- */

.login-card {
    border-radius: 1rem;
    overflow: hidden;
}

.login-logo {
    background: linear-gradient(135deg, var(--brand-dark), var(--brand-mid));
}

/* --- Таблици --- */

.table {
    --bs-table-bg: transparent;
    margin-bottom: 0;
}

.table > :not(caption) > * > * { padding: .7rem .75rem; border-bottom-color: var(--line); }
.table-sm > :not(caption) > * > * { padding: .45rem .5rem; }

.table thead th {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    font-weight: 600;
    border-bottom-width: 1px;
    background: var(--surface-2);
    white-space: nowrap;
}

.table-hover > tbody > tr:hover > * {
    --bs-table-hover-bg: var(--row-hover);
    background-color: var(--row-hover);
}

.table a:not(.btn) { color: inherit; text-decoration: none; font-weight: 500; }
.table a:not(.btn):hover { color: var(--brand-accent); }
.table a.text-secondary { font-weight: 400; }

/* Цветна лента за приоритет в началото на реда */
tr.prio-urgent > td:first-child { box-shadow: inset 3px 0 0 #e5484d; }
tr.prio-high > td:first-child { box-shadow: inset 3px 0 0 #f59f00; }
tr.prio-medium > td:first-child { box-shadow: inset 3px 0 0 #4f7cff; }
tr.prio-low > td:first-child { box-shadow: inset 3px 0 0 #adb5bd; }

tr.is-done td { color: var(--muted); }
tr.is-done .task-title { text-decoration: line-through; }

/* Промяна на място (inline) */
.inline-select {
    border: 0;
    background-color: transparent;
    padding: .15rem 1.6rem .15rem .4rem;
    font-size: .8rem;
    border-radius: .4rem;
    cursor: pointer;
    background-position: right .3rem center;
    width: auto;
    max-width: 160px;
}

.inline-select:hover, .inline-select:focus { background-color: var(--surface-2); }

.inline-date {
    border: 0;
    background: transparent;
    font-size: .8rem;
    padding: .15rem .3rem;
    border-radius: .4rem;
    width: 130px;
    color: inherit;
}

.inline-date:hover, .inline-date:focus { background: var(--surface-2); outline: none; }
.inline-date.is-overdue { color: #e5484d; font-weight: 600; }
/* Празна дата: скрива „mm/dd/yyyy“, докато не се посочи/фокусира */
.inline-date.is-empty:not(:hover):not(:focus) { color: transparent; }
.inline-date.is-empty:not(:hover):not(:focus)::-webkit-calendar-picker-indicator { opacity: .25; }

.status-select[data-v="todo"] { color: #6c757d; }
.status-select[data-v="in_progress"] { color: #0aa2c0; font-weight: 600; }
.status-select[data-v="review"] { color: #d39e00; font-weight: 600; }
.status-select[data-v="done"] { color: #198754; font-weight: 600; }

.quick-add {
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    padding: .6rem .75rem;
}

.quick-add .form-control, .quick-add .form-select { background-color: var(--surface); }

/* --- Значки и прогрес --- */

.badge {
    font-weight: 500;
    letter-spacing: .01em;
    padding: .38em .65em;
    border-radius: .4rem;
}

.progress {
    height: .5rem;
    border-radius: 1rem;
    background: var(--line);
}

.progress-bar { border-radius: 1rem; }

/* --- Kanban --- */

.kanban-board {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    align-items: flex-start;
    padding-bottom: 1rem;
}

.kanban-col {
    flex: 0 0 290px;
    background: var(--surface-2);
    border-radius: var(--radius);
    padding: .6rem;
    min-height: 200px;
}

.kanban-col.drag-over {
    outline: 2px dashed var(--brand-accent);
    outline-offset: -2px;
    background: color-mix(in srgb, var(--brand-accent) 12%, var(--surface-2));
}

.kanban-card {
    cursor: grab;
    border: 0;
    border-left: 3px solid transparent;
    border-radius: .55rem;
}

.kanban-card:has(.text-bg-danger) { border-left-color: #dc3545; }
.kanban-card:has(.text-bg-warning) { border-left-color: #ffc107; }
.kanban-card:has(.text-bg-primary) { border-left-color: #0d6efd; }
.kanban-card:has(.text-bg-secondary) { border-left-color: #adb5bd; }

.kanban-card.dragging {
    opacity: .5;
    transform: rotate(2deg);
}

/* --- Бутони и форми --- */

.btn { border-radius: .5rem; font-weight: 500; }

.btn-primary {
    --bs-btn-bg: var(--brand-accent);
    --bs-btn-border-color: var(--brand-accent);
    --bs-btn-hover-bg: #3d68e6;
    --bs-btn-hover-border-color: #3d68e6;
    --bs-btn-active-bg: #335bd1;
}

.form-control, .form-select { border-radius: .5rem; }

.form-control:focus, .form-select:focus {
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 .2rem rgba(79, 124, 255, .15);
}

td .btn-group .btn,
.table .btn-sm {
    --bs-btn-padding-y: .1rem;
    --bs-btn-padding-x: .4rem;
}

/* Бързо приключване на задача от списъка */
.quick-done { color: var(--muted); }
.quick-done:hover { color: var(--bs-success) !important; }
.quick-done:hover .bi-circle::before { content: "\f26b"; } /* bi-check-circle */

/* --- Toast известия --- */

.toast-container { z-index: 1090; }
.app-toast { box-shadow: var(--shadow-lg); border-radius: .6rem; }

/* --- Търсене --- */

.search-hit mark { padding: 0 .1em; background: rgba(255, 193, 7, .35); color: inherit; border-radius: .2em; }

/* --- Активност --- */

.activity-item {
    display: flex;
    gap: .75rem;
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--line);
}

.activity-item:last-child { border-bottom: 0; }

/* --- Тъмна тема: съвместимост със старите класове по страниците --- */

[data-bs-theme="dark"] .bg-white,
[data-bs-theme="dark"] .bg-light { background-color: var(--surface) !important; }
[data-bs-theme="dark"] .text-dark { color: var(--bs-body-color) !important; }
[data-bs-theme="dark"] .text-bg-light { background-color: var(--surface-2) !important; color: var(--bs-body-color) !important; }
[data-bs-theme="dark"] .list-group { --bs-list-group-bg: var(--surface); --bs-list-group-border-color: var(--line); }
[data-bs-theme="dark"] .modal-content { background: var(--surface); }
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select { background-color: var(--surface-2); border-color: var(--line); }
[data-bs-theme="dark"] .alert-light { background: var(--surface-2); color: var(--bs-body-color); }

/* --- Дребни детайли --- */

.breadcrumb { font-size: .82rem; }
.breadcrumb a { text-decoration: none; }

::-webkit-scrollbar { height: 8px; width: 10px; }
::-webkit-scrollbar-thumb { background: #c3c9d6; border-radius: 8px; }
[data-bs-theme="dark"] ::-webkit-scrollbar-thumb { background: #3a4462; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 576px) {
    .kanban-col { flex-basis: 250px; }
}

@media print {
    .app-sidebar, .app-topbar, .no-print, .toast-container { display: none !important; }
    .app-main { margin-left: 0; }
    .app-content { padding: 0; }
    body { background: #fff; }
    .card { box-shadow: none !important; border: 0 !important; }
}
.min-w-0 { min-width: 0; }

/* --- Известия (камбанка) --- */

.bell-dot {
    position: absolute;
    top: 2px;
    right: 0;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 9px;
    background: #e5484d;
    color: #fff;
    font-size: .62rem;
    font-weight: 600;
    line-height: 17px;
    text-align: center;
}

.notif-menu { width: 360px; max-width: 92vw; border: 0; border-radius: var(--radius); overflow: hidden; }
.notif-item { display: flex; gap: .6rem; align-items: flex-start; white-space: normal; padding: .6rem 1rem; font-size: .85rem; }
.notif-item > i { font-size: .55rem; margin-top: .45rem; color: var(--muted); }
.notif-item.is-unread { background: color-mix(in srgb, var(--brand-accent) 7%, transparent); font-weight: 500; }

/* --- Табло --- */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; }

.layout-list .layout-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem .75rem;
    border: 1px solid var(--line);
    border-radius: .6rem;
    margin-bottom: .5rem;
    background: var(--surface);
    cursor: grab;
}

.layout-item.dragging { opacity: .5; }
.layout-item.is-hidden .layout-label { color: var(--muted); text-decoration: line-through; }
.layout-item .bi-grip-vertical { color: var(--muted); }
