/* immoAI.guru — Dashboard Faza 3: polish, glass, animații, dark mode */

/* ── Dark theme tokens ── */
html[data-theme="dark"] {
  --accent: #6b8ae8;
  --accent-hover: #5271d8;
  --accent-dark: #96aee8;
  --accent-pale: #4a6bb5;
  --accent-light: #1e2d5c;
  --accent-soft: rgba(107, 138, 232, 0.15);
  --accent-glow: rgba(107, 138, 232, 0.25);
  --accent-rgb: 107, 138, 232;

  --bg: #0f1419;
  --bg-soft: linear-gradient(165deg, #121820 0%, #0f1419 45%, #151c26 100%);
  --surface: #1a2230;
  --surface-glass: rgba(26, 34, 48, 0.82);
  --surface-elevated: #222b3a;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.22);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.45);
  --inbox-bg: #151c26;
  --modal-overlay: rgba(0, 0, 0, 0.65);
}

html[data-theme="dark"] body.app-v4 {
  color-scheme: dark;
}

/* ── Theme toggle ── */
body.app-v4 .topbar-theme-toggle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
}

body.app-v4 .topbar-theme-toggle:hover {
  background: var(--accent-soft);
  border-color: var(--border-strong);
  color: var(--accent);
  transform: rotate(-8deg);
}

body.app-v4 .topbar-theme-toggle iconify-icon {
  font-size: 22px;
}

/* ── Tab transitions ── */
@keyframes tabFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

body.app-v4 .tab-content.tab-enter {
  animation: tabFadeIn 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes cardReveal {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

body.app-v4 .overview-kpi-grid .kpi-card {
  animation: cardReveal 0.45s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

body.app-v4 .overview-kpi-grid .kpi-card:nth-child(1) { animation-delay: 0.04s; }
body.app-v4 .overview-kpi-grid .kpi-card:nth-child(2) { animation-delay: 0.08s; }
body.app-v4 .overview-kpi-grid .kpi-card:nth-child(3) { animation-delay: 0.12s; }
body.app-v4 .overview-kpi-grid .kpi-card:nth-child(4) { animation-delay: 0.16s; }

body.app-v4 .agent-card,
body.app-v4 .channel-card-v2,
body.app-v4 .channel-card {
  animation: cardReveal 0.4s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

/* ── Glass modals ── */
body.app-v4 .modal-overlay {
  background: var(--modal-overlay, rgba(15, 23, 42, 0.42)) !important;
  backdrop-filter: blur(14px) saturate(1.15) !important;
  -webkit-backdrop-filter: blur(14px) saturate(1.15) !important;
}

body.app-v4 .modal-overlay.show .modal-content {
  animation: modalGlassIn 0.34s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

@keyframes modalGlassIn {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

body.app-v4 .modal-content {
  background: var(--surface-glass) !important;
  backdrop-filter: blur(24px) saturate(1.2) !important;
  -webkit-backdrop-filter: blur(24px) saturate(1.2) !important;
  border: 1px solid rgba(255, 255, 255, 0.22) !important;
  box-shadow:
    0 24px 80px rgba(15, 23, 42, 0.22),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset !important;
  border-radius: var(--radius-lg, 22px) !important;
}

html[data-theme="dark"] body.app-v4 .modal-content {
  border-color: rgba(255, 255, 255, 0.08) !important;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset !important;
}

body.app-v4 .modal-header {
  border-bottom-color: var(--border) !important;
  background: transparent;
}

body.app-v4 .modal-title {
  color: var(--text) !important;
}

body.app-v4 .modal-body {
  color: var(--text-muted) !important;
}

body.app-v4 .modal-footer {
  border-top-color: var(--border) !important;
}

body.app-v4 .modal-close {
  background: var(--accent-soft) !important;
  color: var(--text-muted) !important;
}

body.app-v4 .modal-close:hover {
  background: var(--accent) !important;
  color: white !important;
}

body.app-v4 .modal-btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%) !important;
  box-shadow: 0 4px 14px var(--accent-glow);
}

body.app-v4 .modal-btn-primary:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

body.app-v4 .modal-btn-secondary {
  background: var(--surface-elevated, #f1f5f9) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
}

html[data-theme="dark"] body.app-v4 .modal-btn-secondary {
  background: var(--surface-elevated) !important;
}

body.app-v4 .conv-panel-backdrop.show {
  background: var(--modal-overlay, rgba(15, 23, 42, 0.5)) !important;
  backdrop-filter: blur(10px) !important;
}

/* ── Notification dropdown — fundal solid (fără glass) ── */
body.app-v4 #notificationDropdown {
  background: #fff !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: 1px solid var(--border, #e2e8f0) !important;
}

body.app-v4 #notificationDropdown > div:first-child {
  background: #fff !important;
}

html[data-theme="dark"] body.app-v4 .user-dropdown-header div {
  color: var(--text) !important;
}

html[data-theme="dark"] body.app-v4 .user-dropdown-item:hover {
  background: var(--accent-soft) !important;
}

/* ── Form polish ── */
body.app-v4 input,
body.app-v4 textarea,
body.app-v4 select,
body.app-v4 .custom-select-trigger {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
  transition: border-color 0.18s, box-shadow 0.18s !important;
}

body.app-v4 input::placeholder,
body.app-v4 textarea::placeholder {
  color: var(--text-dim);
}

body.app-v4 .info-box {
  background: var(--accent-soft) !important;
  border-left-color: var(--accent) !important;
  color: var(--text) !important;
  border-radius: var(--radius-sm) !important;
}

html[data-theme="dark"] body.app-v4 .info-box {
  background: rgba(107, 138, 232, 0.12) !important;
}

body.app-v4 button:not(.nav-item):not(.conv-row-delete):not(.agent-action-btn):not(.mod-btn):not(.topbar-bell):not(.topbar-theme-toggle):not(.sidebar-toggle):not(.modal-close):not(.modal-btn):not(.conv-mode-btn):not(.quick-action-btn) {
  transition: transform 0.12s, box-shadow 0.15s, filter 0.15s;
}

body.app-v4 button:not(.nav-item):not(.conv-row-delete):hover:not(:disabled) {
  filter: brightness(1.03);
}

/* ── Dark: component overrides ── */
html[data-theme="dark"] body.app-v4 .card,
html[data-theme="dark"] body.app-v4 .mod-panel,
html[data-theme="dark"] body.app-v4 .mod-page-header,
html[data-theme="dark"] body.app-v4 .kpi-card:not(.kpi-card--primary),
html[data-theme="dark"] body.app-v4 .overview-panel,
html[data-theme="dark"] body.app-v4 .agent-card,
html[data-theme="dark"] body.app-v4 .channel-card-v2,
html[data-theme="dark"] body.app-v4 .channel-module,
html[data-theme="dark"] body.app-v4 .kn-wizard-progress,
html[data-theme="dark"] body.app-v4 .kn-stat-card,
html[data-theme="dark"] body.app-v4 .mod-inbox-shell {
  background: var(--surface) !important;
  border-color: var(--border) !important;
}

html[data-theme="dark"] body.app-v4 .kpi-card--primary {
  background: linear-gradient(135deg, #3d5299 0%, #5271d8 55%, #6b8ae8 100%) !important;
}

html[data-theme="dark"] body.app-v4 #conversationsInboxCol {
  background: var(--inbox-bg) !important;
}

html[data-theme="dark"] body.app-v4 #conversationsPanelCol {
  background: var(--surface) !important;
  border-color: var(--border) !important;
}

html[data-theme="dark"] body.app-v4 .conv-row {
  background: var(--surface-elevated) !important;
  border-color: var(--border) !important;
}

html[data-theme="dark"] body.app-v4 .conv-row:hover {
  background: var(--accent-soft) !important;
}

html[data-theme="dark"] body.app-v4 h1,
html[data-theme="dark"] body.app-v4 h2,
html[data-theme="dark"] body.app-v4 h3,
html[data-theme="dark"] body.app-v4 h4 {
  color: var(--text);
}

html[data-theme="dark"] body.app-v4 label {
  color: var(--text-muted);
}

html[data-theme="dark"] body.app-v4 .alert-info {
  background: rgba(107, 138, 232, 0.15) !important;
  color: var(--text) !important;
}

html[data-theme="dark"] body.app-v4 .alert-error,
html[data-theme="dark"] body.app-v4 .alert-danger {
  background: rgba(239, 68, 68, 0.15) !important;
}

html[data-theme="dark"] body.app-v4 .alert-success {
  background: rgba(16, 185, 129, 0.15) !important;
}

html[data-theme="dark"] body.app-v4 #createAgentForm {
  background: var(--surface-elevated) !important;
}

html[data-theme="dark"] body.app-v4 .code-block,
html[data-theme="dark"] body.app-v4 .announcement-summary {
  background: var(--inbox-bg) !important;
  color: var(--text-muted) !important;
}

/* ── Toast polish ── */
@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

body.app-v4 [id^="floatingToast"] > div,
body.app-v4 .floating-toast-item {
  animation: toastSlideIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-sm) !important;
}

/* ── Loading overlay ── */
body.app-v4 .loading-overlay {
  background: var(--modal-overlay, rgba(15, 23, 42, 0.55)) !important;
  backdrop-filter: blur(8px) !important;
}

body.app-v4 .loading-overlay p {
  color: var(--text) !important;
}

/* ── Nav micro-interaction ── */
body.app-v4 .nav-item {
  transition: background 0.18s, color 0.18s, box-shadow 0.18s, transform 0.12s !important;
}

body.app-v4 .nav-item:active {
  transform: scale(0.98);
}

body.app-v4 .nav-item.active {
  transition: background 0.22s, box-shadow 0.22s !important;
}

/* ── Login page dark mode ── */
html[data-theme="dark"] body.login-v4 {
  background: var(--bg-soft) !important;
}

html[data-theme="dark"] body.login-v4 .container {
  background: var(--surface-glass) !important;
  border-color: var(--border) !important;
}

html[data-theme="dark"] body.login-v4 input {
  background: var(--surface-elevated) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

html[data-theme="dark"] body.login-v4 .logo p,
html[data-theme="dark"] body.login-v4 label {
  color: var(--text-muted) !important;
}

/* ── Knowledge refresh btn (Conflicte card) ── */
body.app-v4 .kn-refresh-btn {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

body.app-v4 .kn-refresh-btn:hover:not(:disabled) {
  background: var(--accent-soft);
}

body.app-v4 .kn-refresh-btn:disabled {
  cursor: wait;
}

/* ── Dark: legacy embedded styles + inline light blocks ── */
html[data-theme="dark"] body.app-v4 .card {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

html[data-theme="dark"] body.app-v4 p {
  color: inherit;
}

html[data-theme="dark"] body.app-v4 h1,
html[data-theme="dark"] body.app-v4 h2,
html[data-theme="dark"] body.app-v4 h3,
html[data-theme="dark"] body.app-v4 h4,
html[data-theme="dark"] body.app-v4 h5,
html[data-theme="dark"] body.app-v4 h6 {
  color: var(--text);
}

html[data-theme="dark"] body.app-v4 .stat-card,
html[data-theme="dark"] body.app-v4 .kn-stat-card {
  background: var(--surface) !important;
}

html[data-theme="dark"] body.app-v4 .knowledge-subtab {
  color: var(--text-muted) !important;
}

html[data-theme="dark"] body.app-v4 .knowledge-subtab.active {
  color: var(--accent) !important;
  background: var(--accent-soft) !important;
}

html[data-theme="dark"] body.app-v4 .wizard-btn {
  background: var(--surface) !important;
  border-color: var(--border-strong) !important;
}

html[data-theme="dark"] body.app-v4 .wizard-btn-refresh {
  color: var(--accent) !important;
  border-color: var(--accent) !important;
}

html[data-theme="dark"] body.app-v4 .wizard-btn-save {
  color: #4ade80 !important;
  border-color: #4ade80 !important;
}

html[data-theme="dark"] body.app-v4 .wizard-btn-edit {
  color: var(--accent) !important;
  border-color: var(--accent) !important;
}

/* Knowledge wizard — section panels */
html[data-theme="dark"] body.app-v4 #perplexityContent,
html[data-theme="dark"] body.app-v4 #manualTextContent,
html[data-theme="dark"] body.app-v4 #urlContent,
html[data-theme="dark"] body.app-v4 #documentContent,
html[data-theme="dark"] body.app-v4 #perplexitySourcesList,
html[data-theme="dark"] body.app-v4 #manualTextSourcesList,
html[data-theme="dark"] body.app-v4 #urlSourcesList,
html[data-theme="dark"] body.app-v4 #documentSourcesList,
html[data-theme="dark"] body.app-v4 #agentPerplexityContent,
html[data-theme="dark"] body.app-v4 #agentManualTextContent,
html[data-theme="dark"] body.app-v4 #agentUrlContent,
html[data-theme="dark"] body.app-v4 #agentDocumentContent,
html[data-theme="dark"] body.app-v4 #agentPerplexitySourcesList,
html[data-theme="dark"] body.app-v4 #agentManualTextSourcesList,
html[data-theme="dark"] body.app-v4 #agentUrlSourcesList,
html[data-theme="dark"] body.app-v4 #agentDocumentSourcesList,
html[data-theme="dark"] body.app-v4 #chatContainer,
html[data-theme="dark"] body.app-v4 #createAgentForm,
html[data-theme="dark"] body.app-v4 .channel-module {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text-muted) !important;
}

html[data-theme="dark"] body.app-v4 #uploadZone,
html[data-theme="dark"] body.app-v4 #agentUploadZone {
  background: var(--surface-elevated) !important;
  border-color: var(--accent) !important;
}

html[data-theme="dark"] body.app-v4 #notificationDropdown {
  background: var(--surface) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}

html[data-theme="dark"] body.app-v4 #notificationDropdown > div:first-child {
  background: var(--surface) !important;
}

html[data-theme="dark"] body.app-v4 #emailVerificationAlert {
  background: rgba(251, 191, 36, 0.12) !important;
  color: var(--text) !important;
}

/* Accordion headers in Manualul Agenției */
html[data-theme="dark"] body.app-v4 .knowledge-section > div > div[onclick] {
  background: linear-gradient(135deg, var(--surface-elevated) 0%, var(--surface) 100%) !important;
}

html[data-theme="dark"] body.app-v4 .knowledge-section > div > div[onclick] > div[style*="color: #333"],
html[data-theme="dark"] body.app-v4 .knowledge-section div[style*="color: #333"] {
  color: var(--text) !important;
}

html[data-theme="dark"] body.app-v4 .knowledge-section div[style*="color: #666"],
html[data-theme="dark"] body.app-v4 .knowledge-section div[style*="color:#666"] {
  color: var(--text-muted) !important;
}

/* Toggle circles (perplexity, manual, url, document) */
html[data-theme="dark"] body.app-v4 #perplexityToggle,
html[data-theme="dark"] body.app-v4 #manualTextToggle,
html[data-theme="dark"] body.app-v4 #urlToggle,
html[data-theme="dark"] body.app-v4 #documentToggle,
html[data-theme="dark"] body.app-v4 #perplexityQuestionsToggle,
html[data-theme="dark"] body.app-v4 #agentPerplexityToggle,
html[data-theme="dark"] body.app-v4 #agentManualTextToggle,
html[data-theme="dark"] body.app-v4 #agentUrlToggle,
html[data-theme="dark"] body.app-v4 #agentDocumentToggle {
  background: var(--surface) !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

/* Wizard step inner panels (#f8f9fa blocks) */
html[data-theme="dark"] body.app-v4 #wizardSection div[style*="background: #f8f9fa"],
html[data-theme="dark"] body.app-v4 #wizardSection div[style*="background:#f8f9fa"],
html[data-theme="dark"] body.app-v4 #rulesSection div[style*="background: #f8f9fa"],
html[data-theme="dark"] body.app-v4 #createAgentForm div[style*="background: #f8f9fa"],
html[data-theme="dark"] body.app-v4 #createAgentForm div[style*="background: white"],
html[data-theme="dark"] body.app-v4 #perplexityContent div[style*="background: #f8f9fa"] {
  background: var(--surface-elevated) !important;
  color: var(--text-muted) !important;
}

html[data-theme="dark"] body.app-v4 #wizardSection div[style*="background: #fff3cd"],
html[data-theme="dark"] body.app-v4 #rulesSection div[style*="background: #fff3cd"],
html[data-theme="dark"] body.app-v4 .info-box[style*="background: #fff3cd"] {
  background: rgba(251, 191, 36, 0.12) !important;
  color: var(--text) !important;
}

html[data-theme="dark"] body.app-v4 #autoFillBtn {
  background: var(--surface) !important;
  color: var(--accent) !important;
}

/* Broad catch-all for remaining inline white/light backgrounds */
html[data-theme="dark"] body.app-v4 [style*="background: white"],
html[data-theme="dark"] body.app-v4 [style*="background:white"],
html[data-theme="dark"] body.app-v4 [style*="background: #fff"],
html[data-theme="dark"] body.app-v4 [style*="background:#fff"],
html[data-theme="dark"] body.app-v4 [style*="background: #f8f9fa"],
html[data-theme="dark"] body.app-v4 [style*="background:#f8f9fa"],
html[data-theme="dark"] body.app-v4 [style*="background: #f8fafc"],
html[data-theme="dark"] body.app-v4 [style*="background:#f8fafc"],
html[data-theme="dark"] body.app-v4 [style*="background: #f1f5f9"],
html[data-theme="dark"] body.app-v4 [style*="background:#f1f5f9"] {
  background: var(--surface-elevated) !important;
}

html[data-theme="dark"] body.app-v4 [style*="color: #333"],
html[data-theme="dark"] body.app-v4 [style*="color:#333"],
html[data-theme="dark"] body.app-v4 [style*="color: #212529"],
html[data-theme="dark"] body.app-v4 [style*="color: #1a202c"] {
  color: var(--text) !important;
}

html[data-theme="dark"] body.app-v4 [style*="color: #666"],
html[data-theme="dark"] body.app-v4 [style*="color:#666"],
html[data-theme="dark"] body.app-v4 [style*="color: #495057"],
html[data-theme="dark"] body.app-v4 [style*="color: #6c757d"] {
  color: var(--text-muted) !important;
}

html[data-theme="dark"] body.app-v4 [style*="border: 2px solid #e0e0e0"],
html[data-theme="dark"] body.app-v4 [style*="border: 1px solid #e0e0e0"],
html[data-theme="dark"] body.app-v4 [style*="border: 1px solid #ddd"] {
  border-color: var(--border) !important;
}

html[data-theme="dark"] body.app-v4 mark[style*="background:#ffcccc"] {
  background: rgba(239, 68, 68, 0.25) !important;
  color: var(--text) !important;
}

html[data-theme="dark"] body.app-v4 #conflictsList div[style*="background:#fff8f8"],
html[data-theme="dark"] body.app-v4 #conflictsList div[style*="background:white"],
html[data-theme="dark"] body.app-v4 #conflictsList div[style*="background:#f0fff4"],
html[data-theme="dark"] body.app-v4 #conflictsList div[style*="background:#fff5f5"] {
  background: var(--surface-elevated) !important;
}

html[data-theme="dark"] body.app-v4 #conflictsModalIntro {
  color: var(--text-muted) !important;
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  body.app-v4 .tab-content.tab-enter,
  body.app-v4 .overview-kpi-grid .kpi-card,
  body.app-v4 .agent-card,
  body.app-v4 .channel-card-v2,
  body.app-v4 .modal-overlay.show .modal-content {
    animation: none !important;
  }

  body.app-v4 .nav-item:active {
    transform: none;
  }
}
