/*
Theme Name: My UserProfile Theme
Theme URI:  https://example.com/
Author:     HutkoSoft
Author URI: https://hutkosoft.com/
Description: Кабінет замовника для CRM Med3DDruck.
Version:    1.2
License:    GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: my-userprofile
*/

/* === Базові змінні (наближено до стилю med3druk.com) === */
:root {
    --bg: #0b1623;
    --bg-soft: #101b2b;
    --bg-soft-alt: #111d2e;
    --card: #152239;
    --primary: #00a6c7;
    --primary-soft: rgba(0, 166, 199, 0.15);
    --primary-border: rgba(0, 166, 199, 0.4);
    --accent: #3cbaf2;
    --danger: #ff4a6a;
    --muted: #7e8ba5;
    --text: #f5f7ff;
    --text-soft: #c2c9db;
    --border: #1d2840;
    --shadow-soft: 0 18px 40px rgba(0, 0, 0, 0.45);
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-pill: 999px;
}

/* === Базова типографіка === */
body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top left, #12243b 0, #050912 45%, #01030a 100%);
    color: var(--text);
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

.site-header,
.site-footer {
    background: transparent;
    border: none;
}

.site-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* === Загальний layout кабінету === */

.crm-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 24px;
    align-items: flex-start;
}

.crm-main {
    background: var(--bg-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 24px 24px 28px;
    border: 1px solid var(--border);
    min-height: 70vh;
}

/* === Праве меню (sidebar справа) === */

.crm-sidebar {
    background: linear-gradient(160deg, #101b2b 0, #0a111c 45%, #050912 100%);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 20px 18px 22px;
    border: 1px solid var(--border);
    position: sticky;
    top: 24px;
}

.crm-sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.crm-avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 0, #3cbaf2 0, #00a6c7 35%, #004f86 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    font-size: 18px;
}

.crm-sidebar-title {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
}

.crm-sidebar-user {
    font-size: 16px;
    font-weight: 600;
}

.crm-nav {
    list-style: none;
    margin: 10px 0 16px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.crm-nav button {
    width: 100%;
    border-radius: var(--radius-md);
    padding: 9px 12px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.08s ease;
}

.crm-nav button span.label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.crm-nav button span.dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--muted);
    opacity: 0.9;
}

.crm-nav button.is-active {
    background: var(--primary-soft);
    border-color: var(--primary-border);
    color: #f7fbff;
    transform: translateY(-1px);
}

.crm-nav button.is-active span.dot {
    background: var(--accent);
}

.crm-sidebar-footer {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
    font-size: 12px;
    color: var(--muted);
}

/* Кнопка виходу */
.crm-logout-link {
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-soft);
}
.crm-logout-link svg {
    width: 14px;
    height: 14px;
}

/* === Компоненти === */

.crm-page-title {
    font-size: 22px;
    margin: 0 0 8px;
}

.crm-page-subtitle {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 20px;
}

.crm-hero {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: stretch;
    gap: 16px;
    margin-bottom: 18px;
}

.crm-hero-main {
    flex: 1;
}

.crm-hero-notice {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    margin-bottom: 4px;
    border-radius: var(--radius-pill, 8px);
    background: rgba(60, 186, 242, 0.12);
    color: var(--accent, #3cbaf2);
    font-size: 13px;
    flex: 1 1 100%;
    max-width: fit-content;
}

.crm-hero-notice-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent, #3cbaf2);
    animation: crm-hero-notice-pulse 1.5s ease-in-out infinite;
}

@keyframes crm-hero-notice-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.crm-hero-notice-link {
    margin-left: 4px;
    font-weight: 600;
    color: inherit;
    text-decoration: underline;
}

.crm-hero-notice-link:hover {
    opacity: 0.9;
}

.badge-soft {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(60, 186, 242, 0.1);
    color: var(--accent);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.badge-soft-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: #3cbaf2;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: var(--radius-pill);
    padding: 9px 16px;
    border: none;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, #00a6c7, #3cbaf2);
    color: #ffffff;
    box-shadow: 0 10px 25px rgba(0, 166, 199, 0.42);
}
.btn-primary:hover {
    filter: brightness(1.05);
}

.btn-ghost {
    background: rgba(18, 29, 49, 0.8);
    color: var(--text-soft);
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.btn-ghost:hover {
    border-color: rgba(255, 255, 255, 0.18);
}

/* Карточки */
.crm-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.crm-card {
    background: var(--bg-soft-alt);
    border-radius: var(--radius-md);
    padding: 14px 14px 12px;
    border: 1px solid var(--border);
}

.crm-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.crm-card-title {
    font-size: 13px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.crm-card-value {
    font-size: 22px;
    font-weight: 600;
}

.crm-card-tagline {
    font-size: 12px;
    color: var(--muted);
}

/* Таблиця заявок */

.crm-table-wrapper {
    margin-top: 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow: hidden;
    background: var(--bg-soft-alt);
}

.crm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.crm-table thead {
    background: rgba(8, 19, 35, 0.9);
}

.crm-table th,
.crm-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #141d30;
}

.crm-table th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
}

.crm-table tr:hover td {
    background: rgba(60, 186, 242, 0.04);
}

.badge-status {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    border: 1px solid transparent;
}

.badge-status.new { background: rgba(60, 186, 242, 0.18); color: #e9f8ff; border-color: rgba(60, 186, 242, 0.35); }
.badge-status.in_progress { background: rgba(255, 168, 0, 0.18); color: #ffecc2; border-color: rgba(255, 186, 73, 0.4); }
.badge-status.done { background: rgba(86, 209, 141, 0.18); color: #d0ffe1; border-color: rgba(86, 209, 141, 0.4); }

/* Детальна заявка */

.status-timeline {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.status-step {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--muted);
}

.status-step-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    border: 2px solid var(--muted);
    background: transparent;
}

.status-step.is-done .status-step-dot {
    border-color: #56d18d;
    background: #56d18d;
}

.status-step.is-current .status-step-dot {
    border-color: #3cbaf2;
    background: #3cbaf2;
}

.status-step.is-current {
    color: #e9f8ff;
}

/* Чат */

.chat-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 10px;
}

.chat-message {
    max-width: 70%;
    padding: 8px 10px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.4;
}

.chat-message.me {
    margin-left: auto;
    background: var(--primary-soft);
    border: 1px solid var(--primary-border);
}

.chat-message.other {
    margin-right: auto;
    background: #101726;
    border: 1px solid #161f33;
}

.chat-meta {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

/* Форми */

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 16px;
    margin-bottom: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    color: var(--text-soft);
}

.form-group input,
.form-group select,
.form-group textarea {
    border-radius: 10px;
    border: 1px solid #1c273c;
    background: #091222;
    color: var(--text);
    padding: 8px 10px;
    font-size: 14px;
    outline: none;
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
}

/* === Світла тема для форм (щоб поля не були чорні) === */
:root[data-theme="light"] .form-group input,
:root[data-theme="light"] .form-group select,
:root[data-theme="light"] .form-group textarea {
    background: #f9fbff;
    border: 1px solid var(--border);
    color: var(--text);
}

:root[data-theme="light"] .form-group input::placeholder,
:root[data-theme="light"] .form-group textarea::placeholder {
    color: #9aa4b5;
}

/* Повідомлення стану */

.alert {
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 13px;
    margin-bottom: 10px;
}

.alert-success {
    background: rgba(86, 209, 141, 0.12);
    border: 1px solid rgba(86, 209, 141, 0.6);
    color: #d0ffe1;
}

.alert-error {
    background: rgba(255, 74, 106, 0.12);
    border: 1px solid rgba(255, 74, 106, 0.6);
    color: #ffd5df;
}

/* === Секції кабінету === */

.crm-section {
    display: none;
}
.crm-section.is-active {
    display: block;
}

/* Адаптивність */

@media (max-width: 1024px) {
    .crm-layout {
        grid-template-columns: minmax(0, 1fr);
    }
    .crm-sidebar {
        position: static;
        order: -1; /* меню зверху */
    }
}

@media (max-width: 768px) {
    .crm-main {
        padding: 18px 14px 20px;
    }
    .crm-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .crm-hero {
        flex-direction: column;
    }
    .form-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ==========================================================
   🌗 LIGHT THEME (автоматичне перемикання)
   ==========================================================*/

:root[data-theme="light"] {
    --bg: #f4f7fa;
    --bg-soft: #ffffff;
    --bg-soft-alt: #eef2f7;
    --card: #ffffff;

    --primary: #009ec2;
    --primary-soft: rgba(0, 158, 194, 0.15);
    --primary-border: rgba(0, 158, 194, 0.35);

    --accent: #0077b6;

    --danger: #d62839;

    --muted: #566070;
    --text: #0d1b2a;
    --text-soft: #364154;

    --border: #cfd7e3;

    --shadow-soft: 0 8px 20px rgba(0, 0, 0, 0.12);

    background: linear-gradient(180deg, #e7edf3 0%, #f9fbfd 60%, #ffffff 100%);
}

:root[data-theme="light"] body {
    background: #f3f7fc !important;
    color: var(--text);
}

:root[data-theme="light"] .crm-sidebar {
    background: #ffffff;
    border: 1px solid var(--border);
}

:root[data-theme="light"] .crm-main {
    background: #ffffff;
    border: 1px solid var(--border);
}

:root[data-theme="light"] .crm-card {
    background: #ffffff;
}

:root[data-theme="light"] .crm-table-wrapper {
    background: #ffffff;
}

:root[data-theme="light"] .crm-table tr:hover td {
    background: rgba(0, 158, 194, 0.06);
}

/* Таблиця: бейджі статусів та кнопки дій — читабельність на світлому тлі */
:root[data-theme="light"] .badge-status {
    color: #0d1b2a;
}
:root[data-theme="light"] .badge-status.new {
    background: rgba(0, 158, 194, 0.18);
    color: #006b85;
    border-color: rgba(0, 158, 194, 0.4);
}
:root[data-theme="light"] .badge-status.in_progress {
    background: rgba(204, 132, 0, 0.2);
    color: #996300;
    border-color: rgba(255, 165, 0, 0.45);
}
:root[data-theme="light"] .badge-status.done {
    background: rgba(34, 139, 34, 0.18);
    color: #1e7b1e;
    border-color: rgba(34, 139, 34, 0.4);
}
:root[data-theme="light"] .badge-status.cancelled {
    background: rgba(180, 50, 60, 0.15);
    color: #b8323c;
    border-color: rgba(220, 53, 69, 0.4);
}

:root[data-theme="light"] .crm-table .btn-ghost {
    background: #eef2f7;
    color: #0d1b2a;
    border-color: #cfd7e3;
}
:root[data-theme="light"] .crm-table .btn-ghost:hover {
    background: #dfe5ee;
    border-color: #9aa4b5;
}

/* ==========================================================
   ♿ ACCESSIBILITY MODE — WCAG 2.1
   ==========================================================*/

/* Працює і через data-accessibility="on" на <html>, і через body.accessibility-mode */
:root[data-accessibility="on"],
body.accessibility-mode {
    --bg: #000 !important;
    --bg-soft: #000 !important;
    --bg-soft-alt: #000 !important;
    --card: #000 !important;

    --primary: #ff0 !important;
    --primary-soft: rgba(255, 255, 0, 0.25) !important;
    --primary-border: rgba(255, 255, 0, 0.8) !important;

    --accent: #0ff !important;
    --danger: #ff6b6b !important;

    --text: #fff !important;
    --text-soft: #fff !important;
    --muted: #fff !important;

    --border: #fff !important;

    filter: contrast(120%) brightness(120%);
}

/* Логотип у спеціальному режимі завжди світлий для кращої читабельності */
:root[data-accessibility="on"] .logo-light,
body.accessibility-mode .logo-light {
    display: inline-block !important;
}


:root[data-accessibility="on"] .logo-dark,
body.accessibility-mode .logo-dark {
    display: none !important;
}

/* Чіткий фон для світлої теми під час режиму доступності */
:root[data-accessibility="on"] body,
body.accessibility-mode {
    background: #000 !important;
}

/* Контейнери та таблиці стають висококонтрастними, щоб текст не губився на світлому тлі */
:root[data-accessibility="on"] .crm-main,
:root[data-accessibility="on"] .crm-sidebar,
:root[data-accessibility="on"] .crm-card,
:root[data-accessibility="on"] .crm-table-wrapper,
:root[data-accessibility="on"] .crm-table th,
:root[data-accessibility="on"] .crm-table td {
    background: #000 !important;
    border-color: #0ff !important;
    color: #fff !important;
}

:root[data-accessibility="on"] .crm-table tr:nth-child(even) td {
    background: rgba(255, 255, 0, 0.08) !important;
}

:root[data-accessibility="on"] .crm-table tr:hover td {
    background: rgba(0, 255, 255, 0.18) !important;
    color: #000 !important;
}

/* Контури та фокус */
:root[data-accessibility="on"] *:focus,
body.accessibility-mode *:focus {
    outline: 3px solid #0ff !important;
    outline-offset: 3px !important;
}

/* Великі шрифти */
:root[data-accessibility="on"],
body.accessibility-mode {
    font-size: 18px !important;
}

/* Читаємі форми та кнопки у доступному режимі */
:root[data-accessibility="on"] .form-group label,
body.accessibility-mode .form-group label {
    color: #ff0 !important;
}

:root[data-accessibility="on"] .form-group input,
:root[data-accessibility="on"] .form-group select,
:root[data-accessibility="on"] .form-group textarea,
body.accessibility-mode .form-group input,
body.accessibility-mode .form-group select,
body.accessibility-mode .form-group textarea {
    background: #000 !important;
    color: #fff !important;
    border: 2px solid #0ff !important;
}

:root[data-accessibility="on"] .form-group input::placeholder,
:root[data-accessibility="on"] .form-group textarea::placeholder,
body.accessibility-mode .form-group input::placeholder,
body.accessibility-mode .form-group textarea::placeholder {
    color: #ff0 !important;
    opacity: 1 !important;
}

:root[data-accessibility="on"] .btn-primary,
body.accessibility-mode .btn-primary {
    background: #ff0 !important;
    color: #000 !important;
    box-shadow: 0 0 0 2px #0ff inset !important;
}

:root[data-accessibility="on"] .btn-ghost,
body.accessibility-mode .btn-ghost {
    background: #000 !important;
    border: 2px solid #0ff !important;
    color: #fff !important;
}

/* Кнопки дуже видимі */
:root[data-accessibility="on"] button,
:root[data-accessibility="on"] a,
body.accessibility-mode button,
body.accessibility-mode a {
    border: 2px solid #0ff !important;
    padding: 10px 16px !important;
}


/* ==========================================================
   🔁 Плавна анімація перемикання теми
   ==========================================================*/

* {
    transition: background 0.25s ease,
    color 0.25s ease,
    border-color 0.25s ease,
    box-shadow 0.25s ease;
}


/* HEADER */
.crm-header {
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    background: var(--bg-soft);
    padding: 12px 24px;
    border-bottom: 1px solid var(--border);
    overflow-x: hidden;
}

.crm-header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.crm-logo {
    flex-shrink: 0;
}

.crm-logo img {
    height: 36px;
}

/* Default (Dark Theme) - Show LIGHT Logo */
.logo-light { display: inline-block; }
.logo-dark { display: none; }

/* Light Theme - Show DARK Logo */
:root[data-theme="light"] .logo-light { display: none; }
:root[data-theme="light"] .logo-dark { display: inline-block; }

:root[data-accessibility="on"] .crm-logo .logo-light,
body.accessibility-mode .crm-logo .logo-light {
    display: inline-block !important;
    opacity: 1 !important;
}

:root[data-accessibility="on"] .crm-logo .logo-dark,
body.accessibility-mode .crm-logo .logo-dark {
    display: none !important;
    opacity: 0 !important;
}

.crm-header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex-shrink: 1;
}

.crm-header-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-soft-alt);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.08s ease;
}

.crm-header-btn:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.crm-user-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 999px;
    background: transparent;
    max-width: 220px;
    min-width: 0;
}

.crm-user-link-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.crm-user-link:hover {
    background: var(--primary-soft);
}

@media (max-width: 640px) {
    .crm-header {
        padding: 10px 12px;
    }
    .crm-header-inner {
        gap: 8px;
    }
    .crm-user-link {
        max-width: 140px;
    }
}

/* ==========================================================
    СПЕЦІАЛЬНИЙ РЕЖИМ — ЗАВЖДИ ТІЛЬКИ СВІТЛИЙ ЛОГОТИП
   ==========================================================*/

html[data-accessibility="on"] .crm-logo .logo-light,
body.accessibility-mode .crm-logo .logo-light {
    display: inline-block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

html[data-accessibility="on"] .crm-logo .logo-dark,
body.accessibility-mode .crm-logo .logo-dark {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

/* ==========================================================
   📋 PARTNER PROFILE TABS
   ==========================================================*/

.crm-profile-tabs-container {
    margin-top: 10px;
}

.crm-profile-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
    padding-bottom: 0;
}

.crm-profile-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    margin-bottom: -1px;
}

.crm-profile-tab:hover {
    color: var(--text);
    background: var(--bg-soft-alt);
}

.crm-profile-tab.is-active {
    background: var(--bg-soft-alt);
    border-color: var(--border);
    color: var(--text);
    position: relative;
}

.crm-profile-tab.is-active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--bg-soft-alt);
}

.crm-tab-icon {
    font-size: 14px;
}

.crm-profile-tab-content {
    display: none !important;
    padding: 20px;
    background: var(--bg-soft-alt);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.crm-profile-tab-content.is-active {
    display: block !important;
}

.crm-profile-tab-content h3 {
    margin: 0 0 16px;
    font-size: 18px;
    color: var(--text);
}

.crm-profile-tab-content h4 {
    margin: 20px 0 12px;
    font-size: 15px;
    color: var(--text);
}

.crm-profile-submit {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.crm-help-text {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 16px;
}

/* Radio and Checkbox Groups */
.crm-radio-group,
.crm-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 6px;
}

.crm-radio-label,
.crm-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-soft);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-soft);
    transition: border-color 0.2s ease, background 0.2s ease;
}

.crm-radio-label:hover,
.crm-checkbox-label:hover {
    border-color: var(--primary-border);
}

.crm-radio-label input,
.crm-checkbox-label input {
    margin: 0;
}

.crm-radio-label input:checked + span,
.crm-checkbox-label input:checked + span {
    color: var(--primary);
}

.crm-radio-label:has(input:checked),
.crm-checkbox-label:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
}

/* Status Display */
.crm-status-display {
    margin-top: 12px;
}

.crm-status-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
}

.crm-status-badge.status-active {
    background: rgba(86, 209, 141, 0.18);
    color: #d0ffe1;
    border: 1px solid rgba(86, 209, 141, 0.4);
}

.crm-status-badge.status-testing {
    background: rgba(255, 168, 0, 0.18);
    color: #ffecc2;
    border: 1px solid rgba(255, 186, 73, 0.4);
}

.crm-status-badge.status-blocked {
    background: rgba(255, 74, 106, 0.18);
    color: #ffd5df;
    border: 1px solid rgba(255, 74, 106, 0.4);
}

/* ==========================================================
   🖼️ PORTFOLIO SECTION
   ==========================================================*/

.crm-portfolio-field {
    margin-top: 10px;
}

.crm-portfolio-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
    min-height: 100px;
    padding: 12px;
    background: var(--bg-soft);
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
}

.crm-portfolio-thumb {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.crm-portfolio-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.crm-portfolio-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.crm-portfolio-thumb:hover .crm-portfolio-remove {
    opacity: 1;
}

.crm-portfolio-remove:hover {
    background: var(--danger);
}

.crm-portfolio-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.crm-portfolio-upload-btn {
    cursor: pointer;
}

.crm-empty-message {
    color: var(--muted);
    font-size: 13px;
    font-style: italic;
    margin: 0;
}

/* ==========================================================
   ⭐ RATING & REVIEWS
   ==========================================================*/

.crm-rating-summary-card {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
    max-width: 300px;
}

.crm-rating-big {
    font-size: 28px;
    line-height: 1.2;
    margin-bottom: 8px;
}

.crm-star {
    margin-right: 2px;
}

.crm-star.full {
    color: #f5c518;
}

.crm-star.half {
    color: #f5c518;
    position: relative;
}

.crm-star.empty {
    color: var(--muted);
}

.crm-rating-value {
    font-weight: 600;
    margin-left: 8px;
    color: var(--text);
}

.crm-rating-count {
    font-size: 13px;
    color: var(--muted);
    margin: 0;
}

.crm-rating-distribution {
    max-width: 350px;
    margin-bottom: 20px;
}

.crm-rating-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.crm-rating-bar-label {
    width: 45px;
    font-size: 12px;
    color: var(--muted);
}

.crm-rating-bar {
    flex: 1;
    height: 10px;
    background: var(--bg-soft);
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.crm-rating-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #f5c518, #ffda44);
    border-radius: 5px;
    transition: width 0.3s ease;
}

.crm-rating-bar-count {
    width: 30px;
    text-align: right;
    font-size: 12px;
    color: var(--muted);
}

.crm-reviews-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 600px;
}

.crm-review-item {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
}

.crm-review-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.crm-review-author {
    font-weight: 600;
    color: var(--text);
    font-size: 14px;
}

.crm-review-stars {
    font-size: 13px;
}

.crm-review-date {
    color: var(--muted);
    font-size: 12px;
    margin-left: auto;
}

.crm-review-comment {
    color: var(--text-soft);
    font-size: 14px;
    line-height: 1.5;
}

.crm-review-request {
    margin-top: 8px;
    font-size: 12px;
    color: var(--muted);
}

.crm-no-reviews {
    color: var(--muted);
    font-style: italic;
}

/* Light Theme Adjustments */
:root[data-theme="light"] .crm-profile-tab.is-active {
    background: #ffffff;
}

:root[data-theme="light"] .crm-profile-tab.is-active::after {
    background: #ffffff;
}

:root[data-theme="light"] .crm-profile-tab-content {
    background: #ffffff;
}

:root[data-theme="light"] .crm-rating-summary-card,
:root[data-theme="light"] .crm-review-item {
    background: #f8fafc;
}

:root[data-theme="light"] .crm-portfolio-preview {
    background: #f8fafc;
}

:root[data-theme="light"] .crm-radio-label,
:root[data-theme="light"] .crm-checkbox-label {
    background: #f8fafc;
}

:root[data-theme="light"] .crm-star.full {
    color: #f5a623;
}

:root[data-theme="light"] .crm-status-badge.status-active {
    background: rgba(34, 139, 34, 0.15);
    color: #228b22;
    border-color: rgba(34, 139, 34, 0.4);
}

:root[data-theme="light"] .crm-status-badge.status-testing {
    background: rgba(255, 165, 0, 0.15);
    color: #cc8400;
    border-color: rgba(255, 165, 0, 0.4);
}

:root[data-theme="light"] .crm-status-badge.status-blocked {
    background: rgba(220, 53, 69, 0.15);
    color: #dc3545;
    border-color: rgba(220, 53, 69, 0.4);
}

/* Responsive tabs */
@media (max-width: 768px) {
    .crm-profile-tabs {
        flex-direction: column;
        border-bottom: none;
        gap: 2px;
    }

    .crm-profile-tab {
        border-radius: var(--radius-md);
        border: 1px solid var(--border);
        margin-bottom: 0;
    }

    .crm-profile-tab.is-active::after {
        display: none;
    }

    .crm-profile-tab-content {
        border-radius: var(--radius-md);
        border-top: 1px solid var(--border);
    }

    .crm-rating-summary-card {
        max-width: 100%;
    }

    .crm-rating-distribution {
        max-width: 100%;
    }

    .crm-portfolio-thumb {
        width: 80px;
        height: 80px;
    }
}

/* ============================================
   USER CHAT WITH SUPPORT - TELEGRAM STYLE
   ============================================ */

/* Notification badge in header */
.crm-header-btn {
    position: relative;
    overflow: visible;
}

.crm-notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #c0392b;
    color: #fff;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    border: 2px solid var(--bg-soft-alt, #111d2e);
}

.crm-notification-badge-dot {
    min-width: 10px;
    height: 10px;
    padding: 0;
    border-radius: 50%;
    font-size: 0;
}

/* Red dot in top-right corner of bell (no number) when partner has pending tasks */
.crm-tasks-notification-btn.has-pending::after {
    content: "";
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #c0392b;
    border: 2px solid var(--bg-soft-alt, #111d2e);
    z-index: 2;
}

/* Red dot on chat icon when there are unread messages (like notifications bell) */
.crm-chat-notification-btn.has-unread::after {
    content: "";
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #c0392b;
    border: 2px solid var(--bg-soft-alt, #111d2e);
    z-index: 2;
}

.crm-header-tasks-wrap {
    position: relative;
    display: inline-block;
    overflow: visible;
}

/* Dropdown: in-header (hidden until moved to body by JS) */
.crm-header-tasks-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 300px;
    max-width: 360px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 12px);
    box-shadow: var(--shadow-soft, 0 18px 40px rgba(0, 0, 0, 0.45));
    z-index: 10000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.crm-header-tasks-dropdown-portal {
    position: fixed !important;
    top: auto !important;
    right: auto !important;
}

.crm-header-tasks-dropdown[hidden] {
    display: none !important;
}

.crm-header-tasks-dropdown-title {
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    background: var(--bg-soft-alt);
}

.crm-header-tasks-dropdown-list {
    padding: 6px 0;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 156px;
    -webkit-overflow-scrolling: touch;
}

.crm-header-tasks-dropdown-loading,
.crm-header-tasks-dropdown-empty {
    padding: 16px;
    font-size: 14px;
    color: var(--text-soft);
    line-height: 1.4;
}

.crm-header-tasks-dropdown-item {
    display: block;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.35;
    color: var(--text);
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.crm-header-tasks-dropdown-item:hover,
.crm-header-tasks-dropdown-item:focus {
    background: var(--primary-soft);
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.crm-header-tasks-dropdown-item strong {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    color: var(--text);
}

.crm-header-tasks-dropdown-item span {
    font-size: 12px;
    color: var(--text-soft);
}

.crm-header-tasks-dropdown-footer {
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    text-align: center;
    border-top: 1px solid var(--border);
    background: var(--bg-soft-alt);
}

.crm-header-tasks-dropdown-footer:hover,
.crm-header-tasks-dropdown-footer:focus {
    background: var(--primary-soft);
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

/* Light theme */
[data-theme="light"] .crm-notification-badge,
[data-theme="light"] .crm-tasks-notification-btn.has-pending::after,
[data-theme="light"] .crm-chat-notification-btn.has-unread::after {
    border-color: var(--bg-soft-alt);
}

[data-theme="light"] .crm-header-tasks-dropdown {
    background: var(--bg-soft);
    border-color: var(--border);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .crm-header-tasks-dropdown-title,
[data-theme="light"] .crm-header-tasks-dropdown-footer {
    background: var(--bg-soft-alt);
    color: var(--text);
}

[data-theme="light"] .crm-header-tasks-dropdown-footer {
    color: var(--accent);
}

[data-theme="light"] .crm-header-tasks-dropdown-item,
[data-theme="light"] .crm-header-tasks-dropdown-item strong {
    color: var(--text);
}

[data-theme="light"] .crm-header-tasks-dropdown-item span,
[data-theme="light"] .crm-header-tasks-dropdown-loading,
[data-theme="light"] .crm-header-tasks-dropdown-empty {
    color: var(--text-soft);
}

/* Accessibility: high contrast and reduced motion */
@media (prefers-reduced-motion: reduce) {
    .crm-header-tasks-dropdown,
    .crm-header-tasks-dropdown-item,
    .crm-header-tasks-dropdown-footer {
        transition: none;
    }
}

body.accessibility-mode .crm-notification-badge,
body.accessibility-mode .crm-tasks-notification-btn.has-pending::after,
body.accessibility-mode .crm-chat-notification-btn.has-unread::after {
    background: #c0392b;
    border-width: 2px;
    border-color: #fff;
}

body.accessibility-mode .crm-header-tasks-dropdown {
    border: 2px solid var(--text);
}

body.accessibility-mode .crm-header-tasks-dropdown-item,
body.accessibility-mode .crm-header-tasks-dropdown-item strong,
body.accessibility-mode .crm-header-tasks-dropdown-title {
    color: var(--text);
}

body.accessibility-mode .crm-header-tasks-dropdown-item:hover,
body.accessibility-mode .crm-header-tasks-dropdown-item:focus,
body.accessibility-mode .crm-header-tasks-dropdown-footer:hover,
body.accessibility-mode .crm-header-tasks-dropdown-footer:focus {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* Menu badge */
.crm-menu-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 8px;
    background: var(--accent);
    color: #fff;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 600;
}

/* Chat section full height - only when active */
.crm-section--chat.is-active {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 500px;
}

/* Двопанельний чат кабінету (як в адмінці) */
.crm-cabinet-chat-wrap {
    flex: 1;
    display: flex;
    min-height: 0;
    background: #0e1621;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid #232e3c;
}

.crm-cabinet-chats-panel {
    width: 320px;
    min-width: 280px;
    background: #17212b;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #232e3c;
}

.crm-cabinet-chats-header {
    height: 56px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #232e3c;
}

.crm-cabinet-chat-search {
    flex: 1;
    display: flex;
    align-items: center;
    background: #242f3d;
    border-radius: 20px;
    padding: 0 12px;
    height: 36px;
}

.crm-cabinet-chat-search i {
    color: #6c7883;
    font-size: 14px;
    margin-right: 8px;
}

.crm-cabinet-chat-search input {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 14px;
    padding: 0;
    outline: none;
}

.crm-cabinet-chat-search input::placeholder {
    color: #6c7883;
}

.crm-cabinet-chats-list {
    flex: 1;
    overflow-y: auto;
}

.crm-cabinet-chat-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    color: #6c7883;
    gap: 12px;
}

.crm-cabinet-chat-empty-msg {
    padding: 24px 16px;
    text-align: center;
    color: #6c7883;
    font-size: 14px;
}

/* Елемент списку чатів */
.crm-cabinet-chat-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.crm-cabinet-chat-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.crm-cabinet-chat-item.active {
    background: #2b5278;
}

.crm-cabinet-chat-item__avatar {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    margin-right: 12px;
    border-radius: 50%;
    background: #3a4654;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5eb5f7;
    font-size: 18px;
}

.crm-cabinet-chat-item__content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.crm-cabinet-chat-item__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.crm-cabinet-chat-item__name {
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crm-cabinet-chat-item__time {
    font-size: 12px;
    color: #6c7883;
    flex-shrink: 0;
    margin-left: 8px;
}

.crm-cabinet-chat-item__preview {
    font-size: 13px;
    color: #6c7883;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Права панель — область чату */
.crm-cabinet-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0e1621;
    min-width: 0;
}

.crm-cabinet-chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6c7883;
}

.crm-cabinet-chat-empty__icon {
    width: 100px;
    height: 100px;
    background: #17212b;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.crm-cabinet-chat-empty__icon i {
    font-size: 48px;
    color: #5eb5f7;
}

.crm-cabinet-chat-empty p {
    font-size: 15px;
    margin: 0;
}

.crm-cabinet-chat-conversation {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.crm-cabinet-chat-header {
    height: 56px;
    background: #17212b;
    border-bottom: 1px solid #232e3c;
    display: flex;
    align-items: center;
    padding: 0 16px;
    flex-shrink: 0;
}

.crm-cabinet-chat-header__avatar {
    width: 42px;
    height: 42px;
    margin-right: 12px;
    flex-shrink: 0;
    border-radius: 50%;
    background: #5eb5f7;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
}

.crm-cabinet-chat-header__info {
    flex: 1;
    min-width: 0;
}

.crm-cabinet-chat-header__name {
    font-size: 15px;
    font-weight: 500;
    color: #fff;
}

.crm-cabinet-chat-header__meta {
    font-size: 13px;
    color: #6c7883;
}

.crm-cabinet-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    background: #0e1621;
}

.crm-cabinet-no-messages {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #6c7883;
    text-align: center;
}

.crm-cabinet-no-messages i {
    font-size: 40px;
    color: #5eb5f7;
    margin-bottom: 12px;
}

.crm-cabinet-no-messages p {
    margin: 0;
    font-size: 14px;
}

.crm-cabinet-chat-error {
    padding: 24px;
    text-align: center;
    color: #e74c3c;
}

.crm-cabinet-msg {
    display: flex;
    margin-bottom: 12px;
}

.crm-cabinet-msg--own {
    justify-content: flex-end;
}

.crm-cabinet-msg__bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 12px;
    background: #17212b;
}

.crm-cabinet-msg--own .crm-cabinet-msg__bubble {
    background: #2b5278;
}

.crm-cabinet-msg__text {
    font-size: 14px;
    color: #fff;
    white-space: pre-wrap;
    word-break: break-word;
}

.crm-cabinet-msg__time {
    font-size: 11px;
    color: #6c7883;
    margin-top: 4px;
}

.crm-cabinet-chat-input-wrap {
    padding: 12px 16px;
    background: #17212b;
    border-top: 1px solid #232e3c;
    flex-shrink: 0;
}

.crm-cabinet-chat-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #242f3d;
    border-radius: 24px;
    padding: 8px 8px 8px 16px;
}

.crm-cabinet-chat-textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 14px;
    padding: 8px 0;
    resize: none;
    outline: none;
    min-height: 24px;
    max-height: 120px;
}

.crm-cabinet-chat-textarea::placeholder {
    color: #6c7883;
}

.crm-cabinet-chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #5eb5f7;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.crm-cabinet-chat-send-btn:hover {
    background: #4aa3e8;
}

.crm-cabinet-chat-send-btn i {
    font-size: 16px;
}

/* --- Світла тема для чату --- */
:root[data-theme="light"] .crm-cabinet-chat-wrap {
    background: var(--bg-soft);
    border-color: var(--border);
}

:root[data-theme="light"] .crm-cabinet-chats-panel {
    background: var(--bg-soft-alt);
    border-right-color: var(--border);
}

:root[data-theme="light"] .crm-cabinet-chats-header {
    border-bottom-color: var(--border);
}

:root[data-theme="light"] .crm-cabinet-chat-search {
    background: var(--bg-soft);
}

:root[data-theme="light"] .crm-cabinet-chat-search i {
    color: var(--text-soft);
}

:root[data-theme="light"] .crm-cabinet-chat-search input {
    color: var(--text);
}

:root[data-theme="light"] .crm-cabinet-chat-search input::placeholder {
    color: var(--text-soft);
}

:root[data-theme="light"] .crm-cabinet-chat-loading,
:root[data-theme="light"] .crm-cabinet-chat-empty-msg {
    color: var(--text-soft);
}

:root[data-theme="light"] .crm-cabinet-chat-item {
    border-bottom-color: var(--border);
}

:root[data-theme="light"] .crm-cabinet-chat-item:hover {
    background: var(--primary-soft);
}

:root[data-theme="light"] .crm-cabinet-chat-item.active {
    background: var(--primary-soft);
    border-left: 3px solid var(--primary);
}

:root[data-theme="light"] .crm-cabinet-chat-item__avatar {
    background: var(--border);
    color: var(--primary);
}

:root[data-theme="light"] .crm-cabinet-chat-item__name {
    color: var(--text);
}

:root[data-theme="light"] .crm-cabinet-chat-item__time,
:root[data-theme="light"] .crm-cabinet-chat-item__preview {
    color: var(--text-soft);
}

:root[data-theme="light"] .crm-cabinet-chat-area {
    background: var(--bg-soft);
}

:root[data-theme="light"] .crm-cabinet-chat-empty {
    color: var(--text-soft);
}

:root[data-theme="light"] .crm-cabinet-chat-empty__icon {
    background: var(--bg-soft-alt);
}

:root[data-theme="light"] .crm-cabinet-chat-empty__icon i {
    color: var(--primary);
}

:root[data-theme="light"] .crm-cabinet-chat-empty p {
    color: var(--text-soft);
}

:root[data-theme="light"] .crm-cabinet-chat-header {
    background: var(--bg-soft-alt);
    border-bottom-color: var(--border);
}

:root[data-theme="light"] .crm-cabinet-chat-header__avatar {
    background: var(--primary);
    color: #fff;
}

:root[data-theme="light"] .crm-cabinet-chat-header__name {
    color: var(--text);
}

:root[data-theme="light"] .crm-cabinet-chat-header__meta {
    color: var(--text-soft);
}

:root[data-theme="light"] .crm-cabinet-chat-messages {
    background: var(--bg-soft);
}

:root[data-theme="light"] .crm-cabinet-no-messages {
    color: var(--text-soft);
}

:root[data-theme="light"] .crm-cabinet-no-messages i {
    color: var(--primary);
}

:root[data-theme="light"] .crm-cabinet-msg__bubble {
    background: var(--bg-soft-alt);
}

:root[data-theme="light"] .crm-cabinet-msg--own .crm-cabinet-msg__bubble {
    background: var(--primary-soft);
}

:root[data-theme="light"] .crm-cabinet-msg__text {
    color: var(--text);
}

:root[data-theme="light"] .crm-cabinet-msg__time {
    color: var(--text-soft);
}

:root[data-theme="light"] .crm-cabinet-chat-input-wrap {
    background: var(--bg-soft-alt);
    border-top-color: var(--border);
}

:root[data-theme="light"] .crm-cabinet-chat-form {
    background: var(--bg-soft);
}

:root[data-theme="light"] .crm-cabinet-chat-textarea {
    color: var(--text);
}

:root[data-theme="light"] .crm-cabinet-chat-textarea::placeholder {
    color: var(--text-soft);
}

:root[data-theme="light"] .crm-cabinet-chat-send-btn {
    background: var(--primary);
}

:root[data-theme="light"] .crm-cabinet-chat-send-btn:hover {
    background: var(--accent);
}

:root[data-theme="light"] .crm-tg-spinner {
    border-color: var(--border);
    border-top-color: var(--primary);
}

/* Кнопка "Повідомлення" в картці заявки */
.crm-chat-open-wrap {
    padding: 16px 0;
}

.crm-chat-open-wrap .btn i {
    margin-right: 8px;
}

/* Chat container - Telegram style (legacy, kept for spinner) */
.crm-tg-user-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0e1621;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid #232e3c;
}

/* Chat Header */
.crm-tg-user-header {
    height: 56px;
    background: #17212b;
    border-bottom: 1px solid #232e3c;
    display: flex;
    align-items: center;
    padding: 0 16px;
    flex-shrink: 0;
}

.crm-tg-user-header__avatar {
    width: 42px;
    height: 42px;
    margin-right: 12px;
    flex-shrink: 0;
    border-radius: 50%;
    background: #5eb5f7;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
}

.crm-tg-user-header__info {
    flex: 1;
    min-width: 0;
}

.crm-tg-user-header__name {
    font-size: 15px;
    font-weight: 500;
    color: #fff;
}

.crm-tg-user-header__status {
    font-size: 13px;
    color: #6c7883;
    display: flex;
    align-items: center;
    gap: 6px;
}

.crm-tg-online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2ecc71;
    animation: tg-pulse 2s infinite;
}

@keyframes tg-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Messages Area */
.crm-tg-user-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    background: #0e1621;
}

.crm-tg-user-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6c7883;
    gap: 12px;
}

.crm-tg-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #232e3c;
    border-top-color: #5eb5f7;
    border-radius: 50%;
    animation: tg-spin 0.8s linear infinite;
}

@keyframes tg-spin {
    to { transform: rotate(360deg); }
}

/* Welcome message */
.crm-tg-user-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: #6c7883;
}

.crm-tg-user-welcome__icon {
    width: 100px;
    height: 100px;
    background: #17212b;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.crm-tg-user-welcome__icon i {
    font-size: 40px;
    color: #5eb5f7;
}

.crm-tg-user-welcome p {
    font-size: 15px;
    max-width: 300px;
    margin: 0;
}

/* Error state */
.crm-tg-user-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #e74c3c;
}

/* Date divider */
.crm-tg-user-date {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 16px 0;
}

.crm-tg-user-date span {
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
}

/* Messages */
.crm-tg-user-msg {
    display: flex;
    margin-bottom: 8px;
    max-width: 65%;
}

.crm-tg-user-msg--own {
    margin-left: auto;
    flex-direction: row-reverse;
}

.crm-tg-user-msg--other {
    margin-right: auto;
}

.crm-tg-user-msg__avatar {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    margin-right: 8px;
    align-self: flex-end;
    border-radius: 50%;
    background: #5eb5f7;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
}

.crm-tg-user-msg--own .crm-tg-user-msg__avatar {
    margin-right: 0;
    margin-left: 8px;
}

.crm-tg-user-msg__bubble {
    background: #182533;
    border-radius: 12px;
    padding: 8px 12px;
    min-width: 80px;
}

.crm-tg-user-msg--own .crm-tg-user-msg__bubble {
    background: #2b5278;
    border-bottom-right-radius: 4px;
}

.crm-tg-user-msg--other .crm-tg-user-msg__bubble {
    border-bottom-left-radius: 4px;
}

.crm-tg-user-msg__author {
    font-size: 13px;
    font-weight: 500;
    color: #5eb5f7;
    margin-bottom: 4px;
}

.crm-tg-user-msg__text {
    font-size: 14px;
    color: #fff;
    line-height: 1.4;
    word-wrap: break-word;
}

.crm-tg-user-msg__text a {
    color: #5eb5f7;
}

.crm-tg-user-msg__time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    text-align: right;
    margin-top: 4px;
}

/* Message animation */
.crm-tg-user-msg--new {
    animation: tg-msg-in 0.2s ease;
}

@keyframes tg-msg-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Input */
.crm-tg-user-input {
    background: #17212b;
    border-top: 1px solid #232e3c;
    padding: 8px 12px;
    flex-shrink: 0;
}

.crm-tg-user-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #242f3d;
    border-radius: 20px;
    padding: 4px 4px 4px 16px;
}

.crm-tg-user-textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 14px;
    line-height: 1.4;
    padding: 8px 0;
    resize: none;
    min-height: 20px;
    max-height: 120px;
    outline: none;
    font-family: inherit;
}

.crm-tg-user-textarea::placeholder {
    color: #6c7883;
}

.crm-tg-user-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #5eb5f7;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.crm-tg-user-send-btn:hover {
    background: #4aa3e8;
}

.crm-tg-user-send-btn:disabled {
    background: #3a4654;
    cursor: not-allowed;
}

.crm-tg-user-send-btn i {
    font-size: 16px;
}

/* Scrollbar */
.crm-tg-user-messages::-webkit-scrollbar {
    width: 6px;
}

.crm-tg-user-messages::-webkit-scrollbar-track {
    background: transparent;
}

.crm-tg-user-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.crm-tg-user-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Чат — світла тема */
:root[data-theme="light"] .crm-tg-user-chat {
    background: var(--bg-soft);
    border-color: var(--border);
}

:root[data-theme="light"] .crm-tg-user-header {
    background: var(--bg-soft-alt);
    border-bottom-color: var(--border);
}

:root[data-theme="light"] .crm-tg-user-header__name {
    color: var(--text);
}

:root[data-theme="light"] .crm-tg-user-header__status {
    color: var(--muted);
}

:root[data-theme="light"] .crm-tg-user-messages {
    background: var(--bg-soft);
}

:root[data-theme="light"] .crm-tg-user-loading {
    color: var(--muted);
}

:root[data-theme="light"] .crm-tg-spinner {
    border-color: var(--border);
    border-top-color: var(--primary);
}

:root[data-theme="light"] .crm-tg-user-welcome {
    color: var(--muted);
}

:root[data-theme="light"] .crm-tg-user-welcome__icon {
    background: var(--bg-soft-alt);
}

:root[data-theme="light"] .crm-tg-user-welcome__icon i {
    color: var(--primary);
}

:root[data-theme="light"] .crm-tg-user-welcome p {
    color: var(--text-soft);
}

:root[data-theme="light"] .crm-tg-user-error {
    color: var(--danger);
}

:root[data-theme="light"] .crm-tg-user-date span {
    background: var(--bg-soft-alt);
    color: var(--text);
}

:root[data-theme="light"] .crm-tg-user-msg__avatar {
    background: var(--primary);
    color: #fff;
}

:root[data-theme="light"] .crm-tg-user-msg__bubble {
    background: var(--bg-soft-alt);
}

:root[data-theme="light"] .crm-tg-user-msg--own .crm-tg-user-msg__bubble {
    background: var(--primary-soft);
    border: 1px solid var(--primary-border);
}

:root[data-theme="light"] .crm-tg-user-msg--other .crm-tg-user-msg__bubble {
    background: var(--bg-soft-alt);
    border: 1px solid var(--border);
}

:root[data-theme="light"] .crm-tg-user-msg__author {
    color: var(--primary);
}

:root[data-theme="light"] .crm-tg-user-msg__text {
    color: var(--text);
}

:root[data-theme="light"] .crm-tg-user-msg__text a {
    color: var(--primary);
}

:root[data-theme="light"] .crm-tg-user-msg__time {
    color: var(--muted);
}

:root[data-theme="light"] .crm-tg-user-input {
    background: var(--bg-soft-alt);
    border-top-color: var(--border);
}

:root[data-theme="light"] .crm-tg-user-form {
    background: var(--bg-soft);
    border: 1px solid var(--border);
}

:root[data-theme="light"] .crm-tg-user-textarea {
    color: var(--text);
}

:root[data-theme="light"] .crm-tg-user-textarea::placeholder {
    color: var(--muted);
}

:root[data-theme="light"] .crm-tg-user-send-btn {
    background: var(--primary);
    color: #fff;
}

:root[data-theme="light"] .crm-tg-user-send-btn:hover:not(:disabled) {
    background: var(--accent);
}

:root[data-theme="light"] .crm-tg-user-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
}

:root[data-theme="light"] .crm-tg-user-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* Старий чат (chat-wrapper) — світла тема */
:root[data-theme="light"] .chat-message.other {
    background: var(--bg-soft-alt);
    border-color: var(--border);
}

/* Responsive */
@media (max-width: 768px) {
    .crm-section--chat.is-active {
        height: calc(100vh - 250px);
        min-height: 400px;
    }

    .crm-tg-user-msg {
        max-width: 85%;
    }
}

