/* Divine 365 Enterprise ERP/CRM - Dynamics 365 Inspired Theme */
:root {
  --apex-primary: #005a9e;
  --apex-primary-hover: #004578;
  --apex-secondary: #0078d4;
  --apex-accent: #107c41;
  --apex-bg-main: #f3f2f1;
  --apex-bg-card: #ffffff;
  --apex-border-color: #e1dfdd;
  --apex-text-main: #323130;
  --apex-text-muted: #605e5c;
  --apex-sidebar-bg: #1b1a19;
  --apex-sidebar-text: #f3f2f1;
  --apex-sidebar-active: #005a9e;
  --apex-topbar-bg: #ffffff;
  --apex-shadow-sm: 0 1.6px 3.6px 0 rgba(0, 0, 0, 0.132), 0 0.3px 0.9px 0 rgba(0, 0, 0, 0.108);
  --apex-shadow-md: 0 3.2px 7.2px 0 rgba(0, 0, 0, 0.132), 0 0.6px 1.8px 0 rgba(0, 0, 0, 0.108);
}

[data-bs-theme="dark"] {
  --apex-bg-main: #11100f;
  --apex-bg-card: #201f1e;
  --apex-border-color: #3b3a39;
  --apex-text-main: #f3f2f1;
  --apex-text-muted: #a19f9d;
  --apex-topbar-bg: #201f1e;
  --apex-sidebar-bg: #11100f;
}

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', sans-serif;
  background-color: var(--apex-bg-main);
  color: var(--apex-text-main);
  overflow-x: hidden;
  margin: 0;
  padding: 0;
}

/* Sidebar Styling */
#sidebar-wrapper {
  min-height: 100vh;
  width: 260px;
  background-color: var(--apex-sidebar-bg);
  color: var(--apex-sidebar-text);
  transition: margin 0.25s ease-out;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1040;
  overflow-y: auto;
}

#sidebar-wrapper .sidebar-heading {
  padding: 1rem 1.25rem;
  font-size: 1.1rem;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #ffffff;
  background: linear-gradient(135deg, #005a9e 0%, #004578 100%);
}

.sidebar-nav-group {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #a19f9d;
  padding: 1rem 1.25rem 0.35rem 1.25rem;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  padding: 0.6rem 1.25rem;
  color: #c8c6c4;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s ease-in-out;
  border-left: 4px solid transparent;
}

.sidebar-nav-item i {
  font-size: 1.1rem;
  margin-right: 0.75rem;
  width: 20px;
  text-align: center;
}

.sidebar-nav-item:hover {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-nav-item.active {
  color: #ffffff;
  background-color: var(--apex-sidebar-active);
  border-left-color: #60a5fa;
}

/* Page Content Container */
#page-content-wrapper {
  margin-left: 260px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar Header */
.topbar {
  background-color: var(--apex-topbar-bg);
  border-bottom: 1px solid var(--apex-border-color);
  padding: 0.6rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--apex-shadow-sm);
  position: sticky;
  top: 0;
  z-index: 1030;
}

/* Cards & Widgets */
.apex-card {
  background-color: var(--apex-bg-card);
  border: 1px solid var(--apex-border-color);
  border-radius: 6px;
  box-shadow: var(--apex-shadow-sm);
  margin-bottom: 1.25rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.apex-card:hover {
  box-shadow: var(--apex-shadow-md);
}

.apex-card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--apex-border-color);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
}

.kpi-card {
  border-left: 4px solid var(--apex-primary);
}

.kpi-card.kpi-success { border-left-color: #107c41; }
.kpi-card.kpi-warning { border-left-color: #ffb900; }
.kpi-card.kpi-danger { border-left-color: #d13438; }
.kpi-card.kpi-info { border-left-color: #0078d4; }

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.kpi-label {
  font-size: 0.85rem;
  color: var(--apex-text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

/* Tables */
.apex-table {
  width: 100%;
  color: var(--apex-text-main);
  margin-bottom: 0;
}

.apex-table th {
  background-color: rgba(0, 0, 0, 0.02);
  border-bottom: 2px solid var(--apex-border-color);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.75rem 1rem;
}

.apex-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--apex-border-color);
  vertical-align: middle;
  font-size: 0.9rem;
}

/* Status Badges */
.badge-status {
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.35em 0.7em;
  border-radius: 4px;
  text-transform: uppercase;
}

.badge-active, .badge-paid, .badge-completed, .badge-converted, .badge-accepted {
  background-color: #dff6dd;
  color: #107c41;
}

.badge-pending, .badge-unpaid, .badge-draft, .badge-prospecting {
  background-color: #fff4ce;
  color: #797775;
}

.badge-overdue, .badge-cancelled, .badge-lost, .badge-rejected {
  background-color: #fde7e9;
  color: #a80000;
}

.badge-in-progress, .badge-partial, .badge-processing {
  background-color: #deecf9;
  color: #005a9e;
}

/* Global Search Modal Overlay */
.search-results-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--apex-bg-card);
  border: 1px solid var(--apex-border-color);
  box-shadow: var(--apex-shadow-md);
  border-radius: 6px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 1050;
}

.search-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--apex-border-color);
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--apex-text-main);
  transition: background 0.15s ease;
}

.search-item:hover {
  background-color: rgba(0, 90, 158, 0.08);
}
