/* ==========================================================================
   SERVICE & TRADING RECONCILER - DESIGN SYSTEM & MAIN STYLESHEET
   Fintech Aesthetic with Glassmorphism, Dark/Light Mode & Dynamic Transitions
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root,
[data-theme="light"] {
  /* Color Palette - Luxury Gold & Executive Slate Light Theme */
  --bg-app: #fcfbf8;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #faf7f0;
  --bg-elevated: #ffffff;
  --bg-input: #ffffff;

  --border-subtle: #f0ede4;
  --border-focus: #d97706;
  --border-card: #e8e4d8;

  --text-primary: #1c1917;
  --text-secondary: #57534e;
  --text-muted: #a8a29e;

  /* Brand Accents - Luxury Gold Gradient */
  --brand-navy: #78350f;
  --brand-primary: #d97706;
  --brand-primary-hover: #b45309;
  --brand-gradient: linear-gradient(135deg, #b45309 0%, #d97706 45%, #f59e0b 100%);
  --brand-glow: rgba(217, 119, 6, 0.25);

  /* Financial Status Colors - High-Contrast Precision Pastels */
  --color-matched: #059669;
  --bg-matched: #ecfdf5;
  --border-matched: #a7f3d0;

  --color-leak: #dc2626;
  --bg-leak: #fef2f2;
  --border-leak: #fecaca;

  --color-overcharged: #b45309;
  --bg-overcharged: #fef9c3;
  --border-overcharged: #fde047;

  --color-missing: #7c3aed;
  --bg-missing: #f5f3ff;
  --border-missing: #ddd6fe;

  --color-mismatch: #0891b2;
  --bg-mismatch: #ecfeff;
  --border-mismatch: #a5f3fc;

  /* Table & Container Colors */
  --bg-table-th: #fbf9f4;
  --text-table-th: #1c1917;
  --border-table: #e5dfd0;
  --bg-table-hover: #fefdf8;
  --table-sticky-shadow: 4px 0 10px -2px rgba(180, 83, 9, 0.08);

  --bg-subtle-box: #fbf9f4;
  --border-subtle-box: #e8e4d8;
  --bg-modal-footer: #fbf9f4;

  --scrollbar-track: #fbf9f4;
  --scrollbar-thumb: #dcd6c5;
  --scrollbar-thumb-hover: #b45309;

  /* Elevation & Effects */
  --shadow-sm: 0 1px 2px 0 rgba(28, 25, 23, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(28, 25, 23, 0.06), 0 2px 4px -2px rgba(28, 25, 23, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(28, 25, 23, 0.08), 0 4px 6px -4px rgba(28, 25, 23, 0.04);
  --shadow-glow: 0 0 20px rgba(217, 119, 6, 0.2);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Luxury Gold Navigation & Header Refinements */
.app-sidebar {
  background-color: #ffffff;
  border-right-color: #f0ede4;
}

.nav-item {
  color: #57534e;
}

.nav-item:hover {
  background-color: #fbf9f4;
  color: #1c1917;
}

.top-navbar {
  background-color: rgba(255, 255, 255, 0.96);
  border-bottom-color: #f0ede4;
  box-shadow: 0 1px 3px rgba(28, 25, 23, 0.04);
}

.period-badge-group {
  background-color: #fbf9f4;
  border-color: #e5dfd0;
}

.period-badge-group label {
  color: #57534e;
}

/* Base Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: auto;
  display: flex;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Code and Mono Elements */
code,
pre,
.font-mono {
  font-family: 'JetBrains Mono', monospace;
}

/* App Container Layout */
#app-container {
  display: flex;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  position: relative;
}

/* Sidebar Styles */
.app-sidebar {
  width: 270px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  transition: width var(--transition-normal);
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--brand-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 20px;
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
}

.brand-info h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.brand-info span {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  display: block;
}

.sidebar-nav {
  padding: 20px 12px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.nav-item:hover {
  background-color: #f1f5f9;
  color: var(--text-primary);
  transform: translateX(3px);
}

.nav-item.active {
  background: var(--brand-gradient);
  color: #ffffff;
  box-shadow: 0 4px 12px var(--brand-glow);
}

.nav-item .nav-icon {
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background-color: var(--bg-leak);
  color: var(--color-leak);
  border: 1px solid var(--border-leak);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.db-status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  color: #15803d;
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.25);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.db-status-badge.status-postgres {
  color: #047857;
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
}

.db-status-badge.status-sqlite {
  color: #b45309;
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.8);
  animation: pulse-dot 2.5s infinite;
}

@keyframes pulse-dot {
  0% {
    transform: scale(0.95);
    opacity: 0.8;
  }

  50% {
    transform: scale(1.15);
    opacity: 1;
    box-shadow: 0 0 10px rgba(16, 185, 129, 1);
  }

  100% {
    transform: scale(0.95);
    opacity: 0.8;
  }
}

.btn-xs {
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

/* Main Content Area */
.app-main {
  margin-left: 270px;
  flex: 1 1 0;
  min-width: 0;
  width: calc(100% - 270px);
  max-width: calc(100% - 270px);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--bg-app);
  transition: margin-left var(--transition-normal), width var(--transition-normal), max-width var(--transition-normal);
}

/* Sidebar Collapsed State (User toggle or zoomed/compact view) */
#app-container.sidebar-collapsed .app-sidebar {
  width: 70px;
}

#app-container.sidebar-collapsed .app-sidebar .brand-info,
#app-container.sidebar-collapsed .app-sidebar .nav-text,
#app-container.sidebar-collapsed .app-sidebar .nav-badge,
#app-container.sidebar-collapsed .app-sidebar .sidebar-footer {
  display: none !important;
}

#app-container.sidebar-collapsed .app-sidebar .sidebar-header {
  padding: 18px 12px;
  justify-content: center;
}

#app-container.sidebar-collapsed .app-sidebar .brand-icon {
  margin: 0 auto;
}

#app-container.sidebar-collapsed .app-sidebar .sidebar-nav {
  padding: 16px 8px;
}

#app-container.sidebar-collapsed .app-sidebar .nav-item {
  justify-content: center;
  padding: 12px;
  gap: 0;
}

#app-container.sidebar-collapsed .app-sidebar .nav-item .nav-icon {
  font-size: 20px;
  margin: 0;
}

#app-container.sidebar-collapsed .app-main {
  margin-left: 70px;
  width: calc(100% - 70px);
  max-width: calc(100% - 70px);
}

/* Top Navigation Bar */
.top-navbar {
  min-height: 64px;
  height: auto;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  position: sticky;
  top: 0;
  z-index: 90;
  backdrop-filter: blur(16px);
  flex-wrap: wrap;
  gap: 12px;
}

.top-navbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.period-badge-group {
  display: flex;
  align-items: center;
  background-color: var(--bg-input);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 4px 10px;
  gap: 8px;
}

.period-badge-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.period-select {
  background: transparent;
  border: none;
  color: var(--brand-primary);
  font-weight: 700;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

.top-navbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Main Content Views */
.content-area {
  padding: 20px 24px;
  flex-grow: 1;
  max-width: 100%;
  width: 100%;
  min-width: 0;
  margin: 0;
  box-sizing: border-box;
}

.view-section {
  display: none;
  animation: fadeIn 0.3s ease-in-out;
  min-width: 0;
  max-width: 100%;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}