/* ===== Inbox page (messaging/inbox) ===== */
.inbox-page {
    margin-top: 20px;
    color: #000;
    font-size: 0.95rem;
}

/* Списък разговори */
.inbox-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

/* Всеки ред (разговор) */
.inbox-item {
    background: #fff;
    border: 1px solid var(--border, #ddd);
    border-radius: var(--radius, 8px);
    box-shadow: var(--shadow, 0 2px 4px rgba(0, 0, 0, .08));
    overflow: hidden;
    position: relative;
    transition: background-color .15s ease;
}

.inbox-item:hover {
    background: hsl(var(--p-h) var(--p-s) 97%);
}

/* Линкът за целия ред */
.inbox-link {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    text-decoration: none;
    color: inherit;
    padding: 10px 14px;
    position: relative;
}

/* Аватар */
.inbox-avatar {
    flex: 0 0 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--primary-soft, #eee);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #000;
    font-size: 1rem;
}

.inbox-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.inbox-avatar .initial {
    font-size: 1.1rem;
}

/* Основната част */
.inbox-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.inbox-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.inbox-row .user {
    font-weight: 600;
    color: #000;
}

.inbox-row .ts {
    color: #000;
    font-size: 0.8rem;
}

.inbox-preview {
    color: #000;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Бейдж за непрочетени */
.badge-unread {
    position: absolute;
    right: 10px;
    top: 10px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 50%;
    background: var(--primary, #007bff);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 20px;
    text-align: center;
}


/* ===== Messaging Layout & Sidebar ===== */
.messaging-container {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    margin-top: 20px;
}

.messaging-sidebar {
    flex: 0 0 220px; /* Фиксирана ширина от 220px */
}

/* Compose button: стабилни размери дори под 600px */
.compose-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1;
    padding: 8px 12px;
    margin-bottom: 6px;
    box-sizing: border-box;
    color: white !important;
}

/* ≥961px – разтягане вляво (ширината на колоната) */
@media (min-width: 961px) {
    .compose-btn {
        width: 100%;
    }
}

/* ≤960px – компактно по съдържание */
@media (max-width: 960px) {
    .compose-btn {
        max-width: 100%;
    }
}

/* ⬇️ Критично: неутрализира глобалния .btn при ≤600px само за compose бутона */
@media (max-width: 600px) {
    .btn.compose-btn {
        padding: 8px 12px !important; /* твоята желана стойност */
        font-size: 1rem !important; /* или: inherit */
    }
}


.messaging-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.messaging-nav .nav-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    text-decoration: none;
    color: #000;
    border-radius: var(--radius-sm, 6px);
    transition: background-color .15s ease;
}

.messaging-nav .nav-item:hover {
    background-color: #f0f0f0;
}

.messaging-nav .nav-item.active {
    background-color: var(--primary-soft, #e0efff);
    font-weight: 600;
    color: #000;
}

.messaging-nav .badge {
    font-size: 0.8em;
    padding: 2px 6px;
    border-radius: 10px;
    background-color: var(--primary, #007bff);
    color: #fff;
}

.messaging-nav .nav-item.active .badge {
    background-color: #fff;
    color: var(--primary, #007bff);
    border: 1px solid var(--primary, #007bff);
}

.messaging-main {
    flex: 1; /* Заема останалото пространство */
    min-width: 0; /* Важно за flex елементи */
}

/* ===== Специфични стилове ===== */

/* Тема в списъка с разговори */
.inbox-subject {
    font-weight: 600;
    color: #000;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

/* Бутон за изтриване (Х) */
.delete-form {
    position: absolute;
    /* Центриране по вертикала */
    top: 50%;
    transform: translateY(-50%);
    right: 15px;
}

.delete-form button {
    background-color: #e53e3e; /* Червен фон */
    color: #fff; /* Бял Х */
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.15s ease;
}

.delete-form button:hover {
    filter: brightness(0.85); /* Потъмняване при ховър */
}

/* Форма за ново съобщение */
.compose-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.compose-form p {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin: 0;
}

.compose-form label {
    font-weight: 600;
}

.compose-form input,
.compose-form textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border, #ccc);
    border-radius: var(--radius-sm, 6px);
    font: inherit;
}

.compose-form button {
    align-self: flex-start; /* Бутонът да не се разпъва */
}

.mb-3 {
    color: black;
}


/* =================================== */
/* ===== Стил за Messaging Card ===== */
/* =================================== */

.messaging-card {
    /* Използваме бял фон за ясен контраст, подобно на .inbox-item */
    background: #fff;

    /* Използваме съществуващите променливи от темата ти */
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);

    /* Добавяме вътрешно отстояние, за да не е залепено съдържанието */
    padding: 24px;
}

/* Малка корекция за мобилни устройства, за да не е толкова голямо отстоянието */
@media (max-width: 640px) {
    .messaging-card {
        padding: 16px;
    }
}

/* Форма за ново съобщение */
.compose-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    color: #000; /* Основният текст в цялата форма става черен */
}

.compose-form p {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin: 0;
}

.compose-form label {
    font-weight: 600;
    color: #000; /* Уверяваме се, че етикетите (До, Тема, и т.н.) са черни */
}

.compose-form input,
.compose-form textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border, #ccc);
    border-radius: var(--radius-sm, 6px);
    font: inherit;
    color: #000; /* Текстът, който въвеждаш в полетата, също да е черен */
    background: #fff; /* Гарантираме бял фон на полетата за максимален контраст */
}

.compose-form button {
    align-self: flex-start; /* Бутонът да не се разпъва */
}

/* Стилове за бутоните в кошчето */
.trash-actions {
    position: absolute;
    top: 50%;
    right: 15px;
    transform: translateY(-50%);
    display: flex;
    gap: 8px;
}

.trash-actions button {
    border: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm, 6px);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: filter .15s ease;
}

.trash-actions .btn-restore {
    background-color: #28a745; /* Зелено */
    color: #fff;
}

.trash-actions .btn-perm-delete {
    background-color: #dc3545; /* Червено */
    color: #fff;
}

.trash-actions button:hover {
    filter: brightness(0.9);
}

/* Панел за групови действия */
.bulk-actions {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border, #eee);
    display: flex;
    gap: 10px;
}

.btn-bulk {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: #fff;
    color: #000;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
}

.btn-bulk.btn-danger {
    border-color: #e53e3e;
    background: #e53e3e;
    color: #fff;
}

/* Подравняване на елементите с чекбокс */
.inbox-item.with-checkbox {
    display: flex;
    align-items: center;
    padding-left: 15px;
}

.inbox-item .inbox-link {
    flex-grow: 1; /* Линкът да заема останалото място */
}

/* Стилизиране на чекбокс */
.checkbox-label {
    display: block;
    position: relative;
    cursor: pointer;
    user-select: none;
    padding-right: 15px;
}

.conv-checkbox {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

/* ===== По-четлив custom checkbox (инбокс) — FIX: видима и центрирана чавка ===== */

/* Контейнерът да е кликаем и да държи слота за чекбокса */
.checkbox-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px; /* фиксирана колона в списъка */
    height: 28px;
    cursor: pointer;
}

/* Скриваме нативния чекбокс, но остава достъпен за клавиатура/скрийнрийдър */
.conv-checkbox {
    position: absolute;
    opacity: 0;
    inline-size: 0;
    block-size: 0;
    pointer-events: none;
}

/* Визуален чекбокс */
.checkbox-custom {
    /* гъвкав размер + дебелина на рамката/чавката */
    --cb-size: clamp(16px, 1.1em, 30px);
    --cb-border: 2px;
    --cb-tick: max(2px, calc(var(--cb-size) * .14));

    position: relative;
    display: inline-block;
    width: var(--cb-size);
    height: var(--cb-size);
    aspect-ratio: 1 / 1;
    box-sizing: border-box;

    background: #fff;
    border: var(--cb-border) solid var(--border, #ccc);
    border-radius: 4px; /* леко заобляне */
    /*overflow: hidden;   !* нищо да не „стърчи“ *!*/

    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

/* Hover / focus ring */
.checkbox-label:hover .checkbox-custom {
    border-color: color-mix(in oklab, var(--primary, #007bff) 45%, #ccc);
}

.conv-checkbox:focus-visible ~ .checkbox-custom {
    border-color: var(--primary, #007bff);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary, #007bff) 25%, transparent);
}

/* Checked → фон в основния цвят */
.conv-checkbox:checked ~ .checkbox-custom {
    background-color: var(--primary, #007bff);
    border-color: var(--primary, #007bff);
}

/* Чавката — огледален вариант, без scaleX */
.checkbox-custom::after {
    content: "";
    position: absolute;

    /* размер спрямо кутията */
    width: 52%;
    height: 30%;

    /* центриране + леко изместване за оптичен баланс */
    left: 50%;
    top: 50%;
    transform: translate(-50%, -55%) rotate(310deg);

    /* рисуваме тик с ЛЯВО + ДОЛУ (огледално на right+bottom) */
    border: solid #fff;
    border-width: 0 0 var(--cb-tick, 2px) var(--cb-tick, 2px);

    opacity: 0;
    transition: opacity .12s ease;
}

.conv-checkbox:checked ~ .checkbox-custom::after {
    opacity: 1;
}


/* Hi-contrast: по-дебела рамка/чавка */
@media (prefers-contrast: more) {
    .checkbox-custom {
        --cb-border: 2.5px;
        --cb-tick: max(3px, calc(var(--cb-size) * .16));
    }
}

/* Много малки екрани: леко сваляне на размера, чавката остава пропорционална */
@media (max-width: 420px) {
    .checkbox-custom {
        --cb-size: clamp(15px, 1em, 18px);
        /* --cb-tick остава пропорционална заради calc по-горе */
    }
}


/* Контейнер за търсене */
.search-container {
    margin-bottom: 15px;
}

.search-container form {
    display: flex;
}

.search-container input[type="search"] {
    flex-grow: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    border-right: none;
    color: black;
}

.search-container button {
    padding: 8px 15px;
    border: 1px solid var(--primary);
    background: var(--primary);
    color: white;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    cursor: pointer;
}

/* Messaging → нав меню: стабилни размери и без global overrides */
.messaging-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.messaging-nav .nav-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%; /* на десктоп запълва ширината на сайдбара */
    box-sizing: border-box;
    padding: 8px 12px; /* твоите желани стойности */
    font-size: 1rem;
    text-decoration: none;
    color: #000;
    border-radius: var(--radius-sm, 6px);
    transition: background-color .15s ease;
}

.messaging-nav .nav-item:hover {
    background-color: #f0f0f0;
}

.messaging-nav .nav-item.active {
    background-color: var(--primary-soft, #e0efff);
    font-weight: 600;
    color: #000;
}

/* Текстът да не прелива при дълги думи */
.messaging-nav .nav-item > span {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Баджът да не се свива */
.messaging-nav .badge {
    flex: 0 0 auto;
    font-size: 0.8em;
    padding: 2px 6px;
    border-radius: 10px;
    background-color: var(--primary, #007bff);
    color: #fff;
}

.messaging-nav .nav-item.active .badge {
    background-color: #fff;
    color: var(--primary, #007bff);
    border: 1px solid var(--primary, #007bff);
}

/* Неутрализация на нежелани глобални правила под 600px – само тук */
@media (max-width: 600px) {
    .messaging-nav .nav-item {
        padding: 8px 12px !important;
        font-size: 1rem !important;
        width: 100% !important; /* задържи ги широки и четими */
    }
}
