:root {
    --primary: #00a884; /* WhatsApp Teal */
    --primary-hover: #008f72;
    --primary-color: #00a884; 
    --primary-dark: #008f72;
    --secondary-color: #f1f5f9; 
    --secondary: #64748b;
    --text-dark: #0f172a; 
    --text-light: #64748b; 
    --sidebar-bg: #ffffff;
    --bg-color: #f8fafc; /* App background */
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #f59e0b;
    --border-color: #e2e8f0;
    --border-radius: 0.5rem; /* A modern, slightly larger radius */
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-dark);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    padding: 1rem;
    transition: width 0.3s ease;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar.collapsed {
    width: 80px;
}

.sidebar.collapsed .sidebar-header span,
.sidebar.collapsed .nav-links li span,
.sidebar.collapsed .sidebar-footer .user-info {
    display: none;
}

.sidebar.collapsed .nav-links li {
    justify-content: center;
    padding: 0.75rem 0;
}

.sidebar.collapsed .nav-links li i {
    margin: 0;
}

.sidebar-header {
    padding: 1rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.btn-sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    color: var(--text-light);
    padding: 5px;
    border-radius: 4px;
}

.btn-sidebar-toggle:hover {
    background: var(--secondary-color);
    color: var(--primary-color);
}

.sidebar-header i {
    color: var(--primary-color);
}

.nav-links {
    list-style: none;
    padding: 0;
    margin-top: 1rem;
}

.nav-links li {
    padding: 0.75rem 1rem;
    margin-bottom: 0.25rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    color: var(--text-light);
    font-weight: 500;
    transition: all 0.2s ease-in-out;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-links li:hover {
    color: var(--primary-color);
    background-color: var(--secondary-color);
}

.nav-links li.active {
    background-color: var(--primary-color);
    color: white;
}

.nav-links li i {
    width: 20px;
    font-size: 1.1rem;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.view {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-dark);
}

.content-panel {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

/* Toolbar & Search */
.toolbar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

input[type="text"],
input[type="password"],
select {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--bg-color);
    outline: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    color: var(--text-dark);
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
    border-color: var(--primary-color);
    background-color: white;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.btn-primary, .btn-secondary, .btn-danger {
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--secondary-color);
    border: 1px solid var(--border-color);
    color: var(--text-dark);
}

.btn-secondary:hover {
    background-color: #e2e8f0;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}
.btn-danger:hover {
    background-color: #b91c1c;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    gap: 0.25rem;
}

/* Tables */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    color: var(--text-light);
    font-weight: 600;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--secondary-color);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    padding: 1rem;
    color: var(--text-dark);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background-color: var(--bg-color);
}

/* Status Badges */
.status {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
}
.status-completed { color: var(--success); background: #dcfce7; }
.status-processing { color: var(--warning); background: #fef3c7; }
.status-cancelled { color: var(--danger); background: #fee2e2; }

/* Dashboard Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.stat-card h3 {
    margin-bottom: 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-light);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-color);
    padding: 0;
    border-radius: var(--border-radius);
    width: 95%;
    max-width: 1200px;
    max-height: 95vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: var(--shadow-lg);
    font-family: 'Inter', -apple-system, sans-serif;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-dark);
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    transition: color 0.2s;
}
.close-modal:hover {
    color: var(--text-dark);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex-grow: 1;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.flex-1 {
    flex: 1;
}

/* User Status Badges */
.availability-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.availability-indicator.online {
    color: var(--success);
}

.availability-indicator.offline {
    color: var(--secondary);
}

.availability-indicator .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.availability-indicator.online .status-dot {
    background: var(--success);
    box-shadow: 0 0 5px var(--success);
}

.availability-indicator.offline .status-dot {
    background: var(--secondary);
}

/* --- WooCommerce Style Order Details --- */
/* This section is kept largely for its specific layout, but colors and fonts are adapted */
.wc-order-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.wc-order-header h2 {
    margin: 0 0 5px 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-dark);
}

.wc-order-meta-line {
    font-size: 0.9rem;
    color: var(--text-light);
}

.wc-order-body {
    padding: 1.5rem;
    background-color: #fff;
}

.wc-columns {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.wc-column {
    flex: 1;
    min-width: 200px;
}

.wc-column h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-top: 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.wc-address-block p {
    margin: 0;
    line-height: 1.6;
    font-size: 0.9rem;
    color: var(--text-light);
}

.wc-address-block a {
    color: var(--primary-color);
    text-decoration: none;
}

.wc-address-block a:hover {
    text-decoration: underline;
}

.wc-field-group {
    margin-bottom: 1rem;
}

.wc-field-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.wc-field-value {
    font-size: 0.9rem;
    color: var(--text-dark);
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    width: 100%;
}

.wc-field-value.read-only {
    background: var(--secondary-color);
}

.wc-items-table {
    width: 100%;
    border-collapse: separate; 
    border-spacing: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    background: #fff;
}

.wc-items-table th {
    background: var(--secondary-color);
    color: var(--text-light);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.wc-items-table th.col-total {
    text-align: right;
}

.wc-items-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.wc-items-table tr:last-child td {
    border-bottom: none;
}

.wc-item-info {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.wc-item-thumb {
    width: 48px;
    height: 48px;
    border-radius: 0.375rem;
    background: var(--secondary-color);
    border: 1px solid var(--border-color);
    object-fit: cover;
}

.wc-item-name a {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
    font-size: 0.95rem;
}

.wc-item-meta {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-light);
}

.wc-item-meta-row {
    display: flex;
    margin-bottom: 0.25rem;
}

.wc-meta-key {
    font-weight: 600;
    margin-right: 0.5rem;
}

.wc-totals-area {
    display: flex;
    justify-content: flex-end;
    background: var(--secondary-color);
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

.wc-totals-table {
    width: 350px;
}

.wc-totals-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-size: 0.9rem;
    color: var(--text-light);
}

.wc-totals-label {
    text-align: right;
    padding-right: 1.5rem;
}

.wc-totals-value {
    text-align: right;
    width: 120px;
    color: var(--text-dark);
    font-weight: 500;
}

.wc-totals-row.final-total {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-dark);
    border-top: 1px solid var(--border-color);
    margin-top: 0.75rem;
    padding-top: 0.75rem;
}

/* --- End WC Style --- */

/* Utilities */
.hidden { display: none !important; }
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
}

/* Settings Cards */
.sync-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.sync-card {
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    background: #fff;
}

.sync-card h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem; 
    color: var(--text-dark);
    font-weight: 600;
}

.sync-card p {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    min-height: 40px;
}

/* --- Chat Application Styles (WhatsApp Web Clone) --- */
/* Adapted to the new design system */

.chat-container {
    display: flex;
    height: 100%;
    background: #fff;
    border-radius: 0;
    overflow: hidden;
    position: relative;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.chat-sidebar {
    width: 320px; /* Fixed initial width, will be overridden by JS */
    min-width: 280px;
    max-width: 500px;
    background: #fff;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

/* Sidebar Copycat Section */
.sidebar-top {
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    min-height: 59px;
}

.sidebar-top h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
    color: #111b21;
}

.sidebar-top-actions {
    display: flex;
    gap: 8px;
}

.chat-search-container {
    padding: 8px 12px;
}

.chat-search {
    background: #f0f2f5;
    border-radius: 8px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    height: 35px;
}

.chat-search i {
    color: #54656f;
    font-size: 0.85rem;
    margin-right: 15px;
}

.chat-search input {
    background: transparent !important;
    border: none !important;
    flex: 1;
    font-size: 0.9rem;
    color: #3b4a54;
    outline: none;
    padding: 0 !important;
}

.chat-filters {
    padding: 0 12px 12px 12px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
}

.chat-filters::-webkit-scrollbar { display: none; }

.filter-pill {
    background: #f0f2f5;
    border: none;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.85rem;
    color: #54656f;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}

.filter-pill:hover {
    background: #e9edef;
}

.filter-pill.active {
    background: #d9fdd3;
    color: #008069;
    font-weight: 500;
}

.label-filter-pill {
    padding: 6px 12px;
    border-radius: 16px;
    background: #f0f2f5;
    border: none;
    color: #54656f;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.label-filter-pill:hover {
    background: #e9edef;
}

.label-filter-pill.active {
    background: #008069;
    color: white;
}

#labelFilterBar {
    scrollbar-width: none;
    display: flex;
    overflow-x: auto;
    gap: 8px;
}
#labelFilterBar::-webkit-scrollbar {
    display: none;
}

.resizer {
    width: 4px;
    cursor: col-resize;
    background: transparent;
    transition: background 0.2s;
    z-index: 10;
}

.resizer:hover, .resizer.resizing {
    background: var(--primary-color);
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f0f2f5;
    min-width: 400px;
}

.chat-context-panel {
    width: 380px; /* Fixed initial width, will be overridden by JS */
    min-width: 300px;
    max-width: 600px;
    background: #fff;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.chat-search {
    background: #fff;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
}

.chat-search input {
    width: 100%;
    padding: 0.6rem 1rem;
    border: none;
    background: var(--secondary-color);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    color: var(--text-dark);
    outline: none;
}
.chat-search input::placeholder { color: var(--text-light); }

.conversation-list {
    flex: 1;
    overflow-y: auto;
    background: #fff;
}

.conversation-item {
    height: 72px;
    padding: 0 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    background: #fff;
    position: relative;
    transition: background-color 0.2s;
    border-bottom: 0.5px solid #f5f6f6;
}

.conversation-item:hover {
    background: #f5f6f6;
}

.conversation-item.active {
    background: #f0f2f5 !important;
}

.conversation-item.active .name,
.conversation-item.active .time,
.conversation-item.active .last-msg {
    color: #111b21 !important;
}

.conversation-item .avatar {
    width: 49px;
    height: 49px;
    background: #dfe5e7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.2rem;
    font-weight: 500;
    margin-right: 15px;
    flex-shrink: 0;
}

.conversation-item .details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: center;
}

.conversation-item .top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 2px;
}

.conversation-item .name {
    font-size: 1.05rem;
    color: #111b21;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-item .time {
    font-size: 0.75rem;
    color: #667781;
}

.conversation-item.has-unread .time {
    color: #1fa855;
    font-weight: 700;
}

.conversation-item.has-unread .last-msg {
    color: var(--text-dark);
    font-weight: 600;
}

.conversation-item .bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conversation-item .last-msg {
    font-size: 0.88rem;
    color: #667781;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    margin-right: 8px;
}

.conversation-item .badge {
    background: #25d366;
    color: #fff;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.unread-badge {
    background: var(--success);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.5rem;
}

.chat-header {
    height: 70px;
    background: #fff;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    z-index: 2;
}

.chat-user-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.chat-user-info h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 2px;
}

#chatHeaderLabels {
    display: flex;
    gap: 4px;
}

.chat-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.chat-actions .btn-icon:hover {
    background: rgba(0,0,0,0.05);
}

/* Label Selector UI */
.label-selector-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.label-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.label-option:hover {
    background: #f8fafc;
}

.label-option.selected {
    border-color: var(--primary);
    background: #f0fdfa;
}

.label-option input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.label-color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.label-option-text {
    flex: 1;
    font-weight: 500;
    font-size: 0.95rem;
}

.meta-indicators {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.label-pill {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    color: white;
    text-transform: uppercase;
    white-space: nowrap;
}

.messages-area {
    flex: 1;
    padding: 10px 5%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #efeae2;
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    background-repeat: repeat;
    background-attachment: fixed;
}

/* Base message container - acts as a row */
.message {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin-bottom: 2px;
    padding: 0;
}

.message.sent {
    align-items: flex-end;
}

.message.received {
    align-items: flex-start;
}

/* The actual bubble */
.bubble {
    max-width: 65%;
    padding: 6px 7px 8px 9px;
    border-radius: 7.5px;
    position: relative;
    box-shadow: 0 1px 0.5px rgba(11,20,26,.13);
    font-size: 0.9rem;
    line-height: normal;
    display: flex;
    flex-direction: column;
    background: #fff;
    transition: background 0.2s;
    word-break: break-word;
}

.message.received .bubble {
    border-top-left-radius: 0;
    background: #fff;
}

/* System Audit Messages */
.message.system-audit {
    display: flex;
    justify-content: center;
    margin: 1rem 0;
    width: 100%;
}

.system-audit-bubble {
    background: #eef2f5;
    color: #54656f;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 12px;
    box-shadow: 0 1px 1px rgba(0,0,0,0.05);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message.sent .bubble {
    background: #d9fdd3;
    border-top-right-radius: 0;
}

/* Highlighting Search Results */
mark {
    background: #ffeb3b;
    color: #000;
    padding: 0 2px;
    border-radius: 2px;
}

/* Bubble Action Menu (Reply) - Layered Architecture */
.bubble-actions {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100; /* Highest priority */
    pointer-events: none; /* Let clicks pass through empty areas */
    display: none;
}

.bubble-actions .dropdown {
    position: absolute;
    top: 5px;
    right: 5px;
    pointer-events: auto; /* Action button IS clickable */
}

/* WhatsApp Web Style Dropdown */
.bubble-actions .dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 25px; /* Below the chevron */
    background-color: #fff;
    min-width: 200px;
    box-shadow: 0 4px 12px rgba(11,20,26,0.16);
    z-index: 1000;
    border-radius: 4px;
    padding: 9px 0;
    text-align: left;
    transform-origin: top right;
    animation: scaleIn 0.1s ease-out;
}

.bubble-actions .dropdown-content.show {
    display: block;
}

.bubble-actions .dropdown-content a {
    color: #3b4a54;
    padding: 8px 24px 8px 16px; /* Adjusted padding */
    text-decoration: none;
    display: flex;
    align-items: center;
    font-size: 14.5px;
    line-height: 20px;
    cursor: pointer;
    transition: background-color 0.1s;
    user-select: none;
}

.bubble-actions .dropdown-content a:hover {
    background-color: #f5f6f6;
}

.bubble-actions .dropdown-content a i {
    margin-right: 12px;
    color: #54656f;
    width: 20px;
    text-align: center;
    font-size: 16px;
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.message.sent .bubble-actions .dropdown {
    right: 15px; /* Adjust for tails if needed */
}

.bubble:hover .bubble-actions {
    display: block;
}

/* Override old selection */
.btn-bubble-action {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    color: #54656f;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
    transition: background 0.2s;
}

.btn-bubble-action:hover {
    background: #fff;
    color: #000;
}

/* Legacy btn-reply removal or upgrade */
.btn-reply {
    display: none !important;
}

/* Add specialized tails for that authentic WA look */
.message.received .bubble::before {
    content: "";
    position: absolute;
    top: 0;
    left: -10px;
    width: 0;
    height: 0;
    border-top: 0px solid transparent;
    border-bottom: 15px solid transparent;
    border-right: 15px solid #fff;
}

.message.sent .bubble::before {
    content: "";
    position: absolute;
    top: 0;
    right: -10px;
    width: 0;
    height: 0;
    border-top: 0px solid transparent;
    border-bottom: 15px solid transparent;
    border-left: 15px solid #d9fdd3;
}


.bubble:hover .btn-reply {
    display: flex;
}

.btn-reply {
    position: absolute;
    right: -30px;
    top: 0;
    display: none;
    background: transparent;
    border: none;
    color: #54656f;
    cursor: pointer;
    font-size: 1rem;
    padding: 5px;
}

.message.sent .btn-reply {
    right: unset;
    left: -30px;
}

.quoted-message {
    background: rgba(0,0,0,0.05);
    border-radius: 6px;
    display: flex;
    overflow: hidden;
    margin-bottom: 4px;
    cursor: pointer;
    max-height: 60px;
}

.quoted-bar {
    width: 4px;
    background: #06cf9c;
    flex-shrink: 0;
}

.sent .quoted-bar { background: #00a884; }

.quoted-content {
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.quoted-sender {
    font-size: 0.75rem;
    font-weight: 700;
    color: #06cf9c;
    margin-bottom: 2px;
}

.sent .quoted-sender { color: #00a884; }

.quoted-text {
    font-size: 0.8rem;
    color: #54656f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-preview-container {
    background: #f0f2f5;
    padding: 8px 16px;
    border-top: 1px solid rgba(0,0,0,0.05);
    display: none;
    align-items: center;
    gap: 12px;
}

.reply-preview-content {
    flex: 1;
    background: #fff;
    border-left: 4px solid #06cf9c;
    padding: 8px 12px;
    border-radius: 4px;
    min-width: 0;
}

.reply-preview-sender {
    font-size: 0.8rem;
    font-weight: 700;
    color: #06cf9c;
    display: block;
}

.reply-preview-text {
    font-size: 0.85rem;
    color: #54656f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.btn-close-reply {
    color: #54656f;
    cursor: pointer;
    font-size: 1.2rem;
}

.message .meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    color: #667781;
    font-size: 0.68rem;
    margin-top: 2px;
    align-self: flex-end;
}

.message.sent .meta { color: #667781; }

.attachment.image {
    margin-bottom: 4px;
    cursor: pointer;
}

.attachment.image img {
    max-width: 100%;
    border-radius: 6px;
    display: block;
}

.attachment.file {
    background: rgba(0,0,0,0.05);
    padding: 10px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
    cursor: pointer;
}

.attachment.file i {
    font-size: 1.5rem;
    color: #54656f;
}

.fa-check-double { font-size: 0.75rem; color: #999; }
.read-receipt { color: #34b7f1; } /* Blue tick */

.label-pill {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    color: #fff;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: 6px;
}

.status-badge.queued {
    background: var(--warning);
    color: #fff;
}

.availability-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.availability-indicator.online { background-color: var(--success); }
.availability-indicator.offline { background-color: var(--text-light); }
.availability-indicator.busy { background-color: var(--danger); }
.availability-indicator.away { background-color: var(--warning); }

/* Attachments */
.attachment.image img {
    max-width: 100%;
    border-radius: 6px;
    margin-bottom: 4px;
    display: block;
}

.attachment.file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: rgba(0,0,0,0.05);
    border-radius: 4px;
    margin-bottom: 4px;
}
.attachment.file i { font-size: 1.5rem; color: #666; }

/* Input Adjustments */
.chat-input-area {
    background: #f0f2f5;
    padding: 10px 16px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    min-height: 62px;
}

.chat-input-wrapper {
    flex: 1;
    background: #fff;
    border-radius: 8px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    max-width: calc(100% - 100px);
}

.chat-input-area textarea {
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    font-size: 0.94rem;
    color: #111b21;
    max-height: 120px;
    padding: 5px 0;
    margin: 0;
    line-height: 20px;
}

.btn-icon {
    background: transparent;
    border: none;
    color: #54656f;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-icon:hover { 
    background: rgba(0,0,0,0.05); 
}

.btn-icon#btnSend {
    color: #00a884;
}

.empty-state-large {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-light);
    background: var(--secondary-color);
}
.empty-state-large h2 {
    color: var(--text-dark);
    font-weight: 600;
}

/* Login Styles */
.login-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-color); display: flex; align-items: center; justify-content: center; z-index: 1000; } 
.login-box { background: white; padding: 2.5rem; border-radius: var(--border-radius); box-shadow: var(--shadow-lg); width: 100%; max-width: 400px; border: 1px solid var(--border-color); }
.login-box h2 { text-align: center; margin-bottom: 2rem; font-size: 1.5rem; }
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; margin-bottom: 0.5rem; color: var(--text-dark); font-weight: 500; }
.form-group input:not([type="checkbox"]), .form-group select, .form-group textarea { width: 100%; } 
.login-box .btn-primary { width: 100%; justify-content: center; }

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1.5rem;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Sidebar Footer */
.sidebar-footer { 
    margin-top: auto; 
    padding: 1rem; 
    border-top: 1px solid var(--border-color); 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
}
.user-profile { display: flex; align-items: center; gap: 0.75rem; }
.user-avatar { width: 40px; height: 40px; background: var(--secondary-color); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--primary-color); font-size: 1.2rem; }
.user-info { display: flex; flex-direction: column; font-size: 0.9rem; }
.user-info span { font-weight: 600; }
.user-info .badge { font-size: 0.75rem; background: var(--secondary-color); color: var(--primary-color); padding: 0.2rem 0.5rem; border-radius: 999px; display: inline-block; width: fit-content; font-weight: 600; margin-top: 0.25rem; }

/* Admin Tables */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 1rem;
}

.data-table th {
    background: #f8fafc;
    font-weight: 600;
    color: #64748b;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.data-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table tr:hover {
    background-color: #f1f5f9;
}

.badge-success {
    background-color: #dcfce7;
    color: #166534;
}

.badge-secondary {
    background-color: #f1f5f9;
    color: #475569;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.btn-outline {
    background: #fff;
    border: 1px solid var(--border-color);
    color: var(--text-light);
}

.btn-outline:hover {
    background: #f8fafc;
    color: var(--text-dark);
}

/* Utilities */
.text-right { text-align: right; }
.text-center { text-align: center; }
/* Partial Payment Box */
.partial-payment-box {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border-color);
}
.partial-payment-box .wc-totals-row {
    margin-bottom: 0.5rem;
}
.partial-payment-box .wc-totals-label {
    font-weight: 500;
    color: var(--text-dark);
}
.partial-payment-box .wc-totals-value {
    color: var(--text-dark);
}
.text-danger {
    color: var(--danger) !important;
}

/* Additional Modal Specifics */
.wc-meta-value { color: var(--text-dark); }
.wc-item-name-col { width: 50%; }
.col-cost, .col-qty, .col-total { width: 15%; text-align: right; }
.col-qty { text-align: center; }

/* Order Modal Modern Layout */
.wc-order-layout {
    display: flex;
    gap: 0;
    min-height: 500px;
}

.wc-order-main {
    flex: 1;
    padding: 1.5rem;
    border-right: 1px solid var(--border-color);
}

.wc-order-insights-sidebar {
    width: 300px;
    background: var(--bg-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.wc-order-insights-sidebar h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.wc-order-body {
    padding: 0; /* Let main/sidebar handle padding */
}

/* Attribution Styles */
.attribution-grid {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid var(--border-color);
}
.attribution-grid .wc-field-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
}
.attribution-grid .wc-field-value {
    font-size: 0.9rem;
    font-weight: 500;
}
.detail-grid .detail-item label {
    font-size: 0.75rem;
    color: var(--text-light);
    display: block;
    margin-bottom: 2px;
}
.total-spent-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--success);
}

/* Customer Profile Card in Chat Sidebar */
.customer-profile-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.profile-avatar {
    font-size: 3rem;
    color: #3b82f6; /* More vibrant blue */
}

.profile-info h4 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 0.25rem 0;
    color: #1e293b;
}

.profile-tag {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.tag-vvip { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }
.tag-regular { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }

.profile-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #f1f5f9;
}

.stat-box label {
    display: block;
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-box .value {
    font-size: 1.35rem;
    font-weight: 800;
    color: #1e293b;
}

.value.success { color: #10b981; } /* More vibrant green */

.profile-details .detail-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 1rem;
    color: #334155;
}

.profile-details .detail-row i {
    width: 20px;
    color: #94a3b8;
    font-size: 1.1rem;
}

/* Insight Sections */
.context-section {
    margin-bottom: 2rem;
    padding: 0 0.5rem;
}

.context-section h5 {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 700;
    letter-spacing: 0.075em;
    margin-bottom: 1.25rem;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 0.5rem;
    text-transform: uppercase;
}

.insight-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.insight-item label {
    display: block;
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 0.25rem;
}

.insight-item span {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
}

.truncate {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

/* Mini Order Cards */
.mini-order-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.mini-order-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.mini-order-card:hover {
    border-color: #3b82f6;
    background: #fbffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.08);
}

.mini-order-card .order-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.order-id { font-size: 1.1rem; font-weight: 800; color: #1e293b; }
.order-total { font-size: 1.1rem; font-weight: 800; color: #2563eb; }

.mini-order-card .order-sub {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: #64748b;
}

.badge-order-status {
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

/* Chat Sidebar Padding Fix */
#customerDetails, #customerOrders {
    padding: 1.5rem;
}

.chat-sidebar-header {
    padding: 1.5rem 1.5rem 0 1.5rem;
    font-size: 1.5rem;
    font-weight: 800;
    color: #0f172a;
    border-bottom: none;
}

/* Dashboard Enhancements */
.dashboard-container {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.dashboard-section {
    background: transparent;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-title.urgent {
    color: #dc2626;
}

.dashboard-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
}

.dashboard-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.dashboard-stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
}

.dashboard-stat-card.clickable:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    border-color: var(--primary-color);
}

.dashboard-stat-card.urgent {
    border-left: 4px solid #dc2626;
}

.dashboard-stat-card.chat-active {
    border-left: 4px solid var(--primary-color);
}

.dashboard-stat-card.recoverable {
    border-left: 4px solid var(--success);
}

.dashboard-stat-card label {
    font-size: 0.75rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.dashboard-stat-card .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
}

.dashboard-stat-card.urgent .value { color: #dc2626; }

.dashboard-stat-card .sub-value {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

/* Funnel Styles */
.funnel-container {
    background: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.funnel-step {
    display: grid;
    grid-template-columns: 100px 1fr 40px;
    align-items: center;
    gap: 1rem;
}

.funnel-label {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 500;
}

.funnel-bar-bg {
    height: 12px;
    background: #f1f5f9;
    border-radius: 6px;
    overflow: hidden;
}

.funnel-bar {
    height: 100%;
    background: var(--primary-color);
    border-radius: 6px;
    transition: width 0.5s ease-out;
}

.funnel-bar.success {
    background: var(--success);
}

.funnel-value {
    font-size: 0.85rem;
    font-weight: 700;
    text-align: right;
}

.dashboard-table-container {
    background: white;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.dashboard-table-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dashboard-table-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.recent-orders-table {
    width: 100%;
    border-collapse: collapse;
}

.recent-orders-table th,
.recent-orders-table td {
    padding: 1rem 1.25rem;
    text-align: left;
    font-size: 0.9rem;
}

.recent-orders-table th {
    background: #f8fafc;
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.recent-orders-table tr {
    border-bottom: 1px solid var(--border-color);
}

.recent-orders-table tr:hover {
    background: #f8fafc;
}

.recent-orders-table tr:last-child {
    border-bottom: none;
}

.order-status-badge {
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.status-completed { background: #dcfce7; color: #166534; }
.status-processing { background: #dbeafe; color: #1e40af; }
.status-pending { background: #fef9c3; color: #854d0e; }
.status-on-hold { background: #f1f5f9; color: #475569; }
.status-failed { background: #fee2e2; color: #991b1b; }

/* Status Indicators (Live Session etc) */
.status-indicator {
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: 8px;
}

.status-indicator.live {
    background: #ef4444;
    color: white;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
    animation: live-pulse 1.5s infinite;
}

@keyframes live-pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.85; }
    100% { transform: scale(1); opacity: 1; }
}

/* Cart Specific Styles */
.cart-items-preview { 
    display: flex; 
    flex-direction: column; 
    gap: 0.75rem; 
    background: #f8fafc; 
    padding: 1rem; 
    border-radius: 8px; 
    border: 1px dashed #cbd5e1; 
    margin-bottom: 0.75rem; 
}
.cart-item-row { display: flex; gap: 0.5rem; font-size: 0.85rem; align-items: flex-start; }
.cart-item-row .qty { font-weight: 700; color: var(--primary-color); min-width: 25px; }
.cart-item-row .item-name { flex: 1; color: #334155; line-height: 1.2; }
.cart-item-row .item-price { font-weight: 600; color: #475569; }
.cart-summary-line { font-size: 0.9rem; text-align: right; color: #1e293b; }
.insight-item span .fa-bolt { font-size: 0.7rem; margin-left: 4px; vertical-align: middle; }

.btn-refresh-mini {
    background: transparent;
    border: 1px solid #e2e8f0;
    color: #64748b;
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.btn-refresh-mini:hover {
    background: #f1f5f9;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.empty-state-mini {
    font-size: 0.8rem;
    color: #94a3b8;
    text-align: center;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px dashed #e2e8f0;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.flex-1 {
    flex: 1;
}

/* User Status Badges */
.availability-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.availability-indicator.online {
    color: var(--success);
}

.availability-indicator.offline {
    color: var(--secondary);
}

.availability-indicator .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.availability-indicator.online .status-dot {
    background: var(--success);
    box-shadow: 0 0 5px var(--success);
}

.availability-indicator.offline .status-dot {
    background: var(--secondary);
}




/* Command Autocomplete Styles */
.chat-input-wrapper {
    position: relative;
    flex: 1;
}

.command-suggestions {
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 100%;
    max-height: 250px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    margin-bottom: 8px; /* Added spacing from input */
}

.suggestion-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover, .suggestion-item.active {
    background: var(--primary-light);
}

.suggestion-key {
    font-weight: 600;
    color: var(--primary);
    font-family: monospace;
}

.suggestion-meta {
    font-size: 0.8rem;
    color: var(--text-light);
}

.suggestion-preview {
    font-size: 0.85rem;
    color: var(--text-main);
    display: block;
    margin-top: 4px;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.suggestion-transfer-mode {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
}

.suggestion-command-mode {
    background: #e7f3ff;
    border-left: 4px solid #007bff;
}

.command-suggestions.hidden {
    display: none;
}

/* Customer Notes */
.notes-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: #fdfdfd;
}

.note-item {
    transition: background 0.2s;
}

.note-item:hover {
    background: #f1f5f9;
}

.note-meta strong {
    color: var(--primary);
}

.note-content {
    line-height: 1.4;
    color: var(--text-dark);
}

.empty-state {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.85rem;
}

/* Anomalies & Alerts */
.alerts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.alert-card {
    padding: 15px;
    border-radius: var(--border-radius);
    border-left: 5px solid #ccc;
    background: white;
    box-shadow: var(--shadow);
}

.alert-card.severity-high { border-left-color: var(--danger); }
.alert-card.severity-medium { border-left-color: var(--warning); }
.alert-card.severity-low { border-left-color: var(--primary); }

.alert-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.8rem;
    font-weight: 600;
}

.alert-type { color: var(--text-dark); }
.alert-time { color: var(--text-light); }
.alert-msg { font-size: 0.9rem; color: var(--text-dark); line-height: 1.4; }

.badge-outline {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-light);
}

/* Ticket System Styles */
.ticket-status-tabs {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.status-tab {
    background: none;
    border: none;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-light);
    border-radius: 4px;
    transition: all 0.2s;
}

.status-tab.active {
    background: var(--primary-color);
    color: white;
}

.status-tab:hover:not(.active) {
    background: var(--secondary-color);
}

.ticket-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.ticket-badge.open { background: #fee2e2; color: #dc2626; }
.ticket-badge.in_progress { background: #fef3c7; color: #d97706; }
.ticket-badge.resolved { background: #dcfce7; color: #16a34a; }
.ticket-badge.closed { background: #f1f5f9; color: #64748b; }

.priority-high { color: #dc2626; font-weight: 600; }
.priority-urgent { color: #dc2626; font-weight: 700; text-transform: uppercase; }

.ticket-item-card {
    background: white;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 10px;
    cursor: pointer;
}

.ticket-item-card:hover {
    border-color: var(--primary-color);
}

.ticket-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-light);
}

.ticket-actions-cell {
    display: flex;
    gap: 8px;
}

/* Ticket Detail Refactor */
.td-info-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.td-info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.td-info-item label {
    color: var(--text-light);
    font-weight: 400;
}

.td-info-item span {
    font-weight: 500;
    color: var(--text-dark);
}

.td-left-col::-webkit-scrollbar {
    width: 4px;
}

.td-left-col::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.readonly-chat-header {
    background: #f0f2f5;
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.td-timeline {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.td-evidence-item {
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
}

.td-evidence-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 8px;
    border-bottom: 0.5px solid #eee;
    padding-bottom: 4px;
}

.td-evidence-content {
    font-size: 0.9rem;
    color: var(--text-dark);
    line-height: 1.4;
}

.td-evidence-notes {
    margin-top: 8px;
    background: #fff;
    padding: 6px;
    border-left: 3px solid var(--primary-color);
    font-size: 0.8rem;
    color: #444;
}

 / *   T i c k e t   S y s t e m   S t y l e s   * / 
 . t i c k e t - s t a t u s - t a b s   { 
         d i s p l a y :   f l e x ; 
         g a p :   1 5 p x ; 
         m a r g i n - b o t t o m :   2 0 p x ; 
         b o r d e r - b o t t o m :   1 p x   s o l i d   v a r ( - - b o r d e r - c o l o r ) ; 
         p a d d i n g - b o t t o m :   1 0 p x ; 
 } 
 
 . s t a t u s - t a b   { 
         b a c k g r o u n d :   n o n e ; 
         b o r d e r :   n o n e ; 
         p a d d i n g :   8 p x   1 6 p x ; 
         c u r s o r :   p o i n t e r ; 
         f o n t - s i z e :   0 . 9 5 r e m ; 
         f o n t - w e i g h t :   5 0 0 ; 
         c o l o r :   v a r ( - - t e x t - l i g h t ) ; 
         b o r d e r - r a d i u s :   4 p x ; 
         t r a n s i t i o n :   a l l   0 . 2 s ; 
 } 
 
 . s t a t u s - t a b . a c t i v e   { 
         b a c k g r o u n d :   v a r ( - - p r i m a r y - c o l o r ) ; 
         c o l o r :   w h i t e ; 
 } 
 
 . s t a t u s - t a b : h o v e r : n o t ( . a c t i v e )   { 
         b a c k g r o u n d :   v a r ( - - s e c o n d a r y - c o l o r ) ; 
 } 
 
 . t i c k e t - b a d g e   { 
         p a d d i n g :   2 p x   8 p x ; 
         b o r d e r - r a d i u s :   1 2 p x ; 
         f o n t - s i z e :   0 . 7 5 r e m ; 
         f o n t - w e i g h t :   6 0 0 ; 
 } 
 
 . t i c k e t - b a d g e . o p e n   {   b a c k g r o u n d :   # f e e 2 e 2 ;   c o l o r :   # d c 2 6 2 6 ;   } 
 . t i c k e t - b a d g e . i n _ p r o g r e s s   {   b a c k g r o u n d :   # f e f 3 c 7 ;   c o l o r :   # d 9 7 7 0 6 ;   } 
 . t i c k e t - b a d g e . r e s o l v e d   {   b a c k g r o u n d :   # d c f c e 7 ;   c o l o r :   # 1 6 a 3 4 a ;   } 
 . t i c k e t - b a d g e . c l o s e d   {   b a c k g r o u n d :   # f 1 f 5 f 9 ;   c o l o r :   # 6 4 7 4 8 b ;   } 
 
 . p r i o r i t y - h i g h   {   c o l o r :   # d c 2 6 2 6 ;   f o n t - w e i g h t :   6 0 0 ;   } 
 . p r i o r i t y - u r g e n t   {   c o l o r :   # d c 2 6 2 6 ;   f o n t - w e i g h t :   7 0 0 ;   t e x t - t r a n s f o r m :   u p p e r c a s e ;   } 
 
 . t i c k e t - i t e m - c a r d   { 
         b a c k g r o u n d :   w h i t e ; 
         p a d d i n g :   1 2 p x ; 
         b o r d e r - r a d i u s :   8 p x ; 
         b o r d e r :   1 p x   s o l i d   v a r ( - - b o r d e r - c o l o r ) ; 
         m a r g i n - b o t t o m :   1 0 p x ; 
         c u r s o r :   p o i n t e r ; 
 } 
 
 . t i c k e t - i t e m - c a r d : h o v e r   { 
         b o r d e r - c o l o r :   v a r ( - - p r i m a r y - c o l o r ) ; 
 } 
 
 . t i c k e t - m e t a   { 
         d i s p l a y :   f l e x ; 
         j u s t i f y - c o n t e n t :   s p a c e - b e t w e e n ; 
         m a r g i n - t o p :   8 p x ; 
         f o n t - s i z e :   0 . 8 r e m ; 
         c o l o r :   v a r ( - - t e x t - l i g h t ) ; 
 } 
 
 . t i c k e t - a c t i o n s - c e l l   { 
         d i s p l a y :   f l e x ; 
         g a p :   8 p x ; 
 } 
 
 
 .media-blurred-container {
    width: 250px;
    height: 150px;
    background-color: #e9edef;
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 4px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.media-blur-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 2;
    transition: opacity 0.3s ease;
}

.media-blur-overlay i {
    font-size: 2rem;
    margin-bottom: 8px;
    opacity: 0.8;
}

.media-blur-overlay span {
    font-size: 0.8rem;
    font-weight: 500;
    background: rgba(0,0,0,0.3);
    padding: 4px 8px;
    border-radius: 12px;
}

.media-content-loaded {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.media-download-btn-separate {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    padding: 6px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 5;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-download-btn-separate:hover {
    background: rgba(0,0,0,0.7);
}

.media-blurred-container {
    width: 250px;
    height: 150px;
    background-color: #e9edef;
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 4px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.media-blur-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 2;
    transition: opacity 0.3s ease;
}

.media-blur-overlay i {
    font-size: 2rem;
    margin-bottom: 8px;
    opacity: 0.8;
}

.media-blur-overlay span {
    font-size: 0.8rem;
    font-weight: 500;
    background: rgba(0,0,0,0.3);
    padding: 4px 8px;
    border-radius: 12px;
}

.media-content-loaded {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.media-download-btn-separate {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    padding: 6px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 5;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-download-btn-separate:hover {
    background: rgba(0,0,0,0.7);
}


/* Usability & Layering Fixes */
.media-blurred-container {
    z-index: 10;
    pointer-events: auto;
}

.media-content-loaded {
    pointer-events: none !important;
}

.media-blur-overlay {
    pointer-events: auto;
}

.media-download-btn-separate {
    z-index: 50;
    pointer-events: auto;
}


/* Correction for Video Controls */
img.media-content-loaded { pointer-events: none !important; }
video.media-content-loaded { pointer-events: auto !important; }

