@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&family=Lato:wght@300;400;700;900&display=swap');

/* ==========================================
   THEME STYLING & VARIABLES (Flat & Minimalist)
   ========================================== */
:root {
  /* Fonts */
  --font-family-header: 'Poppins', sans-serif;
  --font-family-body: 'Lato', 'Poppins', sans-serif;
  
  /* Color Palette - Default Dark Mode (Flat & Professional) */
  --bg-base: #0a0b0d;
  --bg-surface: #12141c;
  --bg-surface-hover: #1b1e2a;
  --bg-sidebar: #0a0b0d;
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --border-color: #222530;
  --border-color-hover: #313646;
  
  --primary: #2563eb;
  --primary-rgb: 37, 99, 235;
  --primary-bg: #1e293b;
  
  --accent: #4f46e5;
  --accent-rgb: 79, 70, 229;
  
  --success: #16a34a;
  --success-rgb: 22, 163, 74;
  --success-bg: rgba(22, 163, 74, 0.1);
  
  --warning: #d97706;
  --warning-rgb: 217, 119, 6;
  --warning-bg: rgba(217, 119, 6, 0.1);
  
  --danger: #dc2626;
  --danger-rgb: 220, 38, 38;
  --danger-bg: rgba(220, 38, 38, 0.1);
  
  /* Borders & Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  
  /* flat subtle shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.2s ease-in-out;
}

/* Light Theme Variables */
.light-theme {
  --bg-base: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f1f5f9;
  --bg-sidebar: #0f172a; /* Keep dark sidebar for high-end feel */
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --border-color: #e2e8f0;
  --border-color-hover: #cbd5e1;
  
  --primary: #2563eb;
  --primary-bg: #eff6ff;
  
  --success: #16a34a;
  --success-bg: #f0fdf4;
  
  --warning: #d97706;
  --warning-bg: #fef3c7;
  
  --danger: #dc2626;
  --danger-bg: #fef2f2;
}

/* Accessibility: Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* ==========================================
   BASE & RESET STYLES
   ========================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family-body);
  background-color: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
  transition: background-color var(--transition-normal);
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family-header);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==========================================
   SIDEBAR LAYOUT
   ========================================== */
aside {
  background-color: #0b0f19;
  border-right: 1px solid #1e293b;
  padding: 20px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  padding-left: 4px;
}

.brand-logo {
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-logo svg {
  width: 20px;
  height: 20px;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #ffffff;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #4b5563;
  margin: 16px 0 8px 4px;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  color: #9ca3af;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13px;
  transition: all var(--transition-fast);
}

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

.nav-item.active a {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.08);
  font-weight: 600;
  border-left: 2px solid var(--primary);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.nav-item a svg {
  width: 16px;
  height: 16px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid #1e293b;
}

.sidebar-widget {
  padding: 8px 4px;
}

.sidebar-widget-title {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #4b5563;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.sidebar-select {
  width: 100%;
  padding: 6px 10px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

/* ==========================================
   MAIN LAYOUT & HEADER
   ========================================== */
main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

header {
  height: 64px;
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 90;
}

.header-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-base);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  width: 280px;
}

.header-search svg {
  color: var(--text-muted);
  width: 14px;
  height: 14px;
}

.header-search input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-family-body);
  font-size: 13px;
  width: 100%;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle-btn, .action-icon-btn {
  background: var(--bg-base);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all var(--transition-fast);
}

.theme-toggle-btn:hover, .action-icon-btn:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-color-hover);
}

.theme-toggle-btn svg, .action-icon-btn svg {
  width: 16px;
  height: 16px;
}

.theme-toggle-btn .sun-icon { display: none; }
.light-theme .theme-toggle-btn .moon-icon { display: none; }
.light-theme .theme-toggle-btn .sun-icon { display: block; }

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  border: 1px solid var(--primary);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background-color var(--transition-fast);
}

.btn-primary:hover {
  background-color: #1d4ed8;
}

.btn-primary svg {
  width: 14px;
  height: 14px;
}

/* ==========================================
   CONTENT VIEWCONTAINER
   ========================================== */
.content-wrapper {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.view-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.view-title {
  font-size: 20px;
  font-weight: 700;
}

.view-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

/* ==========================================
   KPI GRID (Flat cards, no gradients)
   ========================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.kpi-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.kpi-card:hover {
  border-color: var(--border-color-hover);
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.kpi-trend {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
}

.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--danger); }
.kpi-trend.neutral { color: var(--text-secondary); }

/* ==========================================
   CHARTS & PIPELINE GRID STRUCTURE
   ========================================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.grid-span-12 { grid-column: span 12; }
.grid-span-8 { grid-column: span 8; }
.grid-span-6 { grid-column: span 6; }
.grid-span-4 { grid-column: span 4; }

.dashboard-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.chart-container {
  position: relative;
  width: 100%;
  min-height: 240px;
  flex-grow: 1;
}

/* ==========================================
   KANBAN PIPELINE STYLING (Flat & Clean)
   ========================================== */
.pipeline-container {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.pipeline-column {
  background-color: var(--bg-base);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 200px;
}

.pipeline-column.drag-over {
  border-color: var(--primary);
  background-color: var(--bg-surface-hover);
}

.pipeline-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
}

.pipeline-column-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.pipeline-column-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
}

.pipeline-cards-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 340px;
}

.job-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: grab;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast);
}

.job-card:hover {
  border-color: var(--border-color-hover);
}

.job-card.dragging {
  opacity: 0.3;
}

.job-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.job-card-type {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 10px;
}

.job-card-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-color);
  padding-top: 8px;
}

.job-card-value {
  font-weight: 700;
  color: var(--text-primary);
}

/* ==========================================
   TABLES STYLING (Flat & Minimalist)
   ========================================== */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

thead {
  background-color: var(--bg-base);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-weight: 600;
}

th, td {
  padding: 10px 12px;
}

tbody tr {
  border-bottom: 1px solid var(--border-color);
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background-color: var(--bg-surface-hover);
}

/* Urgency flat labels (No emojis) */
.urgency-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.urgency-badge.red {
  background-color: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(var(--danger-rgb), 0.2);
}

.urgency-badge.yellow {
  background-color: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(var(--warning-rgb), 0.2);
}

.urgency-badge.green {
  background-color: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(var(--success-rgb), 0.2);
}

.tech-rating {
  font-weight: 600;
}

/* ==========================================
   QUOTE-TO-CLOSE STYLING (Flat Circle)
   ========================================== */
.quote-tracker-layout {
  display: flex;
  gap: 24px;
  align-items: center;
}

.quote-circle-progress {
  position: relative;
  width: 90px;
  height: 90px;
  flex-shrink: 0;
}

.quote-circle-progress svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.quote-circle-bg {
  fill: none;
  stroke: var(--border-color);
  stroke-width: 6;
}

.quote-circle-bar {
  fill: none;
  stroke: var(--primary);
  stroke-width: 6;
  stroke-dasharray: 251.32; /* 2 * PI * 40 */
  stroke-dashoffset: 105.55;
  stroke-linecap: square;
  transition: stroke-dashoffset 0.8s ease-out;
}

.quote-percentage {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-family-header);
}

.quote-metrics-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  flex-grow: 1;
}

.quote-metric-item {
  display: flex;
  flex-direction: column;
}

.quote-metric-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.quote-metric-value {
  font-size: 15px;
  font-weight: 700;
}

.quote-comparison-bar {
  grid-column: span 2;
  font-size: 11px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-color);
  padding-top: 8px;
  margin-top: 4px;
}

.quote-comparison-status {
  font-weight: 700;
  color: var(--danger);
}

/* ==========================================
   MODAL DIALOGS
   ========================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 440px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-close-btn svg {
  width: 18px;
  height: 18px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.form-input, .form-select {
  width: 100%;
  padding: 8px 10px;
  background-color: var(--bg-base);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-family-body);
  font-size: 13px;
  outline: none;
}

.form-input:focus, .form-select:focus {
  border-color: var(--primary);
}

option {
  background-color: var(--bg-surface);
  color: var(--text-primary);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.btn-secondary {
  background-color: var(--bg-base);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.btn-secondary:hover {
  background-color: var(--bg-surface-hover);
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .grid-span-8, .grid-span-6, .grid-span-4 {
    grid-column: span 12;
  }
}

@media (max-width: 768px) {
  body {
    grid-template-columns: 1fr;
  }
  aside {
    display: none;
  }
  header {
    padding: 0 16px;
  }
  .content-wrapper {
    padding: 16px;
    gap: 16px;
  }
  .header-search {
    display: none;
  }
}
