:root {
    --border: var(--border-color);
    --bg: var(--bg-card);
    --white: var(--bg-card);
}

/* ==================== ADMIN CHAT ==================== */

/* Header tugmalari */
.admin-chat-header-btn {
    position: relative;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: 8px;
    color: var(--primary);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.admin-chat-header-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }
.admin-chat-header-btn:active { transform: scale(0.93); }

/* Unread badge */
.admin-chat-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ef4444;
    color: white;
    border-radius: 100px;
    font-size: 0.62rem;
    font-weight: 700;
    min-width: 17px;
    height: 17px;
    padding: 0 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--white);
}

/* Overlay */
.admin-chat-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 1198;
}
.admin-chat-overlay.open,
.admin-chat-panel.open ~ .admin-chat-overlay { display: block; }

/* Side panel */
.admin-chat-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: min(420px, 100vw);
    height: 100vh;
    background: var(--white);
    box-shadow: -4px 0 24px rgba(0,0,0,0.15);
    z-index: 1200;
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.4,0,0.2,1);
    overflow: hidden;
}
.admin-chat-panel.open { right: 0; }
.admin-chat-panel.open + .admin-chat-overlay { display: block; }

/* Panel header */
.admin-chat-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--white);
    position: sticky;
    top: 0;
    z-index: 5;
}
.admin-chat-panel-header h3 {
    flex: 1;
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.admin-panel-close, .admin-back-btn {
    width: 34px;
    height: 34px;
    border: none;
    background: var(--bg);
    border-radius: 8px;
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
    transition: all 0.15s;
}
.admin-panel-close:hover, .admin-back-btn:hover { background: #fee2e2; color: #ef4444; }

/* Conversations list */
.admin-conv-search-wrap {
    margin: 10px 10px 0;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--white);
    display: flex;
    align-items: center;
    gap: 8px;
}
.admin-conv-search-wrap i {
    color: var(--text-dim);
    font-size: 0.82rem;
}
.admin-conv-search-input {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-dark);
    font-size: 0.86rem;
}

.admin-conv-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.admin-conv-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}
.admin-conv-item:hover { background: var(--bg); }
.admin-conv-item.unread { background: rgba(0,151,178,0.06); }
.admin-conv-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark, #007a94));
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.admin-conv-body { flex: 1; min-width: 0; }
.admin-conv-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
}
.admin-conv-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.admin-conv-time {
    font-size: 0.73rem;
    color: var(--text-dim);
    flex-shrink: 0;
}
.admin-conv-preview {
    font-size: 0.82rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.admin-conv-meta {
    display: flex;
    gap: 10px;
    margin-bottom: 3px;
    font-size: 0.75rem;
    color: var(--text-dim);
}
.admin-conv-meta span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.admin-conv-badge {
    background: var(--primary);
    color: white;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Individual chat messages */
.admin-msg-list {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f7f8fa;
}
.admin-msg {
    display: flex;
    max-width: 80%;
}
.admin-msg.mine  { align-self: flex-end; }
.admin-msg.theirs { align-self: flex-start; }

.admin-bubble {
    padding: 10px 14px 6px;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.admin-msg.mine .admin-bubble  { background: var(--primary); color: white; border-bottom-right-radius: 4px; }
.admin-msg.theirs .admin-bubble { background: white; color: #1a1a2e; border-bottom-left-radius: 4px; }
.admin-bubble p { margin: 0 0 4px; font-size: 0.9rem; line-height: 1.4; word-break: break-word; }
.admin-msg-time { font-size: 0.68rem; opacity: 0.65; display: block; text-align: right; }
.admin-chat-img {
    width: 100%;
    max-width: 220px;
    border-radius: 10px;
    margin: 6px 0;
    display: block;
}

/* Input area */
.admin-chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 14px;
    background: var(--white);
    border-top: 1px solid var(--border);
}
.admin-chat-textarea {
    flex: 1;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 0.9rem;
    resize: none;
    outline: none;
    background: var(--bg);
    color: var(--text-dark);
    max-height: 80px;
    overflow-y: auto;
    transition: border-color 0.2s;
    font-family: inherit;
}
.admin-chat-textarea:focus { border-color: var(--primary); }
.admin-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
}
.admin-send-btn:hover  { background: var(--primary-dark, #007a94); }
.admin-send-btn:active { transform: scale(0.92); }
.admin-attach-btn {
    background: var(--bg);
    color: var(--primary);
}
.admin-attach-btn:hover {
    background: var(--bg);
    color: var(--primary-dark, #007a94);
}

.admin-chat-pending-preview {
    padding: 8px 14px 0;
    background: var(--white);
}

.admin-chat-pending-preview-card {
    position: relative;
    width: fit-content;
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 6px;
    background: var(--bg);
}

.admin-chat-pending-preview-card img {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}

.admin-chat-pending-preview-name {
    margin-top: 6px;
    max-width: 170px;
    font-size: 0.72rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-chat-pending-preview-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: #ef4444;
    color: #fff;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Broadcast modal */
.admin-broadcast-modal-content {
    background: var(--white);
    border-radius: 16px;
    width: min(920px, 96vw);
    max-height: 92vh;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    overflow: hidden;
    animation: scaleIn 0.25s ease;
    display: flex;
    flex-direction: column;
}
@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}
.admin-broadcast-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark, #007a94));
    color: white;
}
.admin-broadcast-header h3 { margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.admin-modal-close {
    width: 34px;
    height: 34px;
    border: none;
    background: rgba(255,255,255,0.2);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: background 0.2s;
}
.admin-modal-close:hover { background: rgba(255,255,255,0.35); }
.admin-broadcast-body {
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
}
.admin-broadcast-body .form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.admin-broadcast-body label {
    font-size: 0.87rem;
    font-weight: 600;
    color: var(--text-dim);
}
.admin-broadcast-body .form-control {
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.92rem;
    outline: none;
    background: var(--bg);
    color: var(--text-dark);
    transition: border-color 0.2s;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
}
.admin-broadcast-body .form-control:focus { border-color: var(--primary); }

.admin-broadcast-submit-row {
    display: flex;
    gap: 10px;
}
.admin-broadcast-submit-row #broadcastCancelEditBtn {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text-dark);
    padding: 10px 14px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.admin-broadcast-history-wrap {
    margin-top: 8px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}
.admin-broadcast-history-title {
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.admin-broadcast-history-list {
    max-height: 340px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 10px;
}
.admin-broadcast-history-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    background: var(--bg);
}
.admin-broadcast-history-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 6px;
}
.admin-broadcast-history-head strong {
    font-size: 0.85rem;
    color: var(--text-dark);
}
.admin-broadcast-history-head span {
    font-size: 0.72rem;
    color: var(--text-dim);
    white-space: nowrap;
}
.admin-broadcast-history-text {
    font-size: 0.82rem;
    color: var(--text-dim);
    line-height: 1.35;
    white-space: pre-wrap;
}
.admin-broadcast-history-footer {
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.admin-broadcast-history-meta {
    font-size: 0.75rem;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.admin-broadcast-actions {
    display: flex;
    gap: 6px;
}
.admin-broadcast-action {
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--text-dark);
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.admin-broadcast-action.edit { color: #1d4ed8; }
.admin-broadcast-action.delete { color: #b91c1c; }
.admin-broadcast-empty {
    font-size: 0.82rem;
    color: var(--text-dim);
    padding: 8px 2px;
}

/* File upload */
#broadcastFileDropZone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg);
}
#broadcastFileDropZone:hover {
    border-color: var(--primary);
    background: var(--primary);
    background: rgba(0, 102, 204, 0.05);
}
#broadcastFileDropZone i {
    font-size: 28px;
    color: #888;
    margin-bottom: 8px;
    display: block;
}
#broadcastFilePreview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
    margin-top: 10px;
}
#broadcastFilePreview > div {
    width: 80px;
    height: 80px;
    background: #f0f0f0;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ddd;
    overflow: hidden;
}

body.dark-theme #broadcastFileDropZone {
    border-color: #30363d;
    background: #0d1117;
}
body.dark-theme #broadcastFileDropZone:hover {
    background: rgba(88, 166, 255, 0.1);
}
body.dark-theme #broadcastFilePreview > div {
    background: #161b22;
    border-color: #30363d;
}

/* Empty state */
.admin-chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 20px;
    color: var(--text-dim);
}
.admin-chat-empty i { font-size: 2.5rem; opacity: 0.25; }
.admin-chat-empty p { margin: 0; font-size: 0.9rem; }

/* Dark theme */
body.dark-theme .admin-chat-panel,
body.dark-theme .admin-broadcast-modal-content { background: #161b22; }
body.dark-theme .admin-conv-search-wrap { background: #0d1117; border-color: #30363d; }
body.dark-theme .admin-conv-search-wrap i { color: #8b949e; }
body.dark-theme .admin-conv-search-input { color: #e6edf3; }
body.dark-theme .admin-conv-item:hover { background: #1c2128; }
body.dark-theme .admin-conv-item.unread { background: #1a2a30; }
body.dark-theme .admin-conv-meta { color: #8b949e; }
body.dark-theme .admin-msg-list { background: #0d1117; }
body.dark-theme .admin-msg.theirs .admin-bubble { background: #161b22; color: #e6edf3; }
body.dark-theme .admin-chat-input-area,
body.dark-theme .admin-chat-panel-header { background: #161b22; border-color: #30363d; }
body.dark-theme .admin-chat-pending-preview { background: #161b22; }
body.dark-theme .admin-chat-pending-preview-card { background: #0d1117; border-color: #30363d; }
body.dark-theme .admin-chat-pending-preview-name { color: #8b949e; }
body.dark-theme .admin-chat-textarea,
body.dark-theme .admin-broadcast-body .form-control { background: #0d1117; color: #e6edf3; border-color: #30363d; }
body.dark-theme .admin-attach-btn { background: #0d1117; color: #58a6ff; }
body.dark-theme .admin-broadcast-history-item { background: #0d1117; border-color: #30363d; }
body.dark-theme .admin-broadcast-history-title,
body.dark-theme .admin-broadcast-history-head strong { color: #e6edf3; }
body.dark-theme .admin-broadcast-history-head span,
body.dark-theme .admin-broadcast-history-text,
body.dark-theme .admin-broadcast-empty { color: #8b949e; }
body.dark-theme .admin-broadcast-action { background: #161b22; border-color: #30363d; color: #c9d1d9; }
body.dark-theme .admin-broadcast-action.edit { color: #79c0ff; }
body.dark-theme .admin-broadcast-action.delete { color: #ff7b72; }
body.dark-theme .admin-broadcast-submit-row #broadcastCancelEditBtn { background: #161b22; border-color: #30363d; color: #c9d1d9; }
/* Customer Detail Panel Dark Theme */
body.dark-theme #customerDetailPanel { 
    background: #0d1117; 
    border-color: #30363d; 
    color: #e6edf3;
}
body.dark-theme #customerDetailPanel h3,
body.dark-theme #customerDetailPanel h4 { 
    color: #e6edf3; 
}
body.dark-theme #customerDetailPanel small { 
    color: #8b949e; 
}
body.dark-theme #customerDetailPanel button[onclick*="editCustomer"],
body.dark-theme #customerDetailPanel button[onclick*="showBalanceModal"] { 
    background: var(--primary) !important; 
}
body.dark-theme #customerDetailPanel button[onclick*="deleteCustomer"] { 
    background: var(--danger) !important; 
}

/* Dark Theme Table Styling */
body.dark-theme .products-table-card {
    background: var(--glass-surface);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28);
    border: 1px solid var(--glass-edge);
}

body.dark-theme .products-data-table thead {
    background: var(--glass-void);
    border-bottom-color: var(--glass-edge);
}

body.dark-theme .products-data-table th {
    color: var(--primary-light);
    background: var(--glass-void);
    border-bottom-color: var(--glass-edge);
}

body.dark-theme .products-data-table td {
    color: #cfd7e8;
    border-bottom-color: var(--glass-edge);
}

body.dark-theme .products-data-table tbody tr {
    border-left-color: transparent;
    background: rgba(22, 30, 50, 0.35);
}

body.dark-theme .products-data-table tbody tr.status-active {
    border-left-color: #238636;
}

body.dark-theme .products-data-table tbody tr.status-inactive {
    border-left-color: #da3633;
}

body.dark-theme .products-data-table tbody tr.status-restricted {
    border-left-color: #d4a574;
}

body.dark-theme .products-data-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.06) !important;
}

body.dark-theme .product-row-number {
    color: #8b949e;
}

body.dark-theme .product-cell-name {
    color: #e6edf3;
}

body.dark-theme .product-cell-sku {
    color: #8b949e;
}

body.dark-theme .product-variants {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-light);
    border-left-color: var(--primary);
}

body.dark-theme .category-badge {
    opacity: 0.9;
}

body.dark-theme .status-badge {
    opacity: 0.95;
}

body.dark-theme .stock-value {
    color: var(--primary-light);
}

/* Dark Theme Products Filter Bar */
body.dark-theme .products-filter-bar {
    background: transparent;
}

body.dark-theme .search-box {
    background: var(--glass-void);
    border-color: var(--glass-edge);
}

body.dark-theme .search-box i {
    color: #8b949e;
}

body.dark-theme .search-box input {
    color: #e6edf3;
}

body.dark-theme .search-box input::placeholder {
    color: #8b949e;
}

body.dark-theme .filter-select {
    background: var(--glass-void);
    color: var(--text-dark);
    border-color: var(--glass-edge);
}

body.dark-theme .filter-select:hover {
    border-color: var(--primary-light);
}

body.dark-theme .filter-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(0, 151, 178, 0.18);
}

/* Dark Theme Products Top Bar */
body.dark-theme .products-title-section h2 {
    color: #e6edf3;
}

body.dark-theme .product-count {
    color: #8b949e;
}

/* Dark Theme Modal Text */
body.dark-theme .modal-content h2,
body.dark-theme .modal-header h2 {
    color: var(--primary-light);
}

body.dark-theme .form-group label {
    color: #e6edf3;
}

body.dark-theme .form-group input,
body.dark-theme .form-group select,
body.dark-theme .form-group textarea {
    background: var(--glass-void);
    color: var(--text-dark);
    border-color: var(--glass-edge);
}

body.dark-theme .stat-card {
    background: var(--glass-surface);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    border-color: var(--glass-edge);
}

body.dark-theme .stat-number {
    color: var(--primary-light);
}

body.dark-theme .stat-title {
    color: var(--text-light);
}

/* Dark Theme Staff List Table */
body.dark-theme #staffList tr {
    background: #161b22 !important;
    border-bottom-color: #30363d !important;
}

body.dark-theme #staffList tr:hover {
    background: #0d1117 !important;
}

body.dark-theme #staffList td {
    color: #e6edf3 !important;
    border-bottom-color: #30363d !important;
}

body.dark-theme #staffList td div[style*="font-weight: 600"] {
    color: #e6edf3 !important;
}

body.dark-theme #staffList td div[style*="color: #0f172a"] {
    color: #e6edf3 !important;
}

body.dark-theme #staffList td div[style*="color: #475569"] {
    color: #c9d1d9 !important;
}

body.dark-theme #staffList td div[style*="color: #94a3b8"] {
    color: #8b949e !important;
}

body.dark-theme #staffList td span[style*="background: #f1f5f9"] {
    background: #30363d !important;
    color: #e6edf3 !important;
}

body.dark-theme #staffList td span[style*="color: #475569"] {
    color: #c9d1d9 !important;
}

/* Force all nested text in staff list to be readable */
body.dark-theme #staffList td * {
    color: inherit !important;
}
body.dark-theme #staffList td {
    color: #e6edf3 !important;
}
body.dark-theme #staffList td span[style*="background: #f1f5f9"],
body.dark-theme #staffList td span[style*="background: #f1f5f9; color"] {
    background: #21262d !important;
    color: #c9d1d9 !important;
}

