/**
 * Спільні UI-компоненти дашбордів KuBeyond:
 * - dashboard-counter-badge — числові лічильники в меню
 * - status-badge — статусні бейджі (запити, заявки тощо)
 * - dashboard-entity-card — мобільна ієрархія карток сутностей
 */

/* ========== Лічильники меню ========== */
.dashboard-counter-badge,
.sidebar-menu .badge,
.sidebar-menu-trail .badge,
.mobile-dashboard-nav .mob-nav-badge,
.mobile-dashboard-nav .dashboard-counter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 1.35rem;
    min-height: 1.2rem;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    background: #c0392b;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: 0.01em;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}

.sidebar-menu-trail .dashboard-counter-badge,
.sidebar-menu-trail .badge {
    margin-left: 0;
    flex-shrink: 0;
}

.mobile-dashboard-nav .mob-nav-item {
    position: relative;
}

.mobile-dashboard-nav .mob-nav-badge,
.mobile-dashboard-nav .dashboard-counter-badge {
    position: absolute;
    top: 4px;
    right: 6px;
    margin: 0;
    min-width: 1.15rem;
    min-height: 1.05rem;
    padding: 0.1rem 0.35rem;
    font-size: 0.65rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

body.light-theme .dashboard-counter-badge,
body.light-theme .sidebar-menu .badge,
body.light-theme .sidebar-menu-trail .badge,
body.light-theme .mobile-dashboard-nav .mob-nav-badge,
body.light-theme .mobile-dashboard-nav .dashboard-counter-badge {
    background: #c0392b;
    color: #fff;
}

/* ========== Статусні бейджі ========== */
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    box-sizing: border-box;
    max-width: 100%;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.25;
    padding: 0.28rem 0.65rem;
    border-radius: 999px;
    text-align: center;
    white-space: normal;
}

.status-badge::before {
    content: '';
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    flex-shrink: 0;
    background: currentColor;
}

.status-badge.is-new,
.status-badge.status-badge--new {
    color: #fde68a;
    background: rgba(245, 158, 11, 0.18);
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.status-badge.is-accepted,
.status-badge.status-badge--accepted {
    color: #86efac;
    background: rgba(46, 204, 113, 0.15);
    border: 1px solid rgba(46, 204, 113, 0.35);
}

.status-badge.is-rejected,
.status-badge.status-badge--rejected {
    color: #94a3b8;
    background: rgba(148, 163, 184, 0.12);
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.status-badge.is-pending,
.status-badge.status-badge--pending {
    color: #93c5fd;
    background: rgba(52, 152, 219, 0.16);
    border: 1px solid rgba(52, 152, 219, 0.35);
}

body.light-theme .status-badge.is-new,
body.light-theme .status-badge.status-badge--new {
    color: #b45309;
    background: rgba(245, 158, 11, 0.14);
    border-color: rgba(245, 158, 11, 0.4);
}

body.light-theme .status-badge.is-accepted,
body.light-theme .status-badge.status-badge--accepted {
    color: #15803d;
    background: rgba(46, 204, 113, 0.12);
    border-color: rgba(34, 197, 94, 0.4);
}

body.light-theme .status-badge.is-rejected,
body.light-theme .status-badge.status-badge--rejected {
    color: #64748b;
    background: rgba(148, 163, 184, 0.14);
    border-color: rgba(148, 163, 184, 0.35);
}

body.light-theme .status-badge.is-pending,
body.light-theme .status-badge.status-badge--pending {
    color: #1d4ed8;
    background: rgba(37, 99, 235, 0.1);
    border-color: rgba(37, 99, 235, 0.3);
}

/* ========== Мобільна композиція карток сутностей ========== */
@media (max-width: 768px) {
    .dashboard-entity-card .cr-item,
    .company-request-card .cr-item {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px 12px 12px 14px;
    }

    .dashboard-entity-card .cr-title-line,
    .company-request-card .cr-title-line {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .dashboard-entity-card .cr-company-icon,
    .company-request-card .cr-company-icon {
        display: none;
    }

    .dashboard-entity-card .cr-company-link,
    .dashboard-entity-card .cr-company-plain,
    .company-request-card .cr-company-link,
    .company-request-card .cr-company-plain {
        order: -2;
        width: 100%;
        flex: none;
        font-size: 1.05rem;
        font-weight: 700;
        line-height: 1.3;
        text-decoration: none;
    }

    .dashboard-entity-card .cr-company-link,
    .company-request-card .cr-company-link {
        text-decoration: none;
        text-underline-offset: 0;
    }

    .dashboard-entity-card .cr-date,
    .company-request-card .cr-date {
        order: -1;
        margin: 0;
        font-size: 0.78rem;
        font-weight: 500;
        opacity: 0.85;
        line-height: 1.3;
    }

    .dashboard-entity-card .cr-vacancy,
    .dashboard-entity-card .cr-message,
    .company-request-card .cr-vacancy,
    .company-request-card .cr-message {
        padding-left: 0;
        margin-top: 2px;
    }

    .dashboard-entity-card .cr-right,
    .company-request-card .cr-right {
        max-width: none;
        width: 100%;
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
        padding-top: 0;
        border-top: none;
    }

    .dashboard-entity-card .status-badge,
    .dashboard-entity-card .cr-status,
    .company-request-card .status-badge,
    .company-request-card .cr-status {
        align-self: flex-start;
    }

    .dashboard-entity-card .cr-actions,
    .company-request-card .cr-actions {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: stretch;
        justify-content: stretch;
        gap: 8px;
        width: 100%;
    }

    .dashboard-entity-card .cr-btn,
    .company-request-card .cr-btn {
        white-space: normal;
        text-align: center;
        justify-content: center;
        min-height: 36px;
    }

    /* Основна дія */
    #company-requests-section .cr-btn.cr-goto-chat,
    .dashboard-entity-card .cr-btn.cr-goto-chat,
    .company-request-card .cr-btn.cr-goto-chat {
        order: 1;
        flex: 1 1 100%;
        width: 100%;
        padding: 10px 14px;
        font-size: 0.9rem;
        font-weight: 700;
        background: #2980b9;
        color: #fff;
        border-color: #2471a3;
        margin-bottom: 2px;
        padding-bottom: 10px;
        box-shadow: none;
    }

    #company-requests-section .cr-btn.cr-goto-chat:hover,
    .dashboard-entity-card .cr-btn.cr-goto-chat:hover,
    .company-request-card .cr-btn.cr-goto-chat:hover {
        background: #1f6f9f;
        border-color: #1a5276;
    }

    /* Роздільник між primary і secondary (лише flex; у grid ламає ряд кнопок) */
    .dashboard-entity-card .cr-actions:not([style*="grid"]):has(.cr-goto-chat)::before,
    .company-request-card .cr-actions:not([style*="grid"]):has(.cr-goto-chat)::before {
        content: '';
        order: 2;
        flex: 1 1 100%;
        height: 0;
        margin: 2px 0 2px;
        border-top: 1px solid rgba(148, 163, 184, 0.28);
    }
    #company-requests-section .cr-actions::before,
    #company-requests-section .cr-actions:has(.cr-goto-chat)::before {
        content: none !important;
        display: none !important;
    }

    /* Другорядні дії */
    #company-requests-section .cr-btn.cr-archive,
    #company-requests-section .cr-btn.cr-unarchive,
    #company-requests-section .cr-btn.cr-remove,
    #company-requests-section .cr-btn.cr-reject,
    .dashboard-entity-card .cr-btn.cr-archive,
    .dashboard-entity-card .cr-btn.cr-unarchive,
    .dashboard-entity-card .cr-btn.cr-remove,
    .dashboard-entity-card .cr-btn.cr-reject,
    .company-request-card .cr-btn.cr-archive,
    .company-request-card .cr-btn.cr-unarchive,
    .company-request-card .cr-btn.cr-remove,
    .company-request-card .cr-btn.cr-reject {
        order: 3;
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
        padding: 7px 10px;
        font-size: 0.8rem;
        font-weight: 600;
        background: transparent;
        box-shadow: none;
    }

    #company-requests-section .cr-btn.cr-archive,
    #company-requests-section .cr-btn.cr-unarchive,
    .dashboard-entity-card .cr-btn.cr-archive,
    .dashboard-entity-card .cr-btn.cr-unarchive,
    .company-request-card .cr-btn.cr-archive,
    .company-request-card .cr-btn.cr-unarchive {
        color: #94a3b8;
        border-color: rgba(148, 163, 184, 0.4);
    }

    #company-requests-section .cr-btn.cr-remove,
    #company-requests-section .cr-btn.cr-reject,
    .dashboard-entity-card .cr-btn.cr-remove,
    .dashboard-entity-card .cr-btn.cr-reject,
    .company-request-card .cr-btn.cr-remove,
    .company-request-card .cr-btn.cr-reject {
        color: #f87171;
        border-color: rgba(248, 113, 113, 0.45);
        background: transparent;
    }

    body.light-theme #company-requests-section .cr-btn.cr-goto-chat,
    body.light-theme .dashboard-entity-card .cr-btn.cr-goto-chat,
    body.light-theme .company-request-card .cr-btn.cr-goto-chat {
        background: #2563eb;
        border-color: #1d4ed8;
        color: #fff;
    }

    body.light-theme #company-requests-section .cr-actions:has(.cr-goto-chat)::before,
    body.light-theme .dashboard-entity-card .cr-actions:has(.cr-goto-chat)::before,
    body.light-theme .company-request-card .cr-actions:has(.cr-goto-chat)::before {
        border-top-color: rgba(100, 116, 139, 0.28);
    }

    body.light-theme #company-requests-section .cr-btn.cr-archive,
    body.light-theme #company-requests-section .cr-btn.cr-unarchive,
    body.light-theme .dashboard-entity-card .cr-btn.cr-archive,
    body.light-theme .dashboard-entity-card .cr-btn.cr-unarchive,
    body.light-theme .company-request-card .cr-btn.cr-archive,
    body.light-theme .company-request-card .cr-btn.cr-unarchive {
        color: #64748b;
        border-color: rgba(100, 116, 139, 0.4);
        background: transparent;
    }

    #company-requests-section .cr-item {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    #company-requests-section .cr-title-line {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    #company-requests-section .cr-company-icon {
        display: none;
    }

    #company-requests-section .cr-company-link,
    #company-requests-section .cr-company-plain {
        order: -2;
        width: 100%;
        flex: none;
        font-size: 1.05rem;
        font-weight: 700;
        text-decoration: none;
    }

    #company-requests-section .cr-date {
        order: -1;
        font-size: 0.78rem;
        opacity: 0.85;
    }

    #company-requests-section .cr-right {
        max-width: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding-top: 0;
        border-top: none;
    }

    #company-requests-section .cr-actions {
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
        gap: 8px;
    }
}

@media (max-width: 380px) {
    .dashboard-entity-card .cr-btn.cr-archive,
    .dashboard-entity-card .cr-btn.cr-unarchive,
    .dashboard-entity-card .cr-btn.cr-remove,
    .dashboard-entity-card .cr-btn.cr-reject,
    .company-request-card .cr-btn.cr-archive,
    .company-request-card .cr-btn.cr-unarchive,
    .company-request-card .cr-btn.cr-remove,
    .company-request-card .cr-btn.cr-reject {
        flex: 1 1 100%;
    }
}
