/* ============================================================
   DPO - Data Performance Optimizer
   Custom Theme & Visual Polish — Light Mode
   PeopleWorks Services, LLC & Xari Technologies
   ============================================================ */

/* ============ ROOT VARIABLES ============ */
:root {
  --dpo-bg: #f4f7fb;
  --dpo-surface: #ffffff;
  --dpo-primary-dark: #0f2b46;
  --dpo-primary-light: #1a4a7a;
  --dpo-accent: #2ea3f2;
  --dpo-accent-glow: #47b5ff;
  --dpo-gold: #f0a500;
  --dpo-success: #10b981;
  --dpo-warning: #f59e0b;
  --dpo-danger: #ef4444;
  --dpo-text: #1e293b;
  --dpo-text-light: #64748b;
  --dpo-border: #e2e8f0;
  --dpo-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  --dpo-shadow-lg: 0 4px 16px rgba(0,0,0,0.1), 0 12px 40px rgba(0,0,0,0.06);
}

/* ============ GLOBAL POLISH ============ */
html {
  scroll-behavior: smooth;
}

body {
  background: var(--dpo-bg) !important;
  color: var(--dpo-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbar — subtle for light theme */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ============ ANIMATIONS ============ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 rgba(46, 163, 242, 0); }
  50% { box-shadow: 0 0 16px rgba(46, 163, 242, 0.15); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes scoreReveal {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

/* ============ MUD OVERRIDES ============ */

/* Main content — proper spacing below fixed AppBar */
.mud-main-content {
  padding: 24px !important;
  padding-top: 76px !important;
}

/* App Bar — dark gradient (matches landing hero) */
.mud-appbar {
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(46, 163, 242, 0.1) !important;
}

/* Drawer — dark background with smooth transitions */
.mud-drawer {
  border-right: 1px solid rgba(46, 163, 242, 0.08) !important;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Drawer nav links — light text on dark bg */
.mud-drawer .mud-nav-link {
  border-radius: 8px !important;
  margin: 2px 8px !important;
  transition: all 0.2s ease !important;
  color: #e2e8f0 !important;
}

.mud-drawer .mud-nav-link .mud-nav-link-text {
  color: #e2e8f0 !important;
}

.mud-drawer .mud-nav-link .mud-icon-root {
  color: #94a3b8 !important;
}

.mud-drawer .mud-nav-link:hover {
  background: rgba(46, 163, 242, 0.08) !important;
}

.mud-drawer .mud-nav-link:hover .mud-icon-root {
  color: #2ea3f2 !important;
}

.mud-drawer .mud-nav-link.active {
  background: rgba(46, 163, 242, 0.15) !important;
  border-left: none !important;
  position: relative;
}

.mud-drawer .mud-nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--dpo-accent);
  border-radius: 0 3px 3px 0;
}

.mud-drawer .mud-nav-link.active .mud-nav-link-text,
.mud-drawer .mud-nav-link.active .mud-icon-root {
  color: #2ea3f2 !important;
}

.mud-drawer .mud-nav-link.active .mud-icon-root {
  filter: drop-shadow(0 0 4px rgba(46, 163, 242, 0.4));
}

/* Cards — theme-aware background */
.mud-paper, .mud-card {
  border: 1px solid var(--mud-palette-lines-default, #e2e8f0) !important;
  box-shadow: var(--dpo-shadow) !important;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.mud-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--dpo-shadow-lg) !important;
}

/* Tables — theme-aware */
.mud-table {
  border-radius: 12px !important;
  overflow: hidden;
  border: 1px solid var(--mud-palette-lines-default, #e2e8f0) !important;
  box-shadow: var(--dpo-shadow) !important;
}

.mud-table-head .mud-table-cell {
  background: var(--dpo-primary-dark) !important;
  color: #ffffff !important;
  font-size: 11px !important;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600 !important;
  border-bottom: 1px solid var(--mud-palette-lines-default, #e2e8f0) !important;
}

.mud-table-body .mud-table-row {
  transition: background 0.15s ease !important;
}

.mud-table-body .mud-table-row:hover {
  background: var(--mud-palette-table-hover, #f1f5f9) !important;
}

.mud-table-body .mud-table-cell {
  border-bottom: 1px solid var(--mud-palette-lines-default, #e2e8f0) !important;
}

/* Chips — light background with accent text */
.mud-chip {
  backdrop-filter: blur(4px);
  transition: all 0.2s ease !important;
}

.mud-chip.mud-chip-color-primary {
  background: rgba(46, 163, 242, 0.1) !important;
  color: #1a7fd4 !important;
}

.mud-chip.mud-chip-color-success {
  background: rgba(16, 185, 129, 0.1) !important;
  color: #0d9668 !important;
}

.mud-chip.mud-chip-color-warning {
  background: rgba(245, 158, 11, 0.1) !important;
  color: #b97a08 !important;
}

.mud-chip.mud-chip-color-error {
  background: rgba(239, 68, 68, 0.1) !important;
  color: #dc2626 !important;
}

/* Progress bars — rounded, smooth */
.mud-progress-linear {
  border-radius: 6px !important;
  overflow: hidden;
  background: #e2e8f0 !important;
}

.mud-progress-linear .mud-progress-linear-bar {
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Buttons — polish */
.mud-button-filled {
  transition: all 0.2s ease !important;
}

.mud-button-filled:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(46, 163, 242, 0.3) !important;
}

/* Tabs — clean with border */
.mud-tabs-toolbar {
  border-bottom: 1px solid var(--dpo-border) !important;
}

/* Dialogs */
.mud-dialog {
  background: var(--dpo-surface) !important;
  border: 1px solid var(--dpo-border) !important;
  border-radius: 16px !important;
  box-shadow: var(--dpo-shadow-lg) !important;
}

/* Tooltip */
.mud-tooltip {
  background: var(--dpo-surface) !important;
  color: var(--dpo-text) !important;
  border: 1px solid var(--dpo-border) !important;
  border-radius: 8px !important;
  box-shadow: var(--dpo-shadow-lg) !important;
}

/* ============ DPO CUSTOM CLASSES ============ */

/* Animated entrance for page content */
.dpo-page-enter {
  animation: fadeInUp 0.4s ease-out;
}

/* Section tag — matches landing page .section-tag */
.dpo-section-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  background: rgba(46, 163, 242, 0.08);
  border: 1px solid rgba(46, 163, 242, 0.2);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--dpo-accent);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 12px;
}

/* KPI Card hover glow */
.dpo-kpi-card {
  position: relative;
  overflow: hidden;
}
.dpo-kpi-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.3s ease;
  box-shadow: inset 0 0 20px rgba(46, 163, 242, 0.06);
  pointer-events: none;
}
.dpo-kpi-card:hover::after {
  opacity: 1;
}

/* Score number animation */
.dpo-score-value {
  animation: scoreReveal 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Severity indicators */
.dpo-severity-critical { color: #ef4444; }
.dpo-severity-high { color: #f97316; }
.dpo-severity-medium { color: #f59e0b; }
.dpo-severity-low { color: #2ea3f2; }

.dpo-severity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}
.dpo-severity-dot.critical { background: #ef4444; box-shadow: 0 0 6px rgba(239, 68, 68, 0.4); }
.dpo-severity-dot.high { background: #f97316; box-shadow: 0 0 6px rgba(249, 115, 22, 0.4); }
.dpo-severity-dot.medium { background: #f59e0b; box-shadow: 0 0 6px rgba(245, 158, 11, 0.4); }
.dpo-severity-dot.low { background: #2ea3f2; box-shadow: 0 0 6px rgba(46, 163, 242, 0.4); }

/* Card border accents */
.dpo-border-critical { border-left: 3px solid #ef4444 !important; }
.dpo-border-high { border-left: 3px solid #f97316 !important; }
.dpo-border-medium { border-left: 3px solid #f59e0b !important; }
.dpo-border-low { border-left: 3px solid #2ea3f2 !important; }
.dpo-border-success { border-left: 3px solid #10b981 !important; }

/* Region chips */
.dpo-region-americas { background: rgba(16, 185, 129, 0.1) !important; color: #0d9668 !important; }
.dpo-region-europe { background: rgba(245, 158, 11, 0.1) !important; color: #b97a08 !important; }
.dpo-region-asia { background: rgba(239, 68, 68, 0.1) !important; color: #dc2626 !important; }

/* Gradient text */
.dpo-gradient-text {
  background: linear-gradient(135deg, var(--dpo-accent) 0%, var(--dpo-accent-glow) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Code blocks (for T-SQL) */
.dpo-code-block {
  background: #1e293b;
  border: 1px solid var(--dpo-border);
  border-radius: 8px;
  padding: 16px;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  color: #e2e8f0;
  line-height: 1.6;
  overflow-x: auto;
  position: relative;
}
.dpo-code-block::before {
  content: 'T-SQL';
  position: absolute;
  top: 6px;
  right: 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(148, 163, 184, 0.6);
  font-family: 'Inter', sans-serif;
}

/* Chat bubbles */
.dpo-chat-bubble {
  border-radius: 12px;
  padding: 12px 16px;
  max-width: 85%;
  animation: fadeInUp 0.3s ease-out;
}
.dpo-chat-user {
  background: rgba(46, 163, 242, 0.08);
  border: 1px solid rgba(46, 163, 242, 0.15);
  color: var(--dpo-text);
  margin-left: auto;
}
.dpo-chat-ai {
  background: rgba(16, 185, 129, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.12);
  color: var(--dpo-text);
}
.dpo-chat-system {
  background: #f1f5f9;
  border: 1px solid var(--dpo-border);
  text-align: center;
  font-size: 12px;
  color: var(--dpo-text-light);
}

/* Online indicator pulse */
.dpo-online-dot {
  width: 8px;
  height: 8px;
  background: var(--dpo-success);
  border-radius: 50%;
  display: inline-block;
  animation: pulseGlow 2s infinite;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

/* Section dividers */
.dpo-section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.dpo-section-header h6 {
  font-weight: 700;
  color: var(--dpo-text);
}
.dpo-section-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--dpo-border), transparent);
}

/* Staggered card entrance */
.mud-grid > .mud-item:nth-child(1) { animation: fadeInUp 0.3s ease-out 0.0s both; }
.mud-grid > .mud-item:nth-child(2) { animation: fadeInUp 0.3s ease-out 0.05s both; }
.mud-grid > .mud-item:nth-child(3) { animation: fadeInUp 0.3s ease-out 0.1s both; }
.mud-grid > .mud-item:nth-child(4) { animation: fadeInUp 0.3s ease-out 0.15s both; }
.mud-grid > .mud-item:nth-child(5) { animation: fadeInUp 0.3s ease-out 0.2s both; }
.mud-grid > .mud-item:nth-child(6) { animation: fadeInUp 0.3s ease-out 0.25s both; }
.mud-grid > .mud-item:nth-child(7) { animation: fadeInUp 0.3s ease-out 0.3s both; }
.mud-grid > .mud-item:nth-child(8) { animation: fadeInUp 0.3s ease-out 0.35s both; }

/* Loading skeleton shimmer — light theme */
.dpo-shimmer {
  background: linear-gradient(90deg,
    #e2e8f0 25%,
    #f1f5f9 50%,
    #e2e8f0 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

/* Footer branding */
.dpo-branding {
  text-align: center;
  padding: 16px;
  color: var(--dpo-text-light);
  font-size: 11px;
  letter-spacing: 0.5px;
}
.dpo-branding .pw { color: var(--dpo-gold); font-weight: 600; }
.dpo-branding .xari { color: var(--dpo-accent); font-weight: 600; }

/* Dark card wrapper — prevents global .mud-paper from forcing white bg */
.dpo-dark-card.mud-paper {
  background: linear-gradient(135deg, #0f2b46 0%, #132f4c 100%) !important;
  border: none !important;
  border-left: 4px solid var(--dpo-accent) !important;
}

/* Dark table inside dark cards (AI Quick Wins) — override ALL global light styles */
.dpo-dark-card .mud-table,
.dpo-dark-card .mud-simple-table {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}
.dpo-dark-card table {
  background: transparent !important;
}
.dpo-dark-card thead th,
.dpo-dark-card .mud-table-head .mud-table-cell {
  background: transparent !important;
  color: #94a3b8 !important;
  border: none !important;
  border-bottom: 1px solid rgba(255,255,255,0.1) !important;
  font-size: 11px !important;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600 !important;
}
.dpo-dark-card tbody td,
.dpo-dark-card .mud-table-body .mud-table-cell {
  color: #f1f5f9 !important;
  border-bottom: 1px solid rgba(255,255,255,0.05) !important;
}
.dpo-dark-card tbody td.dpo-col-num {
  color: #94a3b8 !important;
  font-weight: 600 !important;
}
.dpo-dark-card tbody td.dpo-col-impact {
  color: #10b981 !important;
  font-weight: 700 !important;
}
.dpo-dark-card tbody td.dpo-col-effort {
  color: #94a3b8 !important;
}
.dpo-dark-card tbody tr:hover {
  background: rgba(255,255,255,0.04) !important;
}
.dpo-dark-card .mud-chip {
  border: none !important;
  box-shadow: none !important;
}

/* Notification hover */
.dpo-notification-item:hover {
  background: #f8fafc;
}

/* Popover overrides — prevent card/paper global styles from breaking popovers */
.mud-popover-cascading-value .mud-paper {
  border: none !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08) !important;
}

/* User menu card */
.mud-menu .mud-list {
  padding: 4px 0 !important;
}

/* ============ DARK MODE ENHANCEMENTS ============ */

/* When MudBlazor dark mode is active, it sets .mud-theme-dark on <html> */
.mud-theme-dark ::-webkit-scrollbar-track {
  background: #1e293b;
}
.mud-theme-dark ::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 4px;
}
.mud-theme-dark ::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

.mud-theme-dark .dpo-shimmer {
  background: linear-gradient(90deg,
    #1e293b 25%,
    #334155 50%,
    #1e293b 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.mud-theme-dark .dpo-notification-item:hover {
  background: #1e293b;
}

.mud-theme-dark .dpo-chat-system {
  background: #1e293b;
  border: 1px solid #334155;
  color: #94a3b8;
}

.mud-theme-dark .dpo-section-tag {
  background: rgba(46, 163, 242, 0.12);
  border-color: rgba(46, 163, 242, 0.3);
}

/* Notification badge position fix — move closer to bell icon */
.dpo-badge-fix .mud-badge-wrapper .mud-badge {
  top: 6px !important;
  right: 2px !important;
}

/* ============ HELP DRAWER ============ */
/* Uses custom fixed panel, not MudDrawer */

/* ============ GLOBAL SEARCH ============ */
.dpo-search-field .mud-input-outlined { border-color: rgba(255,255,255,0.15) !important; }
.dpo-search-field .mud-input-outlined:hover { border-color: rgba(255,255,255,0.3) !important; }
.dpo-search-field input { color: #fff !important; font-size: 13px !important; }
.dpo-search-field input::placeholder { color: rgba(255,255,255,0.35) !important; }
.dpo-search-field .mud-input-adornment-start .mud-icon-root { color: rgba(255,255,255,0.4) !important; }

/* ============ SANKEY ============ */
.dpo-sankey-link { transition: opacity 0.2s; }
.dpo-sankey-link:hover { opacity: 0.9 !important; }
.dpo-sankey-node { transition: opacity 0.2s; }
.dpo-sankey-node:hover { opacity: 0.8; }

/* ============ HEAT MAP ============ */
.dpo-heat-cell:hover { transform: scale(1.08); border-color: rgba(255,255,255,0.5) !important; box-shadow: 0 4px 16px rgba(0,0,0,0.2); }

/* ============ DARK MODE ============ */
.mud-theme-dark .dpo-page-enter,
.mud-theme-dark .mud-paper:not(.mud-alert) {
  background: var(--mud-palette-surface) !important;
  color: var(--mud-palette-text-primary) !important;
}
.mud-theme-dark .mud-table-cell,
.mud-theme-dark .mud-table-head .mud-table-cell {
  color: var(--mud-palette-text-primary) !important;
}
.mud-theme-dark .dpo-section-tag {
  background: rgba(46,163,242,0.15) !important;
}
.mud-theme-dark .dpo-dark-card {
  background: var(--mud-palette-surface) !important;
}
.mud-theme-dark .mud-input,
.mud-theme-dark .mud-input-label,
.mud-theme-dark .mud-select-input {
  color: var(--mud-palette-text-primary) !important;
}
.mud-theme-dark .mud-chip {
  border-color: rgba(255,255,255,0.1) !important;
}
.mud-theme-dark .dpo-branding {
  background: #0a1220 !important;
  color: rgba(255,255,255,0.4) !important;
}
.mud-theme-dark .dpo-branding .pw { color: #f0a500 !important; }
.mud-theme-dark .dpo-branding .xari { color: #2ea3f2 !important; }

/* Dark mode for help drawer */
.mud-theme-dark .dpo-ai-response code,
.mud-theme-dark .dpo-ai-response pre {
  background: #1e293b !important;
  color: #e2e8f0 !important;
}
.mud-theme-dark .dpo-ai-response blockquote {
  background: #1e293b !important;
  color: #94a3b8 !important;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 960px) {
  .dpo-chat-bubble { max-width: 95%; }
}
