/* ========================================
   Chat Redesign - Aligned with Project Design System
   ======================================== */

/* Import project variables from style.css */
/* Using existing CSS variables from :root */

/* Chat-specific overrides and additions */
:root {
    /* Chat-specific colors bound to theme */
    --chat-primary: var(--color-primary, #4A6FA5);
    --chat-primary-light: var(--color-primary-light, #6F92C2);
    --chat-primary-dark: var(--color-primary-dark, #365983);
    --chat-danger: var(--color-danger, #D2555A);
    --chat-warning: var(--color-warning, #DFA94B);
    --chat-info: var(--color-info, #3D7FC1);
    --chat-success: var(--color-success, #2D8F6F);
    --chat-line: #06C755;
    --chat-facebook: #1877F2;

    /* RGB values for rgba() usage - with fallbacks */
    --primary-rgb: 74, 111, 165;
    --success-rgb: 45, 143, 111;
    --warning-rgb: 223, 169, 75;
    --info-rgb: 61, 127, 193;
    --danger-rgb: 210, 85, 90;
    --border-rgb: 225, 229, 239;

    /* Backgrounds */
    --chat-bg-app: var(--bg-body, #F4F6FA);
    --chat-bg-sidebar: var(--bg-card, #FFFFFF);
    --chat-bg-chat: var(--bg-card, #F8FAFB);
    --chat-bg-message-user: #E8EDF4;
    --chat-bg-message-admin: var(--color-primary, #4A6FA5);
    --chat-bg-message-assistant: var(--bg-card, #FFFFFF);
    --chat-bg-hover: #EDF1F7;
    --chat-bg-active: rgba(74, 111, 165, 0.10);

    /* Text Colors */
    --chat-text-primary: var(--text-main, #1E2430);
    --chat-text-secondary: var(--text-sub, #4B5565);
    --chat-text-tertiary: var(--text-muted, #6B7280);
    --chat-text-white: #FFFFFF;

    /* Borders */
    --chat-border-color: var(--border, #E1E5EF);
    --chat-border-radius: var(--radius-md, 8px);

    /* Shadows */
    --chat-shadow-sm: var(--shadow-soft, 0 1px 3px rgba(0, 0, 0, 0.06));
    --chat-shadow: var(--shadow-md, 0 2px 6px rgba(0, 0, 0, 0.08));
    --chat-shadow-lg: var(--shadow-lg, 0 4px 12px rgba(0, 0, 0, 0.12));

    /* Sizes */
    --chat-sidebar-width: 360px;
    --chat-header-height: 52px;
    --chat-input-height: 52px;
    --chat-navbar-height: 56px;

    /* Transitions */
    --chat-transition: var(--transition-base, all 0.2s ease);
}

/* ========================================
   Chat App Wrapper
   ======================================== */

.chat-app-wrapper {
    padding-top: 0;
    padding-bottom: 0;
    background: var(--chat-bg-app);
    min-height: calc(100vh - var(--chat-navbar-height, 56px));
}

.chat-app {
    display: flex;
    height: calc(100vh - var(--chat-navbar-height, 56px));
    background: var(--chat-bg-app);
    border-radius: var(--chat-border-radius);
    overflow: hidden;
    box-shadow: var(--chat-shadow);
}

@supports (height: 100dvh) {
    .chat-app-wrapper {
        min-height: calc(100dvh - var(--chat-navbar-height, 56px));
    }

    .chat-app {
        height: calc(100dvh - var(--chat-navbar-height, 56px));
    }
}

.app-content {
    padding-top: 0;
    padding-bottom: 0.5rem;
}

.section-tabs__inner {
    padding: 0.25rem 0;
}

.chat-app[data-platform="line"] .chat-header::after {
    background: linear-gradient(90deg, var(--chat-line), transparent 60%);
}

.chat-app[data-platform="facebook"] .chat-header::after {
    background: linear-gradient(90deg, var(--chat-facebook), transparent 60%);
}

/* Platform-specific user message accent */
.chat-app[data-platform="line"] .message.user .message-bubble {
    border-left-color: var(--chat-line);
}

.chat-app[data-platform="facebook"] .message.user .message-bubble {
    border-left-color: var(--chat-facebook);
}

/* ========================================
   Sidebar (User List)
   ======================================== */

.chat-sidebar {
    width: var(--chat-sidebar-width);
    flex-shrink: 0;
    background: var(--chat-bg-sidebar);
    border-right: 1px solid var(--chat-border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Sidebar Header */
.sidebar-header {
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--chat-border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--chat-header-height);
    background: linear-gradient(135deg, rgba(74, 111, 165, 0.06), rgba(74, 111, 165, 0.02));
    backdrop-filter: blur(12px);
}

.sidebar-header-content {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.sidebar-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
    color: var(--chat-text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-family-heading, 'Prompt', sans-serif);
}

.sidebar-title i {
    color: var(--chat-primary);
}

.user-count-badge {
    background: var(--chat-primary);
    color: #ffffff;
    padding: 0.25rem 0.625rem;
    border-radius: 12px;
    font-size: 0.8125rem;
    font-weight: 600;
}

.btn-close-sidebar {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--chat-text-secondary);
    cursor: pointer;
    padding: 0.65rem;
    border-radius: var(--chat-border-radius);
    transition: var(--chat-transition);
    min-width: 44px;
    min-height: 44px;
}

.btn-close-sidebar:hover {
    background: var(--chat-bg-hover);
    color: var(--chat-text-primary);
}

/* Search Container */
.search-container {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--chat-border-color);
    background: var(--chat-bg-sidebar);
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--chat-bg-app);
    border-radius: 20px;
    padding: 0 0.6rem;
    transition: var(--chat-transition);
}

.search-input-wrapper:focus-within {
    background: var(--chat-bg-hover);
    border: 1.5px solid rgba(74, 111, 165, 0.35);
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.08);
    margin: -1.5px;
}

.search-icon {
    color: var(--chat-text-tertiary);
    font-size: 0.875rem;
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.5rem 0.65rem;
    font-size: 0.875rem;
    color: var(--chat-text-primary);
    outline: none;
    font-family: var(--font-family-base, 'Prompt', sans-serif);
}

.search-input::placeholder {
    color: var(--chat-text-tertiary);
}

.btn-filter {
    background: none;
    border: none;
    color: var(--chat-text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--chat-border-radius);
    transition: var(--chat-transition);
    position: relative;
}

.btn-filter:hover {
    color: var(--chat-primary);
}

.filter-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--chat-danger);
    color: #ffffff;
    font-size: 0.625rem;
    font-weight: 600;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}

/* Filter Panel */
.filter-panel {
    background: var(--chat-bg-sidebar);
    border-bottom: 1px solid var(--chat-border-color);
    padding: 1rem;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.filter-title {
    font-weight: 600;
    color: var(--chat-text-primary);
    font-size: 0.875rem;
}

.btn-clear-filter {
    background: none;
    border: none;
    color: var(--chat-primary);
    font-size: 0.8125rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--chat-border-radius);
    transition: var(--chat-transition);
}

.btn-clear-filter:hover {
    background: var(--chat-primary-light);
}

.filter-section {
    margin-bottom: 1rem;
}

.filter-section:last-child {
    margin-bottom: 0;
}

.filter-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--chat-text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-btn {
    background: var(--chat-bg-app);
    border: 1px solid var(--chat-border-color);
    color: var(--chat-text-secondary);
    padding: 0.375rem 0.75rem;
    border-radius: 16px;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: var(--chat-transition);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.filter-btn:hover {
    background: var(--chat-bg-hover);
    border-color: var(--chat-primary);
    color: var(--chat-primary);
}

.filter-btn.active {
    background: var(--chat-primary);
    border-color: var(--chat-primary);
    color: #ffffff;
}

.filter-btn i {
    font-size: 0.75rem;
}

.tag-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-filter-btn {
    background: var(--chat-bg-app);
    border: 1px solid var(--chat-border-color);
    color: var(--chat-text-secondary);
    padding: 0.25rem 0.625rem;
    border-radius: 12px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--chat-transition);
}

.tag-filter-btn:hover {
    border-color: var(--chat-primary);
    color: var(--chat-primary);
}

.tag-filter-btn.active {
    background: var(--chat-primary);
    border-color: var(--chat-primary);
    color: #ffffff;
}

.no-tags {
    color: var(--chat-text-tertiary);
    font-size: 0.8125rem;
}

.filter-summary {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--chat-border-color);
    font-size: 0.8125rem;
    color: var(--chat-text-secondary);
}

/* User List */
.user-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.user-list::-webkit-scrollbar {
    width: 6px;
}

.user-list::-webkit-scrollbar-track {
    background: transparent;
}

.user-list::-webkit-scrollbar-thumb {
    background: var(--chat-border-color);
    border-radius: 3px;
}

.user-list::-webkit-scrollbar-thumb:hover {
    background: var(--chat-text-tertiary);
}

.loading-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    color: var(--chat-text-secondary);
    gap: 0.75rem;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--chat-border-color);
    border-top-color: var(--chat-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* User Item */
.user-item {
    padding: 0.6rem 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(225, 229, 239, 0.5);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
}

.user-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: transparent;
    transition: background 0.2s ease;
    border-radius: 0 2px 2px 0;
}

.user-item[data-platform="line"]::before {
    background: rgba(6, 199, 85, 0.45);
}

.user-item[data-platform="facebook"]::before {
    background: rgba(24, 119, 242, 0.45);
}

.user-item:hover {
    background: var(--chat-bg-hover);
    transform: translateX(2px);
}

.user-item.active {
    background: var(--chat-bg-active);
}

.user-item.unread {
    background: rgba(74, 111, 165, 0.08);
}

.user-item.unread .user-name {
    font-weight: 700;
}

.user-item.unread:hover {
    background: rgba(74, 111, 165, 0.14);
}

.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--chat-primary);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.125rem;
    flex-shrink: 0;
}

.user-avatar.purchased {
    background: var(--chat-success);
}

.user-item-content {
    flex: 1;
    min-width: 0;
}

.user-item-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.user-meta {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.user-name {
    font-weight: 600;
    color: var(--chat-text-primary);
    font-size: 0.9375rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.user-time {
    font-size: 0.75rem;
    color: var(--chat-text-tertiary);
    white-space: nowrap;
}

.user-item .platform-badge {
    font-size: 0.65rem;
    padding: 0.15rem 0.45rem;
}

.user-last-message {
    font-size: 0.8125rem;
    color: var(--chat-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.user-item.unread .user-last-message {
    font-weight: 600;
    color: var(--chat-text-primary);
}

.user-badges {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.badge-sm {
    font-size: 0.6875rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.badge-ai {
    background: var(--chat-success);
    color: #ffffff;
}

.badge-followup {
    background: var(--chat-warning);
    color: var(--chat-text-primary);
}

.badge-purchased {
    background: var(--chat-success);
    color: #ffffff;
}

.user-tags {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-top: 0.25rem;
}

.tag-badge {
    font-size: 0.6875rem;
    padding: 2px 6px;
    border-radius: 10px;
    background: var(--chat-bg-app);
    color: var(--chat-text-secondary);
    border: 1px solid var(--chat-border-color);
}

.unread-count {
    position: absolute;
    top: 50%;
    right: 0.85rem;
    transform: translateY(-50%);
    background: var(--chat-primary);
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    min-width: 20px;
    text-align: center;
    animation: pulse-unread 2s infinite;
}

@keyframes pulse-unread {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(74, 111, 165, 0.3);
    }

    50% {
        box-shadow: 0 0 0 4px rgba(74, 111, 165, 0);
    }
}

/* ========================================
   Main Chat Area
   ======================================== */

.chat-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--chat-bg-chat);
}

/* ========================================
   Order Sidebar (Right Panel)
   ======================================== */

.order-sidebar {
    width: 340px;
    flex-shrink: 0;
    background: var(--chat-bg-sidebar);
    border-left: 1px solid var(--chat-border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.order-sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: radial-gradient(circle at top, rgba(var(--primary-rgb, 74, 111, 165), 0.08), transparent 48%);
    pointer-events: none;
}

.order-sidebar-header {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--chat-border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--chat-header-height);
    background: linear-gradient(135deg, rgba(var(--primary-rgb, 74, 111, 165), 0.12), rgba(var(--info-rgb, 61, 127, 193), 0.06));
    position: relative;
    z-index: 1;
}

.order-sidebar-heading {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.order-sidebar-eyebrow {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--chat-text-tertiary);
}

.order-sidebar-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
    color: var(--chat-text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-family-heading, 'Prompt', sans-serif);
}

.order-sidebar-title i {
    color: var(--chat-primary);
}

.order-sidebar-body {
    position: relative;
    z-index: 1;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(var(--primary-rgb, 74, 111, 165), 0.05), transparent 35%);
}

.order-panel {
    background: var(--chat-bg-sidebar);
    border: 1px solid var(--chat-border-color);
    border-radius: 14px;
    box-shadow: var(--chat-shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.order-panel-header {
    padding: 0.6rem 0.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(var(--primary-rgb, 74, 111, 165), 0.06);
}

.order-panel-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--chat-text-primary);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.order-panel-title i {
    color: var(--chat-primary);
}

.order-panel-action {
    border-radius: 999px;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
}

/* Legacy panel classes — replaced by info-sec system in chat-ui-v2.css */
/* Keeping order-content since renderOrders() fills #orderContent */
.order-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-height: 0;
}

.order-content::-webkit-scrollbar { width: 4px; }
.order-content::-webkit-scrollbar-track { background: transparent; }
.order-content::-webkit-scrollbar-thumb { background: var(--chat-border-color); border-radius: 2px; }
.order-content::-webkit-scrollbar-thumb:hover { background: var(--chat-text-tertiary); }

.customer-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.3rem;
    color: var(--chat-text-tertiary);
    padding: 0.75rem;
}

.customer-empty-icon {
    font-size: 2rem;
    opacity: 0.5;
}

.customer-empty-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--chat-text-secondary);
}

.customer-empty-desc {
    font-size: 0.75rem;
}

.customer-overview {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.customer-identity {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.65rem;
}

.customer-identity-main {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
}

.customer-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--chat-text-primary);
    word-break: break-word;
}

.customer-subline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    color: var(--chat-text-tertiary);
}

.customer-id {
    font-weight: 600;
    color: var(--chat-text-secondary);
}

.customer-dot {
    opacity: 0.6;
}

.customer-platform {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    border: 1px solid rgba(var(--primary-rgb, 74, 111, 165), 0.2);
    background: rgba(var(--primary-rgb, 74, 111, 165), 0.12);
    color: var(--chat-primary);
}

.customer-platform i {
    font-size: 0.75rem;
}

.customer-platform.platform-line {
    background: rgba(6, 199, 85, 0.12);
    border-color: rgba(6, 199, 85, 0.3);
    color: var(--chat-line);
}

.customer-platform.platform-facebook {
    background: rgba(24, 119, 242, 0.12);
    border-color: rgba(24, 119, 242, 0.3);
    color: var(--chat-facebook);
}

.customer-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: flex-end;
}

.customer-badge {
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(var(--primary-rgb, 74, 111, 165), 0.12);
    color: var(--chat-primary);
    border: 1px solid rgba(var(--primary-rgb, 74, 111, 165), 0.2);
}

.customer-badge.is-success {
    background: rgba(var(--success-rgb, 45, 143, 111), 0.16);
    color: var(--chat-success);
    border-color: rgba(var(--success-rgb, 45, 143, 111), 0.35);
}

.customer-badge.is-warning {
    background: rgba(var(--warning-rgb, 223, 169, 75), 0.16);
    color: var(--chat-warning);
    border-color: rgba(var(--warning-rgb, 223, 169, 75), 0.4);
}

.customer-badge.is-muted {
    background: rgba(92, 99, 114, 0.12);
    border-color: rgba(92, 99, 114, 0.25);
    color: var(--chat-text-secondary);
}

.customer-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem;
}

.metric-tile {
    background: var(--chat-bg-app);
    border: 1px solid var(--chat-border-color);
    border-radius: 8px;
    padding: 0.32rem 0.4rem;
    text-align: center;
    transition: all 0.2s ease;
}

.metric-tile:hover {
    transform: translateY(-1px);
    box-shadow: var(--chat-shadow-sm);
}

.metric-label {
    display: block;
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--chat-text-tertiary);
}

.metric-value {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--chat-text-primary);
    margin-top: 0.05rem;
}

.customer-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
}

.customer-meta-item {
    background: rgba(var(--primary-rgb, 74, 111, 165), 0.05);
    border: 1px dashed rgba(var(--primary-rgb, 74, 111, 165), 0.2);
    border-radius: 8px;
    padding: 0.3rem 0.5rem;
    transition: all 0.2s ease;
}

.customer-meta-item:hover {
    background: rgba(var(--primary-rgb, 74, 111, 165), 0.08);
    border-color: rgba(var(--primary-rgb, 74, 111, 165), 0.3);
}

.customer-meta-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--chat-text-tertiary);
}

.customer-meta-value {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--chat-text-primary);
    margin-top: 0.1rem;
}

.customer-message {
    padding: 0.45rem 0.6rem;
    border-radius: 8px;
    background: var(--chat-bg-hover);
    border: 1px solid var(--chat-border-color);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.customer-message-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--chat-text-tertiary);
}

.customer-message-text {
    font-size: 0.8rem;
    color: var(--chat-text-secondary);
    line-height: 1.4;
    word-break: break-word;
}

.customer-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.customer-tag {
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.68rem;
    border: 1px solid rgba(var(--primary-rgb, 74, 111, 165), 0.2);
    background: rgba(var(--primary-rgb, 74, 111, 165), 0.1);
    color: var(--chat-primary);
}

.customer-tag.is-empty {
    background: transparent;
    border-style: dashed;
    color: var(--chat-text-tertiary);
}

.customer-callout {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 0.4rem 0.55rem;
    border-radius: 8px;
    background: rgba(var(--warning-rgb, 223, 169, 75), 0.16);
    border: 1px solid rgba(var(--warning-rgb, 223, 169, 75), 0.35);
    color: var(--chat-text-secondary);
    font-size: 0.75rem;
}

.customer-callout i {
    color: var(--chat-warning);
    margin-top: 2px;
}

.customer-updated {
    font-size: 0.7rem;
    color: var(--chat-text-tertiary);
    text-align: right;
}

.notes-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 180px;
    overflow-y: auto;
}

.notes-list::-webkit-scrollbar { width: 3px; }
.notes-list::-webkit-scrollbar-thumb { background: var(--chat-border-color); border-radius: 2px; }

.note-item {
    position: relative;
    padding: 0.4rem 0.6rem 0.4rem 0.8rem;
    border-radius: 8px;
    border: 1px solid var(--chat-border-color);
    background: var(--chat-bg-sidebar);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    overflow: hidden;
}

.note-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: var(--chat-border-color);
    border-radius: 10px 0 0 10px;
}

.note-item.pinned {
    border-color: rgba(var(--warning-rgb, 223, 169, 75), 0.5);
    background: rgba(var(--warning-rgb, 223, 169, 75), 0.06);
}

.note-item.pinned::before {
    background: var(--chat-warning);
}

.note-content {
    font-size: 0.75rem;
    color: var(--chat-text-primary);
    white-space: pre-wrap;
    line-height: 1.45;
}

.note-meta {
    font-size: 0.63rem;
    color: var(--chat-text-tertiary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
}

.note-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.3rem;
}

.note-tools {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

/* Order Empty State */
.order-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 0.75rem;
    text-align: center;
    height: 100%;
    min-height: 130px;
    border: 1px dashed var(--chat-border-color);
    border-radius: 10px;
    background: rgba(var(--primary-rgb, 74, 111, 165), 0.04);
}

.order-empty-icon {
    font-size: 1.8rem;
    color: var(--chat-text-tertiary);
    margin-bottom: 0.4rem;
    opacity: 0.5;
}

.order-empty-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--chat-text-primary);
    margin-bottom: 0.2rem;
}

.order-empty-description {
    font-size: 0.72rem;
    color: var(--chat-text-secondary);
    line-height: 1.5;
    margin: 0;
}

/* Order Card */
.order-card {
    background: var(--chat-bg-sidebar);
    border: 1px solid var(--chat-border-color);
    border-radius: 10px;
    padding: 0.6rem;
    transition: var(--chat-transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    box-shadow: var(--chat-shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.order-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 4px;
    height: 100%;
    background: var(--chat-primary);
    opacity: 0.45;
}

.order-card.status-pending::before {
    background: var(--chat-warning);
}

.order-card.status-confirmed::before {
    background: var(--chat-info);
}

.order-card.status-shipped::before {
    background: var(--chat-primary);
}

.order-card.status-completed::before {
    background: var(--chat-success);
}

.order-card.status-cancelled::before {
    background: var(--chat-danger);
}

.order-card:hover {
    border-color: rgba(var(--primary-rgb, 74, 111, 165), 0.35);
    box-shadow: var(--chat-shadow);
    transform: translateY(-2px);
}

.order-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px dashed var(--chat-border-color);
}

.order-status-badge {
    font-size: 0.65rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border: 1px solid transparent;
}

.order-status-badge.pending {
    background: rgba(var(--warning-rgb, 223, 169, 75), 0.2);
    color: var(--chat-warning);
    border-color: rgba(var(--warning-rgb, 223, 169, 75), 0.45);
}

.order-status-badge.confirmed {
    background: rgba(var(--info-rgb, 61, 127, 193), 0.18);
    color: var(--chat-info);
    border-color: rgba(var(--info-rgb, 61, 127, 193), 0.35);
}

.order-status-badge.shipped {
    background: rgba(var(--primary-rgb), 0.16);
    color: var(--chat-primary);
    border-color: rgba(var(--primary-rgb, 74, 111, 165), 0.35);
}

.order-status-badge.completed {
    background: rgba(var(--success-rgb, 45, 143, 111), 0.18);
    color: var(--chat-success);
    border-color: rgba(var(--success-rgb, 45, 143, 111), 0.35);
}

.order-status-badge.cancelled {
    background: rgba(var(--danger-rgb, 210, 85, 90), 0.18);
    color: var(--chat-danger);
    border-color: rgba(var(--danger-rgb, 210, 85, 90), 0.35);
}

.order-date {
    font-size: 0.7rem;
    color: var(--chat-text-tertiary);
}

.order-items {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.order-item {
    font-size: 0.78rem;
    color: var(--chat-text-secondary);
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
}

.order-item::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--chat-primary-light);
    margin-top: 0.35rem;
    flex-shrink: 0;
}

.order-item-name {
    flex: 1;
    font-weight: 600;
    color: var(--chat-text-primary);
}

.order-item-quantity {
    color: var(--chat-text-tertiary);
    font-size: 0.72rem;
}

.order-item-price {
    color: var(--chat-primary);
    font-weight: 600;
    white-space: nowrap;
}

.order-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0.5rem;
    border-radius: 7px;
    border: 1px solid var(--chat-border-color);
    background: var(--chat-bg-hover);
    font-weight: 600;
}

.order-total.order-shipping {
    font-weight: 500;
    color: var(--chat-text-secondary);
    background: rgba(var(--primary-rgb, 74, 111, 165), 0.05);
}

.order-total.order-shipping .order-total-amount {
    color: var(--chat-text-primary);
    font-size: 0.9rem;
}

.order-total.order-shipping .order-total-amount.free {
    color: var(--chat-success);
    font-weight: 600;
}

.order-total-label {
    font-size: 0.78rem;
    color: var(--chat-text-secondary);
}

.order-total-amount {
    font-size: 0.92rem;
    color: var(--chat-success);
}

.order-meta {
    margin-top: 0.2rem;
    padding-top: 0.4rem;
    border-top: 1px solid var(--chat-border-color);
    font-size: 0.72rem;
    color: var(--chat-text-secondary);
    line-height: 1.4;
}

.order-meta-item {
    display: flex;
    align-items: flex-start;
    gap: 0.375rem;
    margin-bottom: 0.25rem;
}

.order-meta-item i {
    margin-top: 2px;
    font-size: 0.6875rem;
}

.order-meta-label {
    font-weight: 600;
    min-width: 65px;
}

.order-actions {
    display: flex;
    gap: 0.3rem;
    margin-top: 0.35rem;
}

.btn-order-action {
    flex: 1;
    background: var(--chat-bg-sidebar);
    border: 1px solid var(--chat-border-color);
    color: var(--chat-text-secondary);
    padding: 0.28rem 0.5rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--chat-transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
}

.btn-order-action:hover {
    background: var(--chat-primary);
    border-color: var(--chat-primary);
    color: #ffffff;
}

.btn-order-action.btn-delete {
    border-color: var(--chat-danger);
    color: var(--chat-danger);
}

.btn-order-action.btn-delete:hover {
    background: var(--chat-danger);
    color: #ffffff;
}

/* Order Badge in User Item */
.user-item .badge-has-order {
    background: var(--chat-warning);
    color: var(--chat-text-primary);
}

/* Order Form in Modal */
.order-form-group {
    margin-bottom: 1rem;
}

.order-form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--chat-text-primary);
    margin-bottom: 0.5rem;
}

.order-form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--chat-border-color);
    border-radius: var(--chat-border-radius);
    font-size: 0.875rem;
    color: var(--chat-text-primary);
    background: var(--chat-bg-app);
    transition: var(--chat-transition);
    font-family: var(--font-family-base, 'Prompt', sans-serif);
}

.order-form-control:focus {
    outline: none;
    border-color: var(--chat-primary);
    background: var(--bg-card, #FFFFFF);
}

.order-item-edit {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background: var(--chat-bg-app);
    border-radius: var(--chat-border-radius);
}

.order-item-edit input {
    flex: 1;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--chat-border-color);
    border-radius: var(--chat-border-radius);
    font-size: 0.8125rem;
}

.order-item-edit button {
    background: var(--chat-danger);
    border: none;
    color: #ffffff;
    padding: 0.375rem 0.5rem;
    border-radius: var(--chat-border-radius);
    cursor: pointer;
    font-size: 0.75rem;
}

.btn-add-item {
    width: 100%;
    background: var(--chat-primary);
    border: none;
    color: #ffffff;
    padding: 0.5rem;
    border-radius: var(--chat-border-radius);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: var(--chat-transition);
}

.btn-add-item:hover {
    background: var(--chat-primary-dark);
}

/* Chat Header */
.chat-header {
    min-height: var(--chat-header-height);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--chat-border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.6rem;
    flex-shrink: 0;
    position: relative;
}

.chat-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--chat-primary), transparent 60%);
    opacity: 0.3;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    min-width: 0;
}

.btn-toggle-sidebar {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--chat-text-secondary);
    cursor: pointer;
    padding: 0.55rem;
    border-radius: var(--chat-border-radius);
    transition: var(--chat-transition);
    min-width: 40px;
    min-height: 40px;
}

.btn-toggle-sidebar:hover {
    background: var(--chat-bg-hover);
    color: var(--chat-text-primary);
}

.chat-user-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    min-width: 0;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--chat-primary);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    flex-shrink: 0;
}

.chat-avatar.purchased {
    background: var(--chat-success);
}

.user-avatar,
.chat-avatar {
    position: relative;
    overflow: hidden;
}

.user-avatar img,
.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.user-avatar.has-image,
.chat-avatar.has-image {
    background: transparent;
    color: transparent;
}

.user-avatar.platform-line:not(.purchased),
.chat-avatar.platform-line:not(.purchased) {
    background: var(--chat-line);
}

.user-avatar.platform-facebook:not(.purchased),
.chat-avatar.platform-facebook:not(.purchased) {
    background: var(--chat-facebook);
}

.user-avatar.platform-line,
.chat-avatar.platform-line {
    box-shadow: 0 0 0 2px rgba(6, 199, 85, 0.35);
}

.user-avatar.platform-facebook,
.chat-avatar.platform-facebook {
    box-shadow: 0 0 0 2px rgba(24, 119, 242, 0.35);
}

.chat-user-details {
    flex: 1;
    min-width: 0;
}

.chat-user-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--chat-text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-user-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8125rem;
    color: var(--chat-text-secondary);
}

.chat-user-subtitle {
    font-size: 0.75rem;
    color: var(--chat-text-tertiary);
    margin-top: 0.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.meta-item i {
    font-size: 0.75rem;
}

.platform-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.platform-badge i {
    font-size: 0.75rem;
}

.platform-badge.is-line {
    background: rgba(6, 199, 85, 0.12);
    color: var(--chat-line);
    border-color: rgba(6, 199, 85, 0.3);
}

.platform-badge.is-facebook {
    background: rgba(24, 119, 242, 0.12);
    color: var(--chat-facebook);
    border-color: rgba(24, 119, 242, 0.3);
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-header-action {
    background: none;
    border: none;
    color: var(--chat-text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--chat-border-radius);
    transition: var(--chat-transition);
    font-size: 1rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-header-action:hover {
    background: var(--chat-bg-hover);
    color: var(--chat-primary);
    transform: scale(1.08);
}

.btn-header-action.btn-header-followup {
    width: auto;
    min-width: 132px;
    padding: 0 0.65rem;
    border: 1px solid var(--chat-border-color);
    border-radius: 999px;
    font-size: 0.74rem;
    gap: 0.35rem;
    background: var(--chat-bg-app);
}

.btn-header-action.btn-header-followup i {
    font-size: 0.76rem;
}

.btn-header-action.btn-header-followup span {
    line-height: 1;
    white-space: nowrap;
}

.btn-header-action.btn-header-followup.is-active {
    border-color: rgba(223, 169, 75, 0.55);
    color: #8b6707;
    background: rgba(223, 169, 75, 0.14);
}

.btn-header-action.btn-header-followup.is-inactive {
    border-color: rgba(92, 99, 114, 0.35);
    color: #505665;
    background: rgba(92, 99, 114, 0.08);
}

.btn-header-action.btn-header-followup.is-blocked {
    border-color: rgba(210, 85, 90, 0.4);
    color: var(--chat-danger);
    background: rgba(210, 85, 90, 0.08);
}

.btn-header-action.btn-header-followup:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-header-action.btn-danger:hover {
    background: var(--chat-danger);
    color: #ffffff;
}

.header-divider {
    width: 1px;
    height: 24px;
    background: var(--chat-border-color);
    margin: 0 0.5rem;
}

/* Messages Wrapper */
.messages-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--chat-bg-app);
    background-image: radial-gradient(rgba(74, 111, 165, 0.03) 1px, transparent 1px);
    background-size: 20px 20px;
}

.messages-wrapper,
.user-list,
.order-content {
    -webkit-overflow-scrolling: touch;
}

.messages-wrapper::-webkit-scrollbar {
    width: 8px;
}

.messages-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.messages-wrapper::-webkit-scrollbar-thumb {
    background: var(--chat-border-color);
    border-radius: 4px;
}

.messages-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--chat-text-tertiary);
}

.messages-container {
    padding: 1rem;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--chat-text-secondary);
    padding: 1rem;
}

.empty-icon {
    font-size: 4rem;
    color: var(--chat-primary);
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h5 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--chat-text-primary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.875rem;
    color: var(--chat-text-secondary);
    max-width: 400px;
}

/* Message */
.message {
    display: flex;
    margin-bottom: 0.75rem;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    justify-content: flex-start;
    align-items: flex-start;
}

.message.admin,
.message.assistant {
    justify-content: flex-end;
    align-items: flex-end;
}

.message-bubble {
    max-width: min(65%, 520px);
    padding: 0.625rem 0.875rem;
    border-radius: 16px;
    border: 1px solid transparent;
}

.message.user .message-bubble {
    background: var(--chat-bg-message-user);
    color: var(--chat-text-primary);
    border-left: 3px solid var(--chat-line);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.message.admin .message-bubble {
    background: linear-gradient(135deg, #4A6FA5, #5B83BA);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(74, 111, 165, 0.2);
}

.message.assistant .message-bubble {
    background: linear-gradient(135deg, #F3F0FF, #EDE9FE);
    color: var(--chat-text-primary);
    border-bottom-right-radius: 4px;
    border: 1px solid rgba(167, 139, 250, 0.25);
    border-right: 3px solid #A78BFA;
    box-shadow: 0 2px 8px rgba(167, 139, 250, 0.12);
}

.message-header {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.message.user .message-header {
    color: var(--chat-text-secondary);
}

.message.admin .message-header {
    color: rgba(255, 255, 255, 0.82);
}

.message.assistant .message-header {
    color: #7C3AED;
}

.message-content {
    font-size: 0.9375rem;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message-time {
    font-size: 0.6875rem;
    margin-top: 0.25rem;
    opacity: 0.7;
}

.message.user .message-time {
    color: var(--chat-text-tertiary);
}

.message.admin .message-time {
    color: rgba(255, 255, 255, 0.7);
}

.message.assistant .message-time {
    color: var(--chat-text-secondary);
}

/* Date separator */
.message-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin: 0.75rem 0;
    color: var(--chat-text-tertiary);
    font-size: 0.8125rem;
}

.message-separator::before,
.message-separator::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--chat-border-color);
    opacity: 0.6;
}

.message-images {
    margin-top: 0.5rem;
    display: grid;
    gap: 0.5rem;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.message-image {
    border-radius: var(--chat-border-radius);
    overflow: hidden;
    cursor: pointer;
    transition: var(--chat-transition);
}

.message-image:hover {
    opacity: 0.9;
    transform: scale(1.02);
}

.message-image img {
    width: 100%;
    height: auto;
    display: block;
    background: linear-gradient(135deg, var(--chat-bg-hover) 0%, var(--chat-bg-app) 100%);
    min-height: 60px;
}

.image-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--chat-bg-hover);
    border-radius: var(--chat-border-radius);
    color: var(--chat-text-tertiary);
    font-size: 0.75rem;
    gap: 0.25rem;
}

.image-error i {
    font-size: 1.5rem;
}

.message-videos {
    margin-top: 0.5rem;
    display: grid;
    gap: 0.5rem;
}

.message-video {
    border-radius: var(--chat-border-radius);
    border: 1px solid var(--chat-border-color);
    background: var(--chat-bg-app);
    padding: 0.4rem;
}

.message-video video {
    width: 100%;
    max-height: 260px;
    border-radius: 10px;
    background: #10131a;
}

.message-video-link {
    margin-top: 0.35rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    color: var(--chat-primary);
    text-decoration: none;
}

.message-video-link:hover {
    text-decoration: underline;
}

.message-attachments {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.message-attachment {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.6rem;
    border-radius: 10px;
    border: 1px solid var(--chat-border-color);
    background: var(--chat-bg-app);
    color: var(--chat-text-primary);
    text-decoration: none;
}

.message-attachment:hover {
    border-color: var(--chat-primary);
    color: var(--chat-primary);
}

.message-attachment-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(var(--primary-rgb, 74, 111, 165), 0.12);
    color: var(--chat-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.9rem;
}

.message-attachment-info {
    flex: 1;
    min-width: 0;
}

.message-attachment-name {
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-attachment-meta {
    font-size: 0.7rem;
    color: var(--chat-text-tertiary);
}

.message-feedback {
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.75rem;
    color: var(--chat-text-secondary);
}

.message-feedback .feedback-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 500;
    color: var(--chat-text-tertiary);
}

.message-feedback .feedback-label i {
    font-size: 0.75rem;
}

.message-feedback.has-feedback .feedback-label,
.message-feedback .feedback-label.active {
    color: var(--chat-text-secondary);
}

.feedback-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid var(--chat-border-color);
    background: var(--chat-bg-app);
    color: var(--chat-text-secondary);
    border-radius: 999px;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    transition: var(--chat-transition);
    cursor: pointer;
}

.feedback-btn i {
    font-size: 0.75rem;
}

.feedback-btn:hover {
    border-color: var(--chat-primary);
    color: var(--chat-primary);
}

.feedback-btn.positive.active {
    background: rgba(104, 185, 132, 0.12);
    border-color: var(--chat-success);
    color: var(--chat-success);
}

.feedback-btn.negative.active {
    background: rgba(255, 104, 104, 0.12);
    border-color: var(--chat-danger);
    color: var(--chat-danger);
}

.feedback-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.message-feedback.is-loading .feedback-btn {
    opacity: 0.6;
    pointer-events: none;
}

/* Typing indicator */
#typingIndicator .message-content {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chat-primary);
    display: inline-block;
    animation: typing-blink 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-blink {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.6;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========================================
   Message Input Area (Fixed at bottom)
   ======================================== */

.attachment-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--chat-bg-app);
    border: 1px solid var(--chat-border-color);
    border-radius: 12px;
    padding: 0.4rem 0.6rem;
    min-width: 0;
}

.attachment-thumb {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--chat-bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--chat-text-tertiary);
    flex-shrink: 0;
}

.attachment-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.attachment-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #10131a;
}

.attachment-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.attachment-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--chat-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.attachment-meta {
    font-size: 0.7rem;
    color: var(--chat-text-tertiary);
}

.attachment-remove {
    background: none;
    border: none;
    color: var(--chat-text-tertiary);
    padding: 0.35rem;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--chat-transition);
}

.attachment-remove:hover {
    background: var(--chat-bg-hover);
    color: var(--chat-text-primary);
}

.message-input-area {
    background: var(--chat-bg-sidebar);
    border-top: 1px solid var(--chat-border-color);
    padding: 0.55rem 0.7rem;
    flex-shrink: 0;
    padding-bottom: calc(0.55rem + env(safe-area-inset-bottom, 0px));
}

.message-input-container {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: var(--chat-bg-app);
    border-radius: 22px;
    padding: 0.4rem;
    border: 1.5px solid transparent;
    transition: all 0.25s ease;
}

.message-input-container:focus-within {
    border-color: rgba(74, 111, 165, 0.25);
    background: var(--chat-bg-hover);
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.06);
}

.btn-input-action {
    background: none;
    border: none;
    color: var(--chat-text-secondary);
    cursor: pointer;
    padding: 0.65rem;
    border-radius: 50%;
    transition: var(--chat-transition);
    font-size: 1.125rem;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-input-action:hover {
    background: rgba(74, 111, 165, 0.08);
    color: var(--chat-primary);
    transform: scale(1.08);
}

.message-input-wrapper {
    flex: 1;
    max-height: 120px;
    overflow-y: auto;
}

.message-input-wrapper::-webkit-scrollbar {
    width: 4px;
}

.message-input-wrapper::-webkit-scrollbar-thumb {
    background: var(--chat-border-color);
    border-radius: 2px;
}

.message-input {
    width: 100%;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    font-size: 0.9375rem;
    line-height: 1.4;
    color: var(--chat-text-primary);
    padding: 0.4rem 0;
    font-family: var(--font-family-base, 'Prompt', sans-serif);
}

.message-input::placeholder {
    color: var(--chat-text-tertiary);
}

.btn-send {
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-light));
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s ease;
    font-size: 1rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-send:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(74, 111, 165, 0.3);
}

.btn-send:active {
    transform: scale(0.95);
}

.message-input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--chat-text-tertiary);
}

.char-counter {
    font-weight: 500;
}

.input-hints {
    display: none;
}

/* ========================================
   Modals
   ======================================== */

.modal-content {
    border-radius: var(--chat-border-radius);
    border: none;
    box-shadow: var(--chat-shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--chat-border-color);
    padding: 1rem;
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.modal-body {
    padding: 1rem;
}

.modal-footer {
    border-top: 1px solid var(--chat-border-color);
    padding: 1rem;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-item {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    background: var(--chat-primary-light);
    color: var(--chat-primary);
    border-radius: 12px;
    font-size: 0.8125rem;
    font-weight: 500;
}

.tag-item .btn-remove-tag {
    background: none;
    border: none;
    color: var(--chat-primary);
    cursor: pointer;
    padding: 0;
    font-size: 0.875rem;
    line-height: 1;
    transition: var(--chat-transition);
}

.tag-item .btn-remove-tag:hover {
    color: var(--chat-danger);
}

.template-list {
    max-height: 400px;
    overflow-y: auto;
}

.template-item {
    padding: 0.75rem;
    border: 1px solid var(--chat-border-color);
    border-radius: var(--chat-border-radius);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: var(--chat-transition);
}

.template-item:hover {
    background: var(--chat-bg-hover);
    border-color: var(--chat-primary);
}

.template-title {
    font-weight: 600;
    color: var(--chat-text-primary);
    margin-bottom: 0.25rem;
}

.template-content {
    font-size: 0.8125rem;
    color: var(--chat-text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.template-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.template-actions .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* ========================================
   Sidebar Overlay (Mobile)
   ======================================== */

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* ========================================
   Responsive Design
   ======================================== */

@media (min-width: 992px) {
    .input-hints {
        display: block;
    }

    /* Desktop: refined scrollbars */
    .user-list::-webkit-scrollbar,
    .messages-wrapper::-webkit-scrollbar,
    .order-sidebar-body::-webkit-scrollbar {
        width: 5px;
    }

    .user-list::-webkit-scrollbar-thumb,
    .messages-wrapper::-webkit-scrollbar-thumb,
    .order-sidebar-body::-webkit-scrollbar-thumb {
        background: var(--chat-border-color);
        border-radius: 3px;
    }

    /* Desktop: sidebar hover depth */
    .chat-sidebar {
        transition: box-shadow 0.3s ease;
    }

    /* Desktop: right panel sections breathing room */
    .order-panel {
        transition: box-shadow 0.2s ease;
    }

    .order-panel:hover {
        box-shadow: var(--chat-shadow);
    }

    /* Desktop: order card subtle lift */
    .order-card {
        transition: all 0.2s ease;
    }

    /* Desktop: note items hover */
    .note-item:hover {
        box-shadow: var(--chat-shadow-sm);
        border-color: rgba(74, 111, 165, 0.2);
    }

    /* Desktop: template item hover scale */
    .template-item:hover {
        transform: translateY(-1px);
    }

    /* Desktop: quick action buttons grid */
    .customer-metrics .metric-card:hover {
        transform: translateY(-1px);
        box-shadow: var(--chat-shadow);
    }
}

@media (max-width: 991.98px) {
    .chat-sidebar {
        position: fixed;
        top: var(--chat-navbar-height);
        left: -100%;
        height: calc(100vh - var(--chat-navbar-height));
        z-index: 100;
        transition: left 0.3s ease;
        box-shadow: var(--chat-shadow-lg);
    }

    .chat-sidebar.show {
        left: 0;
    }

    .order-sidebar {
        position: fixed;
        top: var(--chat-navbar-height);
        right: -100%;
        height: calc(100vh - var(--chat-navbar-height));
        z-index: 101;
        transition: right 0.3s ease;
        box-shadow: var(--chat-shadow-lg);
        width: 92%;
        max-width: 360px;
    }

    .order-sidebar.show {
        right: 0;
    }

    .message-bubble {
        max-width: min(85%, 520px);
    }
}

@media (max-width: 575.98px) {
    :root {
        --chat-sidebar-width: 100%;
    }

    .app-content {
        padding: 0;
    }

    .chat-app-wrapper {
        padding: 0;
    }

    .chat-app {
        height: calc(100vh - var(--chat-navbar-height) - var(--mob-tabs-h, 42px));
        border-radius: 0;
        box-shadow: none;
    }

    /* When mob-chat-active is on (conversation view), fill full viewport */
    html.mob-chat-active .chat-app {
        height: 100vh;
        height: 100dvh;
    }

    .sidebar-header,
    .search-container,
    .filter-panel,
    .message-input-area {
        padding: 0.55rem;
    }

    /* Chat header: defer to chat-mobile.css for mobile sizing */
    .chat-header {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 0.5rem;
        padding: 0 0.5rem;
    }

    .chat-header-left {
        flex: 1 1 auto;
        min-width: 0;
    }

    .chat-header-right {
        flex: 0 0 auto;
        justify-content: flex-end;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 0;
        gap: 0.25rem;
    }

    .chat-header-right::-webkit-scrollbar {
        height: 3px;
    }

    .chat-header-right::-webkit-scrollbar-thumb {
        background: var(--chat-border-color);
        border-radius: 3px;
    }

    .header-divider {
        display: none;
    }

    .chat-user-meta {
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .messages-container {
        padding: 0.6rem;
    }

    .message-bubble {
        max-width: min(90%, 520px);
    }

    .user-item {
        padding: 0.6rem;
    }

    .user-avatar {
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }

    .chat-avatar {
        width: 36px;
        height: 36px;
        font-size: 0.875rem;
    }

    .btn-header-action {
        width: 34px;
        height: 34px;
    }

    .btn-header-action.btn-header-followup {
        width: auto;
        min-width: 118px;
        height: 34px;
        padding: 0 0.5rem;
        font-size: 0.68rem;
    }

    .btn-header-action.btn-header-followup span {
        max-width: 110px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .btn-input-action {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }

    .btn-send {
        width: 34px;
        height: 34px;
    }

    .message-input-container {
        gap: 0.35rem;
        padding: 0.35rem;
    }

    .message-input {
        font-size: 1rem;
    }

    .search-input {
        font-size: 1rem;
    }

    .attachment-thumb {
        width: 36px;
        height: 36px;
    }

    .attachment-name {
        max-width: 130px;
    }

    .filter-panel {
        max-height: 45vh;
        overflow-y: auto;
    }

    .user-list {
        max-height: none;
    }

    .order-sidebar {
        width: 100%;
        max-width: none;
    }

    .order-sidebar-body {
        padding: 0.6rem;
    }

    .customer-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .customer-meta {
        grid-template-columns: 1fr;
    }
}

@supports (height: 100dvh) {
    @media (max-width: 991.98px) {

        .chat-sidebar,
        .order-sidebar {
            height: calc(100dvh - var(--chat-navbar-height));
            height: calc(100dvh - var(--chat-navbar-height) - env(safe-area-inset-top, 0px));
        }
    }

    @media (max-width: 575.98px) {
        .chat-app {
            height: calc(100dvh - var(--chat-navbar-height) - var(--mob-tabs-h, 42px));
        }

        html.mob-chat-active .chat-app {
            height: 100dvh;
        }

        .user-list {
            max-height: none;
        }

        .message-input-area {
            padding-bottom: calc(0.55rem + env(safe-area-inset-bottom, 0px));
        }
    }
}

/* iOS Safe Area Support */
@supports (padding: max(0px)) {
    .chat-app {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .chat-sidebar,
    .order-sidebar {
        padding-top: env(safe-area-inset-top);
    }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {

    .chat-sidebar,
    .chat-header,
    .message-input-area {
        display: none;
    }

    .chat-main {
        width: 100%;
    }

    .messages-wrapper {
        overflow: visible;
    }
}