/* 2CRM.kz - Custom Styles */

/* ============================
   CSS Custom Properties (Theme)
   ============================ */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-input: #ffffff;
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-tertiary: #6b7280;
    --text-muted: #9ca3af;
    --border-primary: #e5e7eb;
    --border-secondary: #f3f4f6;
    --border-input: #d1d5db;
    --shadow-color: rgba(0, 0, 0, 0.07);
    --kanban-bg: #f9fafb;
    --kanban-drag: #eff6ff;
    --kanban-card: #ffffff;
    --table-hover: #f9fafb;
    --note-bg: #fffbeb;
    --note-border: #f59e0b;
    --mark-bg: #fef08a;
    --mark-color: inherit;
    --scrollbar-thumb: #d1d5db;
    --scrollbar-hover: #9ca3af;
    --spinner-bg: #e5e7eb;
    --spinner-fg: #3b82f6;
    --overlay-bg: rgba(0, 0, 0, 0.5);
}

html.dark {
    --bg-primary: #1e293b;
    --bg-secondary: #0f172a;
    --bg-tertiary: #1e293b;
    --bg-input: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #e2e8f0;
    --text-tertiary: #94a3b8;
    --text-muted: #64748b;
    --border-primary: #334155;
    --border-secondary: #1e293b;
    --border-input: #475569;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --kanban-bg: #0f172a;
    --kanban-drag: #1e3a5f;
    --kanban-card: #1e293b;
    --table-hover: #334155;
    --note-bg: #422006;
    --note-border: #d97706;
    --mark-bg: #854d0e;
    --mark-color: #fef3c7;
    --scrollbar-thumb: #475569;
    --scrollbar-hover: #64748b;
    --spinner-bg: #334155;
    --spinner-fg: #60a5fa;
    --overlay-bg: rgba(0, 0, 0, 0.75);
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes slideRight { from { transform: translateX(-100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideLeft { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes slideOutLeft { from { transform: translateX(0); } to { transform: translateX(-100%); } }

.animate-fade-in { animation: fadeIn 0.3s ease-out; }
.animate-slide-up { animation: slideUp 0.4s ease-out; }
.animate-scale-in { animation: scaleIn 0.3s ease-out; }
.animate-slide-right { animation: slideRight 0.3s ease-out; }
.animate-slide-left { animation: slideLeft 0.3s cubic-bezier(0.16, 1, 0.3, 1); }

/* AI FAB pulse */
@keyframes aiFabPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(129, 90, 213, 0.5); }
    50% { box-shadow: 0 0 0 12px rgba(129, 90, 213, 0); }
}
.ai-fab-pulse { animation: aiFabPulse 3s ease-in-out infinite; transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.ai-fab-pulse:hover { animation: none; }

/* AI gradient text */
.ai-gradient-text {
    background: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

/* Kanban */
.kanban-column { min-height: 200px; transition: background-color 0.2s; background-color: var(--kanban-bg); border-color: var(--border-primary); }
.kanban-column.drag-over { background-color: var(--kanban-drag) !important; border-color: #93c5fd !important; }
.kanban-card { cursor: grab; transition: transform 0.15s, box-shadow 0.15s; background-color: var(--kanban-card); }
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: 0.5; transform: rotate(2deg) scale(1.02); }
.kanban-col-width { width: 260px; }
@media (min-width: 640px) { .kanban-col-width { width: 280px; } }
@media (min-width: 1024px) { .kanban-col-width { width: 300px; } }

/* Toast transitions */
.toast { transition: opacity 0.3s, transform 0.3s; }

/* Table hover */
.table-row-hover:hover { background-color: var(--table-hover); }

/* Loading spinner */
.spinner { border: 3px solid var(--spinner-bg); border-top: 3px solid var(--spinner-fg); border-radius: 50%; width: 24px; height: 24px; animation: spin 0.8s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Badge styles */
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 9999px; font-size: 0.75rem; font-weight: 500; }

/* Mobile sidebar */
#sidebar { transition: transform 0.3s ease; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 35; }
.sidebar-overlay.active { display: block; }

@media (max-width: 1023px) {
    #sidebar { transform: translateX(-100%); }
    #sidebar.sidebar-open { transform: translateX(0); }
    #main-area { margin-left: 0 !important; }
}

/* ============================
   Responsive / Mobile
   ============================ */

/* Tables: horizontal scroll on small screens */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Team Chat slide-out panel */
.team-chat-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 380px;
    max-width: 100vw;
    background: #fff;
    border-left: 1px solid #e5e7eb;
    box-shadow: -4px 0 20px rgba(0,0,0,0.08);
    z-index: 45;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.team-chat-panel.open {
    transform: translateX(0);
}
.team-chat-panel.pinned {
    transform: translateX(0);
}
.team-chat-panel.pinned ~ #main-area {
    margin-right: 380px;
}
.team-chat-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.2);
    z-index: 44;
}
.team-chat-overlay.active {
    display: block;
}
/* Pinned state: no overlay, adjust main area */
.team-chat-panel.pinned + .team-chat-overlay { display: none !important; }

@media (max-width: 767px) {
    .team-chat-panel { width: 100vw; }
}

html.dark .team-chat-panel { background: var(--bg-primary); border-color: var(--border-primary); }

/* Chat/Inbox: two-panel layout */
.chat-sidebar-panel { width: 100%; flex-shrink: 0; }
.chat-main-panel { display: none; }

@media (min-width: 768px) {
    .chat-sidebar-panel { width: 320px; }
    .chat-main-panel { display: flex !important; }
    .chat-back-btn { display: none !important; }
}
@media (max-width: 767px) {
    .chat-back-btn { display: flex !important; }
    .chat-main-panel.is-active { display: flex !important; }
    .chat-sidebar-panel.is-hidden { display: none !important; }
}

/* Notification panel responsive */
@media (max-width: 480px) {
    #notif-panel { width: calc(100vw - 16px) !important; right: -8px !important; }
    #ai-popup { width: calc(100vw - 24px) !important; right: 12px !important; left: 12px !important; bottom: 80px !important; }
}

/* Header buttons on small screens */
@media (max-width: 374px) {
    .header-hide-xs { display: none !important; }
}

/* Pagination */
.pagination-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 2rem; height: 2rem; padding: 0 0.5rem; border-radius: 0.5rem; font-size: 0.875rem; transition: background-color 0.15s; }
.pagination-btn:hover:not(:disabled) { background-color: var(--bg-tertiary); }
.pagination-btn.active { background-color: #2563eb; color: #fff; }
.pagination-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Notes */
.note-card { background: var(--note-bg); border-left: 3px solid var(--note-border); }

/* Search highlight */
mark { background: var(--mark-bg); color: var(--mark-color); border-radius: 2px; padding: 0 2px; }

/* ============================
   Dark Mode Overrides
   ============================ */

/* Transition for theme switch */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease !important;
    transition-delay: 0s !important;
}

/* --- Backgrounds --- */
html.dark .bg-white { background-color: var(--bg-primary) !important; }
html.dark .bg-gray-50 { background-color: var(--bg-secondary) !important; }
html.dark .bg-gray-100 { background-color: var(--bg-tertiary) !important; }
html.dark .bg-gray-50\/50 { background-color: rgba(17, 24, 39, 0.5) !important; }

/* --- Text --- */
html.dark .text-gray-900 { color: #f9fafb !important; }
html.dark .text-gray-800 { color: #e5e7eb !important; }
html.dark .text-gray-700 { color: #d1d5db !important; }
html.dark .text-gray-600 { color: #9ca3af !important; }
html.dark .text-gray-500 { color: #9ca3af !important; }
html.dark .text-gray-400 { color: #6b7280 !important; }

/* --- Borders --- */
html.dark .border-gray-200 { border-color: var(--border-primary) !important; }
html.dark .border-gray-100 { border-color: var(--border-secondary) !important; }
html.dark .border-gray-300 { border-color: var(--border-input) !important; }
html.dark .divide-gray-200 > * + * { border-color: var(--border-primary) !important; }
html.dark .divide-gray-100 > * + * { border-color: var(--border-secondary) !important; }

/* --- Hover states --- */
html.dark .hover\:bg-gray-50:hover { background-color: #374151 !important; }
html.dark .hover\:bg-gray-100:hover { background-color: #374151 !important; }
html.dark .hover\:bg-gray-200:hover { background-color: #4b5563 !important; }
html.dark .hover\:text-gray-900:hover { color: #f9fafb !important; }
html.dark .hover\:text-gray-600:hover { color: #d1d5db !important; }

/* --- Form inputs --- */
html.dark input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
html.dark select,
html.dark textarea {
    background-color: var(--bg-input) !important;
    border-color: var(--border-input) !important;
    color: var(--text-primary) !important;
}
html.dark input::placeholder,
html.dark textarea::placeholder {
    color: var(--text-muted) !important;
}
html.dark input:focus,
html.dark select:focus,
html.dark textarea:focus {
    border-color: #3b82f6 !important;
}

/* --- Shadows --- */
html.dark .shadow-soft { box-shadow: 0 2px 15px -3px var(--shadow-color), 0 10px 20px -2px rgba(0, 0, 0, 0.3) !important; }
html.dark .shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5) !important; }
html.dark .shadow-xl { box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5) !important; }

/* --- Colored tints (make semi-transparent on dark bg) --- */
html.dark .bg-primary-50 { background-color: rgba(37, 99, 235, 0.15) !important; }
html.dark .bg-primary-100 { background-color: rgba(37, 99, 235, 0.25) !important; }
html.dark .bg-blue-50 { background-color: rgba(59, 130, 246, 0.15) !important; }
html.dark .bg-blue-100 { background-color: rgba(59, 130, 246, 0.2) !important; }
html.dark .bg-green-50 { background-color: rgba(16, 185, 129, 0.15) !important; }
html.dark .bg-green-100 { background-color: rgba(16, 185, 129, 0.2) !important; }
html.dark .bg-red-50 { background-color: rgba(239, 68, 68, 0.15) !important; }
html.dark .bg-red-100 { background-color: rgba(239, 68, 68, 0.2) !important; }
html.dark .bg-amber-50 { background-color: rgba(245, 158, 11, 0.15) !important; }
html.dark .bg-amber-100 { background-color: rgba(245, 158, 11, 0.2) !important; }
html.dark .bg-purple-50 { background-color: rgba(139, 92, 246, 0.15) !important; }
html.dark .bg-purple-100 { background-color: rgba(139, 92, 246, 0.2) !important; }
html.dark .bg-yellow-50 { background-color: rgba(234, 179, 8, 0.15) !important; }
html.dark .bg-indigo-50 { background-color: rgba(99, 102, 241, 0.15) !important; }

/* --- Modal overlay --- */
html.dark .bg-black\/50 { background-color: var(--overlay-bg) !important; }
html.dark .bg-black\/40 { background-color: rgba(0, 0, 0, 0.6) !important; }

/* --- Ring focus (focus:ring-*) --- */
html.dark .focus\:ring-primary-500:focus { --tw-ring-color: rgba(59, 130, 246, 0.5) !important; }

/* ============================
   Page Transition Animations
   ============================ */

/* Page transition */
.animate-fade-in {
    animation: fadeIn 0.25s ease-out;
}

/* Stagger children animation */
.stagger-children > * {
    opacity: 0;
    animation: slideUp 0.3s ease-out forwards;
}
.stagger-children > *:nth-child(1) { animation-delay: 0.03s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.06s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.09s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.12s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.15s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.18s; }
.stagger-children > *:nth-child(7) { animation-delay: 0.21s; }
.stagger-children > *:nth-child(8) { animation-delay: 0.24s; }
.stagger-children > *:nth-child(9) { animation-delay: 0.27s; }

/* Smooth list item entrance */
.animate-list-item {
    animation: slideRight 0.3s ease-out;
}

/* Card hover lift */
.card-hover {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px -5px rgba(0, 0, 0, 0.1);
}

/* ============================
   Additional Dark Mode Fixes
   ============================ */

/* Body background */
html.dark body { background-color: #0f172a !important; }
html.dark .bg-gray-50 { background-color: #0f172a !important; }

/* Cards in dark mode */
html.dark .bg-white { background-color: #1e293b !important; }
html.dark .bg-white.rounded-2xl,
html.dark .bg-white.rounded-xl,
html.dark .bg-white.rounded-lg {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

/* Sidebar in dark mode */
html.dark #sidebar {
    background-color: #0f172a !important;
    border-color: #1e293b !important;
}
html.dark #sidebar a, html.dark #sidebar button {
    color: #cbd5e1;
}
html.dark #sidebar a:hover, html.dark #sidebar button:hover {
    background-color: #1e293b !important;
}
html.dark #sidebar .text-gray-400 { color: #64748b !important; }
html.dark #sidebar .text-gray-900 { color: #f1f5f9 !important; }
html.dark #sidebar .bg-primary-50 { background-color: rgba(59, 130, 246, 0.15) !important; }
html.dark #sidebar .text-primary-700 { color: #60a5fa !important; }
html.dark #sidebar .border-gray-100 { border-color: #1e293b !important; }
html.dark #sidebar .border-gray-200 { border-color: #1e293b !important; }

/* Header/Topbar in dark mode */
html.dark header {
    background-color: rgba(15, 23, 42, 0.85) !important;
    border-color: #1e293b !important;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

/* Quick command buttons in dark mode */
html.dark .qcmd-btn {
    background-color: #334155 !important;
    color: #cbd5e1 !important;
}
html.dark .qcmd-btn:hover {
    background-color: rgba(59, 130, 246, 0.2) !important;
    color: #93c5fd !important;
}

/* Command palette in dark mode */
html.dark #cmd-palette .bg-white { background-color: #1e293b !important; }
html.dark #cmd-palette .border-gray-200 { border-color: #334155 !important; }
html.dark #cmd-palette input { background-color: transparent !important; color: #f1f5f9 !important; }
html.dark #cmd-palette .bg-primary-50 { background-color: rgba(59, 130, 246, 0.15) !important; }
html.dark #cmd-palette .hover\:bg-gray-50:hover { background-color: #334155 !important; }

/* Create menu in dark mode */
html.dark #create-menu { background-color: #1e293b !important; border-color: #334155 !important; }
html.dark #create-menu button:hover { background-color: #334155 !important; }

/* Quick cmd editor in dark mode */
html.dark #qcmd-editor { background-color: #1e293b !important; border-color: #334155 !important; }
html.dark #qcmd-editor label:hover { background-color: #334155 !important; }

/* Scrollbar-none helper */
.scrollbar-none::-webkit-scrollbar { display: none; }
.scrollbar-none { -ms-overflow-style: none; scrollbar-width: none; }

/* Tables in dark mode */
html.dark table { color: #e2e8f0; }
html.dark thead { background-color: #1e293b !important; }
html.dark th { color: #94a3b8 !important; }
html.dark td { color: #cbd5e1; border-color: #334155 !important; }
html.dark tbody tr:hover { background-color: #1e293b !important; }
html.dark .divide-gray-100 > * + *,
html.dark .divide-gray-200 > * + * { border-color: #334155 !important; }

/* Gradient cards in dark mode */
html.dark .bg-gradient-to-r { opacity: 0.95; }

/* Modal backdrop */
html.dark .bg-black\/40 { background-color: rgba(0, 0, 0, 0.7) !important; }
html.dark .bg-black\/50 { background-color: rgba(0, 0, 0, 0.75) !important; }

/* Slide-over panels in dark mode */
html.dark .animate-slide-left {
    background-color: #1e293b !important;
}

/* Tab styles */
html.dark .bg-gray-100 { background-color: #1e293b !important; }

/* Stat/KPI cards */
html.dark .shadow-soft {
    box-shadow: 0 2px 15px -3px rgba(0, 0, 0, 0.3), 0 10px 20px -2px rgba(0, 0, 0, 0.2) !important;
}
html.dark .border-gray-100 { border-color: #1e293b !important; }

/* Chart containers */
html.dark canvas { filter: brightness(0.95); }

/* Skeleton shimmer in dark mode */
html.dark .animate-pulse.bg-gray-200 { background-color: #334155 !important; }

/* Product cards */
html.dark .prod-card { background-color: #1e293b !important; border-color: #334155 !important; }
html.dark .prod-card:hover { border-color: #3b82f6 !important; }

/* Badge/pill colors in dark mode — make text lighter */
html.dark .badge { opacity: 0.9; }
html.dark .text-green-700 { color: #4ade80 !important; }
html.dark .text-green-800 { color: #86efac !important; }
html.dark .text-blue-700 { color: #60a5fa !important; }
html.dark .text-blue-800 { color: #93c5fd !important; }
html.dark .text-red-700 { color: #f87171 !important; }
html.dark .text-red-800 { color: #fca5a5 !important; }
html.dark .text-yellow-700 { color: #fbbf24 !important; }
html.dark .text-yellow-800 { color: #fcd34d !important; }
html.dark .text-purple-700 { color: #a78bfa !important; }
html.dark .text-purple-800 { color: #c4b5fd !important; }
html.dark .text-indigo-700 { color: #818cf8 !important; }
html.dark .text-orange-700 { color: #fb923c !important; }
html.dark .text-pink-700 { color: #f472b6 !important; }
html.dark .text-teal-700 { color: #2dd4bf !important; }
html.dark .text-cyan-700 { color: #22d3ee !important; }

/* Kanban in dark mode */
html.dark .kanban-card { background-color: #1e293b !important; border-color: #334155 !important; }
html.dark .kanban-column { background-color: #0f172a !important; border-color: #1e293b !important; }

/* Task items in dark mode */
html.dark .task-item { background-color: #1e293b !important; border-color: #334155 !important; }

/* Dropdowns in dark mode */
html.dark [class*="shadow-lg"][class*="bg-white"] { background-color: #1e293b !important; border-color: #334155 !important; }

/* Tooltip/Popover dark mode */
html.dark .bg-gray-50\/50 { background-color: rgba(15, 23, 42, 0.5) !important; }

/* Chat dark mode */
html.dark .bg-primary-50 { background-color: rgba(59, 130, 246, 0.15) !important; }
html.dark .bg-gray-100 { background-color: #1e293b !important; }

/* ============================
   Unified Card Styles
   ============================ */

/* Unified card style */
.card {
    background: var(--bg-primary);
    border: 1px solid var(--border-secondary);
    border-radius: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.card:hover {
    border-color: var(--border-primary);
    box-shadow: 0 4px 15px -3px var(--shadow-color);
}
.card-sm {
    background: var(--bg-primary);
    border: 1px solid var(--border-secondary);
    border-radius: 0.75rem;
    transition: border-color 0.2s;
}
.card-sm:hover {
    border-color: var(--border-primary);
}

/* Stat card */
.stat-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-secondary);
    border-radius: 0.75rem;
    padding: 1.25rem;
}
.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}
.stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* Turbo Drive progress bar */
.turbo-progress-bar { height: 3px; background: linear-gradient(to right, #6366f1, #a855f7, #ec4899); }

/* ═══ Dark Mode Global Overrides ═══ */
html.dark body { background-color: var(--bg-secondary); color: var(--text-primary); }
html.dark .bg-white { background-color: var(--bg-primary) !important; }
html.dark .bg-gray-50 { background-color: var(--bg-secondary) !important; }
html.dark .bg-gray-100, html.dark .bg-gray-50\/50 { background-color: var(--bg-tertiary) !important; }
html.dark .border-gray-100, html.dark .border-gray-200 { border-color: var(--border-primary) !important; }
html.dark .border-gray-50 { border-color: var(--border-secondary) !important; }
html.dark .text-gray-900 { color: var(--text-primary) !important; }
html.dark .text-gray-700 { color: var(--text-secondary) !important; }
html.dark .text-gray-500, html.dark .text-gray-600 { color: var(--text-tertiary) !important; }
html.dark .text-gray-400 { color: var(--text-muted) !important; }
html.dark .shadow-soft { box-shadow: 0 2px 15px -3px rgba(0,0,0,0.3) !important; }

/* Dark mode: inputs and forms */
html.dark input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
html.dark select,
html.dark textarea {
    background-color: var(--bg-input) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-input) !important;
}
html.dark input::placeholder, html.dark textarea::placeholder { color: var(--text-muted) !important; }
html.dark input:focus, html.dark select:focus, html.dark textarea:focus { border-color: #60a5fa !important; }

/* Dark mode: tables */
html.dark table thead tr { background-color: var(--bg-tertiary) !important; }
html.dark table thead th { color: var(--text-tertiary) !important; }
html.dark table tbody tr { border-color: var(--border-secondary) !important; }
html.dark table tbody tr:hover { background-color: var(--table-hover) !important; }

/* Dark mode: modals and panels */
html.dark .animate-slide-left, html.dark [class*="slide-over"] { background-color: var(--bg-primary) !important; }
html.dark .backdrop-blur-sm { background-color: rgba(0,0,0,0.6) !important; }

/* Dark mode: kanban */
html.dark .kanban-column { background-color: var(--kanban-bg) !important; border-color: var(--border-primary) !important; }
html.dark .kanban-card { background-color: var(--kanban-card) !important; border-color: var(--border-primary) !important; }
html.dark .kanban-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important; }

/* Dark mode: dropdowns and popovers */
html.dark [class*="dropdown"], html.dark [id*="menu"] { background-color: var(--bg-primary) !important; border-color: var(--border-primary) !important; }

/* Dark mode: badges and pills */
html.dark .bg-gray-100 { background-color: var(--bg-tertiary) !important; }
html.dark .hover\:bg-gray-50:hover, html.dark .hover\:bg-gray-100:hover { background-color: var(--bg-tertiary) !important; }

/* Dark mode: AI popup */
html.dark #ai-popup { background-color: var(--bg-primary) !important; border-color: var(--border-primary) !important; }
html.dark #ai-popup .bg-gray-50 { background-color: var(--bg-tertiary) !important; }

/* Dark mode: checkboxes + radio — use accent-color and color-scheme */
html.dark input[type="checkbox"],
html.dark input[type="radio"] {
    color-scheme: dark !important;
    accent-color: #3b82f6 !important;
}

/* Dark mode: header quick-command buttons + badges */
html.dark .qcmd-btn {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border: 1px solid #334155;
}
html.dark .qcmd-btn:hover {
    background-color: rgba(59, 130, 246, 0.15) !important;
    color: #93c5fd !important;
    border-color: rgba(59, 130, 246, 0.3) !important;
}
/* Badge container inside qcmd buttons */
html.dark .qcmd-btn .bg-gray-200\/60 {
    background-color: rgba(100, 116, 139, 0.3) !important;
}
/* Badge count text */
html.dark .qcmd-btn .text-gray-500 {
    color: #e2e8f0 !important;
}
/* Green +new count */
html.dark .qcmd-btn .text-green-600 {
    color: #4ade80 !important;
}
/* Red overdue count */
html.dark .qcmd-btn .text-red-500 {
    color: #f87171 !important;
}

html.dark header .bg-primary-50 { background-color: rgba(59, 130, 246, 0.2) !important; }
html.dark header .text-primary-700 { color: #93c5fd !important; }

/* Dark mode: direction badges */
html.dark .bg-blue-50, html.dark .bg-green-50, html.dark .bg-purple-50,
html.dark .bg-orange-50, html.dark .bg-pink-50, html.dark .bg-teal-50,
html.dark .bg-cyan-50, html.dark .bg-rose-50 {
    opacity: 0.85;
}

/* Dark mode: active sidebar link */
html.dark #sidebar a.bg-primary-50,
html.dark #sidebar a.bg-primary-100 {
    background-color: rgba(59, 130, 246, 0.2) !important;
    color: #93c5fd !important;
}

/* Dark mode: table row borders cleaner */
html.dark table tbody td { border-bottom: 1px solid var(--border-secondary); }
html.dark table tbody tr:last-child td { border-bottom: none; }

/* Dark mode: notification panel */
html.dark #notif-panel { background-color: var(--bg-primary) !important; border-color: var(--border-primary) !important; }

/* Dark mode: search input in header */
html.dark header input {
    background-color: var(--bg-tertiary) !important;
    border-color: transparent !important;
}

/* Dark mode: gradient banner (dashboard welcome etc.) */
html.dark .bg-gradient-to-r.from-primary-600 { opacity: 0.9; }

/* Dark mode: white text on colored bg keeps contrast */
html.dark .text-white { color: #ffffff !important; }

/* Dark mode: card subtle glow on hover */
html.dark .card:hover, html.dark .card-sm:hover {
    box-shadow: 0 4px 20px -3px rgba(59, 130, 246, 0.1);
}

/* Dark mode: warm score badges */
html.dark .bg-orange-100 { background-color: rgba(251, 146, 60, 0.2) !important; }
html.dark .bg-yellow-100 { background-color: rgba(250, 204, 21, 0.2) !important; }

/* Dark mode: inline-styled score/heat badges — override light bg */
html.dark td .inline-flex[style*="background-color"] {
    background-color: transparent !important;
    border-color: currentColor !important;
    border-width: 1px !important;
}

/* Dark mode: scrollbar */
html.dark ::-webkit-scrollbar-track { background: var(--bg-secondary); }
html.dark ::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); }
html.dark ::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

/* ══════ Dark Mode: Chat & Messaging ══════ */

/* Team chat panel */
html.dark .team-chat-panel { background: #0f172a !important; border-color: #1e293b !important; }
html.dark .team-chat-panel .bg-white { background: #0f172a !important; }
html.dark .team-chat-panel .bg-gray-50 { background: #111827 !important; }
html.dark .team-chat-panel .border-gray-100,
html.dark .team-chat-panel .border-gray-200 { border-color: #1e293b !important; }

/* Chat reply previews */
html.dark .bg-primary-50\/50 { background-color: rgba(37, 99, 235, 0.15) !important; }
html.dark .border-primary-300 { border-color: #3b82f6 !important; }

/* Sender names in chat */
html.dark .text-primary-600 { color: #93c5fd !important; }

/* Chat conversation list active item */
html.dark .bg-primary-50 { background-color: rgba(59, 130, 246, 0.15) !important; }

/* Chat message area */
html.dark #chat-messages { background: #111827 !important; }

/* Chat input area */
html.dark #chat-input-area { background: #0f172a !important; border-color: #1e293b !important; }
html.dark #chat-input { background: #1e293b !important; border-color: #334155 !important; color: #f1f5f9 !important; }

/* Chat header */
html.dark #chat-header { border-color: #1e293b !important; }
html.dark #chat-header-title { color: #f1f5f9 !important; }

/* Inbox panel dark mode */
html.dark #inbox-messages { background: #111827 !important; }
html.dark #inbox-input-area { background: #0f172a !important; }
html.dark #inbox-msg-input { background: #1e293b !important; border-color: #334155 !important; color: #f1f5f9 !important; }

/* ══════ Dark Mode: Global Refinements ══════ */

/* Gradient text stays visible */
html.dark .from-primary-600 { color: inherit; }

/* Links in dark mode */
html.dark a.text-primary-600:hover { color: #93c5fd !important; }

/* Tag/direction badges with inline colors — keep visible */
html.dark span[style*="background"] { opacity: 0.85; }

/* Empty state text */
html.dark .text-gray-300 { color: #4b5563 !important; }
html.dark .text-gray-200 { color: #374151 !important; }

/* White cards on dark — need subtle border */
html.dark .bg-white.rounded-xl,
html.dark .bg-white.rounded-2xl {
    border-color: #334155 !important;
}

/* Pagination in dark */
html.dark .pagination-btn { color: #cbd5e1; }
html.dark .pagination-btn:hover:not(:disabled) { background-color: #334155; }
html.dark .pagination-btn.active { background-color: #2563eb; color: #fff; }

/* Toast in dark */
html.dark .toast { background-color: #1e293b !important; color: #f1f5f9 !important; border-color: #334155 !important; }

/* Slide-over modal content */
html.dark #modal-container { background-color: #1e293b !important; }
html.dark #modal-container .border-gray-100,
html.dark #modal-container .border-gray-200 { border-color: #334155 !important; }

/* Quick-create panel */
html.dark #quick-create { background-color: #1e293b !important; border-color: #334155 !important; }

/* Pipeline kanban in dark */
html.dark .kanban-column .border-gray-200 { border-color: #334155 !important; }
html.dark .stage-count { background-color: #334155 !important; color: #94a3b8 !important; }

/* Filter bar */
html.dark .bg-white.rounded-xl.border { background-color: #1e293b !important; border-color: #334155 !important; }

/* ══════ Dark Mode: Comprehensive Text & UI Fixes ══════ */

/* All inline-styled colored badges (pricing tiers, tags) — ensure readable */
html.dark span[style*="background-color"][style*="color"] {
    filter: brightness(0.85) saturate(1.2);
}

/* Product cards */
html.dark .prod-card {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}
html.dark .prod-card:hover {
    border-color: #3b82f6 !important;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.15) !important;
}

/* Tabs (Продукты/Склад/Реквизиты) */
html.dark .bg-gray-100.rounded-xl { background-color: #1e293b !important; }
html.dark .bg-white.rounded-lg.shadow-sm,
html.dark .bg-white.rounded-lg.shadow { background-color: #0f172a !important; }

/* Line-clamp text (descriptions) more visible */
html.dark .text-gray-500.line-clamp-2,
html.dark .text-gray-500.line-clamp-3 { color: #94a3b8 !important; }

/* Price text */
html.dark .text-gray-900.font-bold,
html.dark .text-gray-900.font-semibold { color: #f1f5f9 !important; }

/* Colored text on dark — make brighter */
html.dark .text-green-600 { color: #34d399 !important; }
html.dark .text-red-600 { color: #f87171 !important; }
html.dark .text-amber-600 { color: #fbbf24 !important; }
html.dark .text-primary-700 { color: #93c5fd !important; }

/* Tab active state */
html.dark .bg-white.shadow-sm { background-color: #334155 !important; }

/* Filter sidebar (product page left panel) */
html.dark .text-xs.font-bold.text-gray-700.uppercase { color: #94a3b8 !important; }

/* Radio & checkbox labels */
html.dark label .text-sm.text-gray-700 { color: #cbd5e1 !important; }
html.dark label .text-sm.text-gray-600 { color: #94a3b8 !important; }

/* Search input */
html.dark .bg-gray-50.rounded-lg input,
html.dark input.bg-gray-50 { background-color: #1e293b !important; }

/* SKU mono text */
html.dark .font-mono.text-gray-400 { color: #64748b !important; }

/* Category text */
html.dark .text-xs.text-gray-400 { color: #64748b !important; }

/* Breadcrumb/path text */
html.dark .text-gray-400 a { color: #64748b !important; }
html.dark .text-gray-400 a:hover { color: #93c5fd !important; }
