/* ArchiSpace OS V13 - Enterprise Design System (Notion + Monday + Power BI + Engineering ERP) */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --secondary: #0f172a;
  --surface: #ffffff;
  --canvas: #f8fafc;
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-text: #f1f5f9;
  --sidebar-text-muted: #94a3b8;
  --badge-ontrack-bg: #ecfdf5;
  --badge-ontrack-text: #065f46;
  --badge-ontrack-border: #a7f3d0;
  --badge-attention-bg: #fffbeb;
  --badge-attention-text: #92400e;
  --badge-attention-border: #fde68a;
  --badge-critical-bg: #fff1f2;
  --badge-critical-text: #9f1239;
  --badge-critical-border: #fecdd3;
  --badge-info-bg: #eff6ff;
  --badge-info-text: #1e40af;
  --badge-info-border: #bfdbfe;
}

[data-theme="dark"] {
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: #1e293b;
  --secondary: #f8fafc;
  --surface: #1e293b;
  --canvas: #0f172a;
  --border: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --sidebar-bg: #0b1120;
  --sidebar-hover: #1e293b;
  --sidebar-text: #f8fafc;
  --sidebar-text-muted: #64748b;
  --badge-ontrack-bg: #064e3b;
  --badge-ontrack-text: #a7f3d0;
  --badge-ontrack-border: #047857;
  --badge-attention-bg: #78350f;
  --badge-attention-text: #fde68a;
  --badge-attention-border: #b45309;
  --badge-critical-bg: #881337;
  --badge-critical-text: #fecdd3;
  --badge-critical-border: #be123c;
  --badge-info-bg: #1e3a8a;
  --badge-info-text: #bfdbfe;
  --badge-info-border: #1d4ed8;
}

/* Base & Typography */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Tajawal", "Cairo", sans-serif;
  background-color: var(--canvas);
  color: var(--text-main);
  overflow-x: hidden;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Custom Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #475569; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* Notion-style Cards */
.notion-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.notion-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 16px -2px rgba(15, 23, 42, 0.08);
}
[data-theme="dark"] .notion-card:hover {
  border-color: #475569;
  box-shadow: 0 4px 16px -2px rgba(0, 0, 0, 0.3);
}

/* Professional Tables */
.notion-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.notion-table th {
  background-color: var(--canvas);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  text-align: inherit;
}
.notion-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  vertical-align: middle;
}
.notion-table tr:hover td {
  background-color: rgba(37, 99, 235, 0.02);
}
[data-theme="dark"] .notion-table tr:hover td {
  background-color: rgba(59, 130, 246, 0.05);
}

/* Status Badges */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
}
.badge-ontrack {
  background-color: var(--badge-ontrack-bg);
  color: var(--badge-ontrack-text);
  border: 1px solid var(--badge-ontrack-border);
}
.badge-attention {
  background-color: var(--badge-attention-bg);
  color: var(--badge-attention-text);
  border: 1px solid var(--badge-attention-border);
}
.badge-critical {
  background-color: var(--badge-critical-bg);
  color: var(--badge-critical-text);
  border: 1px solid var(--badge-critical-border);
}
.badge-info {
  background-color: var(--badge-info-bg);
  color: var(--badge-info-text);
  border: 1px solid var(--badge-info-border);
}

/* Kanban Board */
.kanban-board {
  display: flex;
  gap: 1.25rem;
  overflow-x: auto;
  padding-bottom: 1.5rem;
  min-height: calc(100vh - 240px);
}
.kanban-col {
  flex: 0 0 320px;
  background-color: var(--canvas);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
}
.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.875rem;
  cursor: grab;
  transition: all 0.15s ease;
  margin-bottom: 0.75rem;
}
.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  border-color: #94a3b8;
}

/* Financial Lag Visual Meter */
.lag-meter {
  position: relative;
  height: 8px;
  border-radius: 9999px;
  background: var(--border);
  overflow: hidden;
}
.lag-fill-tech {
  height: 100%;
  background: #2563eb;
  position: absolute;
  left: 0;
  top: 0;
}
.lag-fill-fin {
  height: 100%;
  background: #10b981;
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0.85;
}

/* Stepper Bar */
.stepper-step {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}
.stepper-step::before {
  content: '';
  position: absolute;
  top: 18px;
  left: -50%;
  width: 100%;
  height: 2px;
  background-color: var(--border);
  z-index: 1;
}
html[dir="rtl"] .stepper-step::before {
  left: auto;
  right: -50%;
}
.stepper-step:first-child::before {
  display: none;
}
.stepper-step.completed::before,
.stepper-step.active::before {
  background-color: var(--primary);
}
.stepper-circle {
  width: 36px;
  height: 36px;
  border-radius: 9999px;
  background-color: var(--surface);
  border: 2px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-muted);
  z-index: 2;
  transition: all 0.2s ease;
}
.stepper-step.active .stepper-circle {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.stepper-step.completed .stepper-circle {
  border-color: #10b981;
  background-color: #10b981;
  color: #ffffff;
}

/* Risk Matrix 5x5 */
.risk-matrix {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.risk-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.risk-cell:hover {
  transform: scale(1.05);
}
.risk-cell-low { background: #dcfce7; color: #166534; }
.risk-cell-med { background: #fef9c3; color: #854d0e; }
.risk-cell-high { background: #fed7aa; color: #9a3412; }
.risk-cell-crit { background: #fecdd3; color: #9f1239; }

/* Global Search Modal (Ctrl + K) */
.search-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}
.search-modal-box {
  width: 100%;
  max-width: 640px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

/* Print Stylesheet */
@media print {
  .no-print, #sidebar, #topbar, .modal-overlay, #toast-container, button {
    display: none !important;
  }
  body, #main-content {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .notion-card {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    page-break-inside: avoid;
  }
  .print-header {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #0f172a;
    padding-bottom: 12px;
    margin-bottom: 24px;
  }
}
