/* WhatsApp Chat Inbox Module */
.wa-chat-inbox .chat-inbox-page {
    --chat-primary: #059669;
    --chat-primary-soft: #d1fae5;
    --chat-success: #059669;
    --chat-warning: #f59e0b;
    --chat-danger: #dc2626;
    --chat-info: #0891b2;
    --chat-ink: #064e3b;
    --chat-muted: #64748b;
    --chat-bg: #f0fdf4;
    padding: 1.25rem;
    background:
        radial-gradient(circle at 8% -5%, rgba(5, 150, 105, 0.10), transparent 35%),
        radial-gradient(circle at 92% 0%, rgba(16, 185, 129, 0.09), transparent 33%),
        var(--chat-bg);
    border-radius: 1rem;
}

.wa-chat-inbox .chat-title {
    color: var(--chat-ink);
}

.wa-chat-inbox .chat-subtitle {
    color: var(--chat-muted);
}

.wa-chat-inbox .chat-card {
    border: 1px solid rgba(5, 150, 105, 0.15);
    border-radius: 0.9rem;
    background: #fff;
    box-shadow: 0 8px 24px rgba(6, 78, 59, 0.05);
}

.wa-chat-inbox .chat-list-panel {
    border-right: 1px solid rgba(5, 150, 105, 0.1);
    height: 600px;
    display: flex;
    flex-direction: column;
}

.wa-chat-inbox .chat-side-panel {
    display: flex;
    flex-direction: column;
    height: 600px;
    gap: 0.75rem;
}

.wa-chat-inbox .chat-side-panel > .chat-card {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin-top: 0 !important;
}

.wa-chat-inbox .chat-side-panel > .chat-card > .card-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.wa-chat-inbox .chat-search-header {
    padding: 0.8rem;
    border-bottom: 1px solid rgba(5, 150, 105, 0.1);
    background: linear-gradient(180deg, rgba(5, 150, 105, 0.04), transparent);
    flex-shrink: 0;
}

.wa-chat-inbox .chat-list-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.wa-chat-inbox .chat-list-item {
    padding: 0.85rem;
    border-bottom: 1px solid rgba(5, 150, 105, 0.08);
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    gap: 0.8rem;
}

.wa-chat-inbox .chat-list-item:hover {
    background: #f0fdf4;
}

.wa-chat-inbox .chat-list-item.active {
    background: rgba(5, 150, 105, 0.08);
    border-left: 3px solid #059669;
}

.wa-chat-inbox .chat-list-item.unread {
    background: rgba(5, 150, 105, 0.03);
}

.wa-chat-inbox .chat-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #059669, #10b981);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
    flex-shrink: 0;
}

.wa-chat-inbox .chat-avatar.agent {
    background: linear-gradient(135deg, #7c3aed, #8b5cf6);
}

.wa-chat-inbox .chat-info {
    flex: 1;
    min-width: 0;
}

.wa-chat-inbox .chat-name {
    font-weight: 600;
    color: var(--chat-ink);
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-chat-inbox .chat-preview {
    color: var(--chat-muted);
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-chat-inbox .chat-meta {
    text-align: right;
    flex-shrink: 0;
}

.wa-chat-inbox .chat-time {
    color: var(--chat-muted);
    font-size: 0.75rem;
    margin-bottom: 0.3rem;
}

.wa-chat-inbox .chat-unread-badge {
    display: inline-block;
    background: #059669;
    color: #fff;
    border-radius: 10px;
    padding: 0.1rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 700;
}

.wa-chat-inbox .chat-status-badge {
    padding: 0.2rem 0.5rem;
    border-radius: 0.35rem;
    font-size: 0.72rem;
    font-weight: 600;
    display: inline-block;
}

.wa-chat-inbox .chat-status-badge.open {
    background: #d1fae5;
    color: #065f46;
}

.wa-chat-inbox .chat-status-badge.assigned {
    background: #dbeafe;
    color: #1e40af;
}

.wa-chat-inbox .chat-status-badge.pending {
    background: #fef3c7;
    color: #92400e;
}

.wa-chat-inbox .chat-conversation-panel {
    height: 600px;
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 0;
    overflow: hidden;
}

.wa-chat-inbox .chat-header {
    padding: 0.75rem;
    border-bottom: 1px solid rgba(5, 150, 105, 0.1);
    background: #fff;
    grid-row: 1;
    /* Override rocker.css conflicting rules */
    position: static !important;
    height: auto !important;
    left: unset !important;
    right: unset !important;
    top: unset !important;
    z-index: unset !important;
}

.wa-chat-inbox .chat-messages-area {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    background: #fafafa;
    min-height: 0;
    grid-row: 2;
}

.wa-chat-inbox .chat-bubble {
    max-width: 65%;
    margin-bottom: 1rem;
    display: flex;
    gap: 0.6rem;
}

.wa-chat-inbox .chat-bubble.incoming {
    justify-content: flex-start;
}

.wa-chat-inbox .chat-bubble.outgoing {
    justify-content: flex-end;
    flex-direction: row-reverse;
}

.wa-chat-inbox .chat-bubble-content {
    padding: 0.7rem 1rem;
    border-radius: 1rem;
    font-size: 0.88rem;
    line-height: 1.5;
}

.wa-chat-inbox .chat-bubble.incoming .chat-bubble-content {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 0.3rem;
}

.wa-chat-inbox .chat-bubble.outgoing .chat-bubble-content {
    background: #059669;
    color: #fff;
    border-bottom-right-radius: 0.3rem;
}

.wa-chat-inbox .chat-bubble-time {
    font-size: 0.72rem;
    color: var(--chat-muted);
    margin-top: 0.3rem;
}

.wa-chat-inbox .chat-bubble.outgoing .chat-bubble-time {
    text-align: right;
    color: rgba(255, 255, 255, 0.8);
}

.wa-chat-inbox .chat-input-area {
    padding: 1rem;
    border-top: 1px solid rgba(5, 150, 105, 0.1);
    background: #fff;
    grid-row: 3;
}

.wa-chat-inbox .chat-input-box {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}

.wa-chat-inbox .chat-input-box textarea {
    flex: 1;
    border: 1px solid rgba(5, 150, 105, 0.2);
    border-radius: 0.7rem;
    padding: 0.7rem;
    resize: none;
    font-size: 0.88rem;
}

.wa-chat-inbox .chat-input-box textarea:focus {
    outline: none;
    border-color: #059669;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

.wa-chat-inbox .chat-sla-bar {
    padding: 0.5rem 0.75rem;
    background: #fffbeb;
    border-left: 3px solid #f59e0b;
    border-radius: 0.5rem;
    font-size: 0.84rem;
    margin-top: 0.5rem;
}

.wa-chat-inbox .chat-sla-bar.critical {
    background: #fef2f2;
    border-color: #dc2626;
    color: #991b1b;
}

.wa-chat-inbox .chat-agent-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: background 0.15s;
}

.wa-chat-inbox .chat-agent-item:hover {
    background: #f0fdf4;
}

.wa-chat-inbox .chat-agent-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid #fff;
}

.wa-chat-inbox .chat-agent-status.online {
    background: #059669;
}

.wa-chat-inbox .chat-agent-status.away {
    background: #f59e0b;
}

.wa-chat-inbox .chat-agent-status.offline {
    background: #9ca3af;
}

.wa-chat-inbox .chat-stats-box {
    border-radius: 0.7rem;
    background: linear-gradient(135deg, rgba(5, 150, 105, 0.06), rgba(16, 185, 129, 0.06));
    border: 1px solid rgba(5, 150, 105, 0.18);
    padding: 0.8rem;
    text-align: center;
}

.wa-chat-inbox .chat-stats-box .label {
    color: var(--chat-muted);
    font-size: 0.76rem;
    margin-bottom: 0.3rem;
}

.wa-chat-inbox .chat-stats-box .value {
    color: var(--chat-ink);
    font-size: 1.3rem;
    font-weight: 700;
}

.wa-chat-inbox .chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--chat-muted);
    text-align: center;
    padding: 2rem;
}

.wa-chat-inbox .chat-empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: rgba(5, 150, 105, 0.3);
}

/* ============================================================
   DARK MODE
   ============================================================ */
html.dark-theme .wa-chat-inbox .chat-inbox-page {
    --chat-ink: #a7f3d0;
    --chat-muted: #94a3b8;
    --chat-bg: #0d1f17;
    background:
        radial-gradient(circle at 8% -5%, rgba(5, 150, 105, 0.12), transparent 35%),
        radial-gradient(circle at 92% 0%, rgba(16, 185, 129, 0.10), transparent 33%),
        var(--chat-bg);
}

html.dark-theme .wa-chat-inbox .chat-title {
    color: #a7f3d0;
}

html.dark-theme .wa-chat-inbox .chat-subtitle {
    color: #94a3b8;
}

html.dark-theme .wa-chat-inbox .chat-card {
    background: #111b15;
    border: 1px solid rgba(5, 150, 105, 0.2);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* Chat List Panel */
html.dark-theme .wa-chat-inbox .chat-list-panel {
    border-right: 1px solid rgba(5, 150, 105, 0.15);
}

html.dark-theme .wa-chat-inbox .chat-search-header {
    background: rgba(5, 150, 105, 0.06);
    border-bottom: 1px solid rgba(5, 150, 105, 0.15);
}

html.dark-theme .wa-chat-inbox .chat-search-header .form-control {
    background: #1a2e22;
    border-color: rgba(5, 150, 105, 0.25);
    color: #e4e5e6;
}

html.dark-theme .wa-chat-inbox .chat-search-header .form-control::placeholder {
    color: #64748b;
}

html.dark-theme .wa-chat-inbox .chat-list-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

html.dark-theme .wa-chat-inbox .chat-list-item:hover {
    background: rgba(5, 150, 105, 0.1);
}

html.dark-theme .wa-chat-inbox .chat-list-item.active {
    background: rgba(5, 150, 105, 0.15);
    border-left-color: #10b981;
}

html.dark-theme .wa-chat-inbox .chat-list-item.unread {
    background: rgba(5, 150, 105, 0.07);
}

html.dark-theme .wa-chat-inbox .chat-name {
    color: #e2e8f0;
}

html.dark-theme .wa-chat-inbox .chat-preview {
    color: #64748b;
}

html.dark-theme .wa-chat-inbox .chat-time {
    color: #64748b;
}

/* Conversation Panel */
html.dark-theme .wa-chat-inbox .chat-header {
    background: #111b15;
    border-bottom: 1px solid rgba(5, 150, 105, 0.15);
}

html.dark-theme .wa-chat-inbox .chat-messages-area {
    background: #0d1a14;
}

html.dark-theme .wa-chat-inbox .chat-bubble.incoming .chat-bubble-content {
    background: #1a2e22;
    border-color: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
}

html.dark-theme .wa-chat-inbox .chat-bubble.outgoing .chat-bubble-content {
    background: #065f46;
    color: #fff;
}

html.dark-theme .wa-chat-inbox .chat-bubble-time {
    color: #64748b;
}

html.dark-theme .wa-chat-inbox .chat-input-area {
    background: #111b15;
    border-top: 1px solid rgba(5, 150, 105, 0.15);
}

html.dark-theme .wa-chat-inbox .chat-input-box textarea {
    background: #1a2e22;
    border-color: rgba(5, 150, 105, 0.25);
    color: #e2e8f0;
}

html.dark-theme .wa-chat-inbox .chat-input-box textarea::placeholder {
    color: #64748b;
}

html.dark-theme .wa-chat-inbox .chat-input-box textarea:focus {
    border-color: #059669;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

/* SLA Bar */
html.dark-theme .wa-chat-inbox .chat-sla-bar {
    background: rgba(245, 158, 11, 0.1);
    border-left-color: #f59e0b;
    color: #fcd34d;
}

html.dark-theme .wa-chat-inbox .chat-sla-bar.critical {
    background: rgba(220, 38, 38, 0.1);
    border-color: #dc2626;
    color: #fca5a5;
}

/* Agents */
html.dark-theme .wa-chat-inbox .chat-agent-item:hover {
    background: rgba(5, 150, 105, 0.1);
}

html.dark-theme .wa-chat-inbox .chat-agent-item .fw-semibold {
    color: #e2e8f0;
}

html.dark-theme .wa-chat-inbox .chat-agent-item .text-muted {
    color: #64748b !important;
}

/* Stats Box */
html.dark-theme .wa-chat-inbox .chat-stats-box {
    background: linear-gradient(135deg, rgba(5, 150, 105, 0.1), rgba(16, 185, 129, 0.08));
    border: 1px solid rgba(5, 150, 105, 0.25);
}

html.dark-theme .wa-chat-inbox .chat-stats-box .label {
    color: #94a3b8;
}

html.dark-theme .wa-chat-inbox .chat-stats-box .value {
    color: #a7f3d0;
}

/* Empty State */
html.dark-theme .wa-chat-inbox .chat-empty-state {
    color: #64748b;
}

/* Status Badges */
html.dark-theme .wa-chat-inbox .chat-status-badge.open {
    background: rgba(5, 150, 105, 0.2);
    color: #6ee7b7;
}

html.dark-theme .wa-chat-inbox .chat-status-badge.assigned {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
}

html.dark-theme .wa-chat-inbox .chat-status-badge.pending {
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
}

/* Card header/footer in agents & SLA panels */
html.dark-theme .wa-chat-inbox .chat-card .card-header {
    background: #111b15;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: #a7f3d0;
}

html.dark-theme .wa-chat-inbox .chat-card .card-body {
    background: #111b15;
}

html.dark-theme .wa-chat-inbox .chat-side-panel > .chat-card {
    background: #111b15;
    border-color: rgba(5, 150, 105, 0.2);
}
