/* ============================================================
   DRC CEIP Platform - Design System
   Deep Retrofit Capital Inc.
   Enterprise/Government Efficacy Standards
   ============================================================ */

/* --- CSS Custom Properties (Design Tokens) --- */
:root {
  /* Brand Colors */
  --drc-primary: #1a365d;
  --drc-primary-light: #2a4a7f;
  --drc-primary-dark: #0f2440;
  --drc-accent: #2f855a;
  --drc-accent-light: #48bb78;
  --drc-accent-dark: #1e6b45;

  /* Phase Colors */
  --phase-1: #718096;
  --phase-1-bg: #f7fafc;
  --phase-1-border: #cbd5e0;
  --phase-2: #2f855a;
  --phase-2-bg: #f0fff4;
  --phase-2-border: #9ae6b4;
  --phase-3: #2b6cb0;
  --phase-3-bg: #ebf8ff;
  --phase-3-border: #90cdf4;
  --phase-4: #b7791f;
  --phase-4-bg: #fffff0;
  --phase-4-border: #f6e05e;
  --phase-5: #6b46c1;
  --phase-5-bg: #faf5ff;
  --phase-5-border: #d6bcfa;

  /* Status Colors */
  --status-pending: #d69e2e;
  --status-approved: #38a169;
  --status-rejected: #e53e3e;
  --status-active: #3182ce;
  --status-complete: #2f855a;

  /* Property Type Colors */
  --prop-residential: #4299e1;
  --prop-commercial: #ed8936;
  --prop-farm: #48bb78;
  --prop-industrial: #9f7aea;

  /* Neutrals */
  --gray-50: #f7fafc;
  --gray-100: #edf2f7;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e0;
  --gray-400: #a0aec0;
  --gray-500: #718096;
  --gray-600: #4a5568;
  --gray-700: #2d3748;
  --gray-800: #1a202c;
  --gray-900: #171923;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Borders & Shadows */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 25px rgba(0,0,0,0.1), 0 10px 10px rgba(0,0,0,0.04);

  /* Layout */
  --max-width: 1280px;
  --sidebar-width: 280px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--drc-primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--drc-accent); }
img { max-width: 100%; display: block; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--gray-200); }
th { background: var(--gray-100); font-weight: 600; font-size: var(--text-sm); color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.05em; }
td { font-size: var(--text-sm); }
tbody tr:hover { background: var(--gray-50); }

/* --- Layout Components --- */
.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.top-nav {
  background: var(--drc-primary);
  color: white;
  padding: var(--space-3) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}
.top-nav .logo {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.top-nav .logo .icon {
  width: 32px;
  height: 32px;
  background: var(--drc-accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
}
.top-nav nav { display: flex; gap: var(--space-1); }
.top-nav nav a {
  color: rgba(255,255,255,0.8);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
}
.top-nav nav a:hover, .top-nav nav a.active {
  color: white;
  background: rgba(255,255,255,0.15);
}

.main-content {
  flex: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
  width: 100%;
}

/* --- Page Header --- */
.page-header {
  margin-bottom: var(--space-10);
  padding-bottom: var(--space-6);
  border-bottom: 2px solid var(--gray-200);
}
.page-header h1 {
  font-size: var(--text-4xl);
  font-weight: 800;
  color: var(--drc-primary);
  letter-spacing: -0.03em;
  margin-bottom: var(--space-2);
}
.page-header .subtitle {
  font-size: var(--text-lg);
  color: var(--gray-500);
  max-width: 640px;
}

/* --- Section --- */
.section {
  margin-bottom: var(--space-12);
}
.section-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--drc-primary);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 2px solid var(--drc-accent);
  display: inline-block;
}
.section-subtitle {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--gray-700);
  margin: var(--space-6) 0 var(--space-3);
}
.section p, .section li {
  font-size: var(--text-base);
  color: var(--gray-700);
  line-height: 1.7;
  max-width: 80ch;
}
.section ul, .section ol {
  padding-left: var(--space-6);
  margin: var(--space-3) 0;
}
.section li { margin-bottom: var(--space-2); }

/* --- Cards --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-6);
}
.card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: all var(--transition-base);
  box-shadow: var(--shadow-sm);
}
.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--drc-accent);
}
.card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: var(--space-4);
}
.card h3 {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--drc-primary);
  margin-bottom: var(--space-2);
}
.card p {
  font-size: var(--text-sm);
  color: var(--gray-600);
  line-height: 1.6;
}
.card-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--drc-accent);
}
.card-link:hover { color: var(--drc-accent-dark); }

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-phase-1 { background: var(--phase-1-bg); color: var(--phase-1); border: 1px solid var(--phase-1-border); }
.badge-phase-2 { background: var(--phase-2-bg); color: var(--phase-2); border: 1px solid var(--phase-2-border); }
.badge-phase-3 { background: var(--phase-3-bg); color: var(--phase-3); border: 1px solid var(--phase-3-border); }
.badge-phase-4 { background: var(--phase-4-bg); color: var(--phase-4); border: 1px solid var(--phase-4-border); }
.badge-phase-5 { background: var(--phase-5-bg); color: var(--phase-5); border: 1px solid var(--phase-5-border); }
.badge-pending { background: #fffff0; color: var(--status-pending); border: 1px solid #fefcbf; }
.badge-approved { background: #f0fff4; color: var(--status-approved); border: 1px solid #c6f6d5; }
.badge-rejected { background: #fff5f5; color: var(--status-rejected); border: 1px solid #fed7d7; }
.badge-active { background: #ebf8ff; color: var(--status-active); border: 1px solid #bee3f8; }

/* Property type badges */
.badge-residential { background: #ebf8ff; color: var(--prop-residential); border: 1px solid #bee3f8; }
.badge-commercial { background: #fffaf0; color: var(--prop-commercial); border: 1px solid #feebc8; }
.badge-farm { background: #f0fff4; color: var(--prop-farm); border: 1px solid #c6f6d5; }
.badge-industrial { background: #faf5ff; color: var(--prop-industrial); border: 1px solid #e9d8fd; }

/* --- Tabs --- */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: var(--space-6);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-500);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: all var(--transition-fast);
}
.tab:hover { color: var(--drc-primary); }
.tab.active {
  color: var(--drc-primary);
  border-bottom-color: var(--drc-accent);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.3s ease; }

/* --- Phase Progress Bar --- */
.phase-progress {
  display: flex;
  align-items: center;
  gap: 0;
  margin: var(--space-6) 0;
  background: var(--gray-100);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.phase-step {
  flex: 1;
  text-align: center;
  padding: var(--space-3) var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--gray-500);
  background: var(--gray-100);
  position: relative;
  cursor: pointer;
  transition: all var(--transition-base);
}
.phase-step.active { color: white; }
.phase-step.completed { color: white; opacity: 0.8; }
.phase-step[data-phase="1"].active, .phase-step[data-phase="1"].completed { background: var(--phase-1); }
.phase-step[data-phase="2"].active, .phase-step[data-phase="2"].completed { background: var(--phase-2); }
.phase-step[data-phase="3"].active, .phase-step[data-phase="3"].completed { background: var(--phase-3); }
.phase-step[data-phase="4"].active, .phase-step[data-phase="4"].completed { background: var(--phase-4); }
.phase-step[data-phase="5"].active, .phase-step[data-phase="5"].completed { background: var(--phase-5); }

/* --- Property Type Toggle --- */
.prop-type-toggle {
  display: flex;
  gap: var(--space-2);
  margin: var(--space-4) 0;
  flex-wrap: wrap;
}
.prop-type-btn {
  padding: var(--space-2) var(--space-4);
  border: 2px solid var(--gray-300);
  border-radius: var(--radius-md);
  background: white;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.prop-type-btn:hover { border-color: var(--gray-400); }
.prop-type-btn.active[data-type="residential"] { background: var(--prop-residential); color: white; border-color: var(--prop-residential); }
.prop-type-btn.active[data-type="commercial"] { background: var(--prop-commercial); color: white; border-color: var(--prop-commercial); }
.prop-type-btn.active[data-type="farm"] { background: var(--prop-farm); color: white; border-color: var(--prop-farm); }
.prop-type-btn.active[data-type="industrial"] { background: var(--prop-industrial); color: white; border-color: var(--prop-industrial); }

/* --- Journey Animation --- */
.journey-screen {
  background: white;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  max-width: 900px;
  margin: 0 auto;
}
.journey-titlebar {
  background: var(--drc-primary);
  color: white;
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-sm);
  font-weight: 600;
}
.journey-content {
  padding: var(--space-8);
  min-height: 400px;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}
.journey-step {
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.5s ease;
}
.journey-step.visible {
  opacity: 1;
  transform: translateY(0);
}
.journey-step-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.journey-step-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.journey-step-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--gray-800);
}
.journey-step-body {
  margin-left: calc(32px + var(--space-3));
}
.journey-step-desc {
  font-size: var(--text-sm);
  color: var(--gray-600);
  margin-bottom: var(--space-3);
}
.journey-mockup {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: var(--space-5);
}
.journey-mockup-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-500);
  margin-bottom: var(--space-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.interaction-callout {
  background: #ebf8ff;
  border-left: 4px solid var(--status-active);
  padding: var(--space-3) var(--space-4);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: var(--text-sm);
  color: var(--gray-700);
  margin-top: var(--space-3);
}
.interaction-callout strong { color: var(--status-active); }

/* Journey Controls */
.journey-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  margin-top: var(--space-6);
}
.journey-btn {
  padding: var(--space-3) var(--space-6);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.journey-btn-primary {
  background: var(--drc-accent);
  color: white;
}
.journey-btn-primary:hover { background: var(--drc-accent-dark); }
.journey-btn-secondary {
  background: var(--gray-200);
  color: var(--gray-700);
}
.journey-btn-secondary:hover { background: var(--gray-300); }
.journey-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* --- Stakeholder Selector --- */
.stakeholder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  margin: var(--space-6) 0;
}
.stakeholder-card {
  background: white;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-base);
}
.stakeholder-card:hover {
  border-color: var(--drc-accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.stakeholder-card.selected {
  border-color: var(--drc-accent);
  background: var(--phase-2-bg);
}
.stakeholder-icon {
  font-size: 40px;
  margin-bottom: var(--space-3);
}
.stakeholder-name {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--drc-primary);
  margin-bottom: var(--space-1);
}
.stakeholder-desc {
  font-size: var(--text-xs);
  color: var(--gray-500);
}

/* --- Gantt Chart (CSS-only) --- */
.gantt {
  width: 100%;
  overflow-x: auto;
  margin: var(--space-4) 0;
}
.gantt-row {
  display: flex;
  align-items: center;
  margin-bottom: var(--space-2);
}
.gantt-label {
  width: 200px;
  flex-shrink: 0;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-700);
  padding-right: var(--space-4);
}
.gantt-track {
  flex: 1;
  height: 28px;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  position: relative;
}
.gantt-bar {
  position: absolute;
  height: 100%;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
}

/* --- Info Box --- */
.info-box {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  margin: var(--space-4) 0;
}
.info-box-header {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--drc-primary);
  margin-bottom: var(--space-3);
}
.info-box.highlight {
  border-left: 4px solid var(--drc-accent);
}

/* --- Mermaid Overrides --- */
.mermaid-container {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  overflow-x: auto;
  margin: var(--space-4) 0;
}

/* --- Architecture Diagram (CSS) --- */
.arch-diagram {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-6);
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
}
.arch-layer {
  padding: var(--space-5);
  border-radius: var(--radius-md);
  border: 2px dashed var(--gray-300);
}
.arch-layer-title {
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-3);
}
.arch-modules {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.arch-module {
  background: white;
  border: 2px solid var(--gray-300);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  text-align: center;
  min-width: 140px;
  transition: all var(--transition-fast);
}
.arch-module:hover {
  border-color: var(--drc-accent);
  box-shadow: var(--shadow-sm);
}

/* --- Risk Matrix --- */
.risk-matrix {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}
.risk-item {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.risk-high { background: #fff5f5; border: 1px solid #fed7d7; }
.risk-medium { background: #fffff0; border: 1px solid #fefcbf; }
.risk-low { background: #f0fff4; border: 1px solid #c6f6d5; }

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-30px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}
.animate-fade { animation: fadeIn 0.4s ease forwards; }
.animate-slide-left { animation: slideInLeft 0.4s ease forwards; }
.animate-slide-right { animation: slideInRight 0.4s ease forwards; }
.animate-pulse { animation: pulse 2s ease infinite; }
.animate-scale { animation: scaleIn 0.3s ease forwards; }

/* Staggered children */
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 80ms; }
.stagger > *:nth-child(3) { animation-delay: 160ms; }
.stagger > *:nth-child(4) { animation-delay: 240ms; }
.stagger > *:nth-child(5) { animation-delay: 320ms; }
.stagger > *:nth-child(6) { animation-delay: 400ms; }

/* --- Flow Diagram (CSS-only swimlane) --- */
.swimlane-diagram {
  display: grid;
  gap: 0;
  border: 2px solid var(--gray-300);
  border-radius: var(--radius-lg);
  overflow: hidden;
  font-size: var(--text-xs);
}
.swimlane-header {
  display: grid;
  background: var(--drc-primary);
  color: white;
  font-weight: 700;
  text-align: center;
}
.swimlane-header > div {
  padding: var(--space-2) var(--space-1);
  border-right: 1px solid rgba(255,255,255,0.2);
  font-size: var(--text-xs);
}
.swimlane-row {
  display: grid;
  min-height: 60px;
  border-bottom: 1px solid var(--gray-200);
}
.swimlane-cell {
  padding: var(--space-2);
  border-right: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
}
.flow-node {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  text-align: center;
  max-width: 160px;
  line-height: 1.3;
}
.flow-node-action { background: #e2e8f0; color: var(--gray-700); border: 1px solid var(--gray-300); }
.flow-node-decision { background: #fefcbf; color: var(--gray-800); border: 1px solid #f6e05e; transform: rotate(0deg); }
.flow-node-trigger { background: var(--drc-primary); color: white; }
.flow-node-output { background: var(--drc-accent); color: white; }
.flow-node-register { background: #1a202c; color: white; }
.flow-node-payment { background: #9f7aea; color: white; }
.flow-arrow {
  color: var(--gray-400);
  font-size: var(--text-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .card-grid { grid-template-columns: 1fr; }
  .stakeholder-grid { grid-template-columns: repeat(2, 1fr); }
  .top-nav { flex-direction: column; gap: var(--space-2); }
  .top-nav nav { flex-wrap: wrap; justify-content: center; }
  .main-content { padding: var(--space-4); }
  .page-header h1 { font-size: var(--text-3xl); }
  .gantt-label { width: 140px; font-size: var(--text-xs); }
  .risk-matrix { grid-template-columns: 1fr; }
  .arch-modules { flex-direction: column; }
}

/* --- Footer --- */
.page-footer {
  background: var(--gray-800);
  color: var(--gray-400);
  padding: var(--space-6);
  text-align: center;
  font-size: var(--text-sm);
  margin-top: auto;
}
.page-footer strong { color: white; }
