/* JES Estimation v3.0 — Shared Design System Styles */
/* Source of truth: JES_Estimation_Design_System.html */

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

:root {
  --primary: #2E6FF2;
  --primary-light: #EFF6FF;
  --primary-hover: #2560D9;
  --text-primary: #111827;
  --text-body: #374151;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --text-disabled: #D1D5DB;
  --bg: #FAFBFC;
  --surface: #FFFFFF;
  --border: #E5E7EB;
  --divider: #F3F4F6;
  --success: #059669;
  --success-bg: #ECFDF5;
  --warning: #D97706;
  --warning-bg: #FFFBEB;
  --error: #DC2626;
  --error-bg: #FEF2F2;
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ========== APP SHELL ========== */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* ========== SIDEBAR ========== */
.sidebar {
  width: 240px; min-width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.sidebar-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.sidebar-logo svg { width: 18px; height: 18px; stroke: #fff; fill: none; stroke-width: 2; }
.sidebar-title-group { display: flex; flex-direction: column; }
.sidebar-title { font-size: 14px; font-weight: 700; letter-spacing: -0.3px; line-height: 1.2; }
.sidebar-version { font-size: 10px; color: var(--text-muted); line-height: 1.2; margin-top: 1px; }
.sidebar-body { padding: 8px; flex: 1; }
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.sidebar-user-info { display: flex; flex-direction: column; min-width: 0; }
.sidebar-user-name {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 11px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Nav Items */
.nav-group-label {
  font-size: 10px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 12px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500; color: var(--text-secondary);
  cursor: pointer; transition: background 0.1s;
  text-decoration: none; border: none; background: none;
  width: 100%; text-align: left; font-family: inherit;
  margin-bottom: 1px;
}
.nav-item:hover { background: var(--bg); color: var(--text-primary); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }

.nav-icon {
  width: 18px; height: 18px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.nav-icon svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }

/* ========== MAIN AREA ========== */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ========== TOP BAR ========== */
.topbar {
  height: 48px; min-height: 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; gap: 12px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 15px; font-weight: 700; letter-spacing: -0.3px; }
.topbar-subtitle { font-size: 12px; color: var(--text-muted); margin-left: 8px; }

/* ========== USER AVATAR ========== */
.user-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600; flex-shrink: 0;
}
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500; color: var(--text-body);
}

/* ========== CONTENT AREA ========== */
.content { flex: 1; overflow: auto; padding: 20px; }

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 16px; border-radius: var(--radius-md);
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; transition: background 0.1s;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text-body); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-destructive { background: var(--error); color: #fff; }
.btn-destructive:hover { background: #B91C1C; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ========== INPUTS / SELECTS ========== */
.input {
  font-family: inherit; font-size: 13px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  color: var(--text-primary); background: var(--surface);
  outline: none; transition: border-color 0.1s; width: 100%;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.input::placeholder { color: var(--text-muted); }

.select {
  font-family: inherit; font-size: 13px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  color: var(--text-primary); background: var(--surface);
  outline: none; cursor: pointer;
}

.textarea {
  font-family: inherit; font-size: 13px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  color: var(--text-primary); background: var(--surface);
  outline: none; resize: vertical; width: 100%;
}
.textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }

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

/* ========== BADGES ========== */
.status-badge {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: 10px; font-size: 12px; font-weight: 600;
  white-space: nowrap; line-height: 1.4;
}
.status-green { background: var(--success-bg); color: var(--success); }
.status-amber { background: var(--warning-bg); color: var(--warning); }
.status-red { background: var(--error-bg); color: var(--error); }
.status-blue { background: var(--primary-light); color: var(--primary); }
.status-gray { background: var(--divider); color: var(--text-secondary); }

.type-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600; white-space: nowrap;
}

.role-badge {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: var(--radius-sm); font-size: 12px; font-weight: 600;
  white-space: nowrap;
}
.role-sa { background: #FFF3E0; color: #E67E22; }
.role-em { background: #EBF5FB; color: #3498DB; }
.role-ee { background: #E8F8F5; color: #27AE60; }
.role-om { background: #F4ECF7; color: #8E44AD; }
.role-pc { background: #E8F6F3; color: #1ABC9C; }

/* Priority Dots */
.priority-dot {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500;
}
.priority-dot::before {
  content: ''; width: 8px; height: 8px;
  border-radius: 50%; flex-shrink: 0;
}
.priority-dot.p1::before { background: #E74C3C; }
.priority-dot.p2::before { background: #F1C40F; }
.priority-dot.p3::before { background: #3498DB; }

/* ========== CARDS ========== */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px;
}
.card-hover:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
}

/* ========== TABLES ========== */
.table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.table th {
  text-align: left; padding: 8px 12px;
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.table td {
  padding: 10px 12px; border-bottom: 1px solid var(--divider);
  color: var(--text-body); vertical-align: middle;
}
.table tr:hover td { background: var(--bg); }
.table-wrap { overflow-x: auto; }

/* ========== KANBAN ========== */
.kanban {
  display: flex; gap: 12px; overflow-x: auto;
  padding-bottom: 8px; align-items: flex-start;
}
.kanban-col {
  min-width: 220px; max-width: 220px; flex-shrink: 0;
}
.kanban-col-header {
  padding: 8px 10px; font-size: 12px; font-weight: 600;
  color: var(--text-secondary); display: flex;
  align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.kanban-col-count {
  background: var(--divider); color: var(--text-muted);
  padding: 1px 6px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
}
.kanban-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 10px;
  margin-bottom: 6px; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.kanban-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}
.kanban-card-title {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  margin-bottom: 4px; line-height: 1.3;
}
.kanban-card-subtitle {
  font-size: 12px; color: var(--text-secondary); margin-bottom: 6px;
}
.kanban-card-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--text-muted);
}

/* ========== SLA INDICATORS ========== */
.sla-green { border-left: 3px solid var(--success); }
.sla-amber { border-left: 3px solid var(--warning); }
.sla-red { border-left: 3px solid var(--error); }
.sla-text-green { color: var(--success); }
.sla-text-amber { color: var(--warning); }
.sla-text-red { color: var(--error); }

/* ========== MODALS ========== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-box {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 80%; max-width: 1100px;
  max-height: 90vh; display: flex; flex-direction: column;
}
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { flex: 1; overflow: auto; padding: 20px; }
.modal-footer {
  padding: 12px 20px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
}
.modal-close {
  width: 28px; height: 28px; border: none; background: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md); color: var(--text-muted);
  font-size: 18px;
}
.modal-close:hover { background: var(--bg); color: var(--text-primary); }

/* ========== TABS ========== */
.tabs {
  display: flex; border-bottom: 1px solid var(--border);
  gap: 0;
}
.tab {
  padding: 8px 16px; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  background: none; border-top: none; border-left: none; border-right: none;
  font-family: inherit;
}
.tab:hover { color: var(--text-primary); }
.tab.active {
  color: var(--primary); border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ========== WIZARD STEPS ========== */
.wizard-steps {
  display: flex; align-items: center; gap: 8px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.wizard-step {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500; color: var(--text-muted);
}
.wizard-step.active { color: var(--primary); font-weight: 600; }
.wizard-step.completed { color: var(--success); }
.wizard-step-number {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  border: 2px solid var(--border); color: var(--text-muted);
}
.wizard-step.active .wizard-step-number {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.wizard-step.completed .wizard-step-number {
  background: var(--success); color: #fff; border-color: var(--success);
}
.wizard-connector {
  flex: 1; height: 1px; background: var(--border); min-width: 20px;
}

/* ========== WIDGETS / STATS ========== */
.widget-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 12px; margin-bottom: 20px;
}
.widget {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px;
}
.widget-label {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.3px;
}
.widget-value {
  font-size: 24px; font-weight: 700; color: var(--text-primary);
  margin-top: 4px;
}
.widget-sub {
  font-size: 11px; color: var(--text-secondary); margin-top: 2px;
}

/* ========== SECTION HEADERS ========== */
.section-title {
  font-size: 22px; font-weight: 700; letter-spacing: -0.4px;
  margin-bottom: 4px;
}
.section-sub {
  font-size: 13px; color: var(--text-secondary); margin-bottom: 24px;
}
.sub-label {
  font-size: 10px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 10px;
}

/* ========== UTILITY ========== */
.flex-wrap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.flex-col { display: flex; flex-direction: column; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.text-mono { font-family: 'JetBrains Mono', monospace; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-semibold { font-weight: 600; }
.divider { height: 1px; background: var(--divider); margin: 20px 0; }

/* ========== ENTITY LINKS ========== */
.entity-link {
  color: var(--primary); text-decoration: none;
  font-size: 13px; font-weight: 500; cursor: pointer;
}
.entity-link:hover { text-decoration: underline; }

/* ========== EXPANDABLE ROWS ========== */
.expand-toggle {
  width: 20px; height: 20px; border: none; background: none;
  cursor: pointer; color: var(--text-muted); font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); transition: background 0.1s;
}
.expand-toggle:hover { background: var(--bg); color: var(--text-primary); }
.expand-panel {
  display: none; background: var(--bg); padding: 16px 20px;
  border-bottom: 1px solid var(--divider);
}
.expand-panel.open { display: block; }

/* ========== CHECKLIST ========== */
.checklist-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; font-size: 13px; color: var(--text-body);
}
.checklist-icon {
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; flex-shrink: 0;
}
.checklist-pass { background: var(--success-bg); color: var(--success); }
.checklist-fail { background: var(--error-bg); color: var(--error); }
.checklist-pending { background: var(--divider); color: var(--text-muted); }

/* ========== NOTIFICATION DOT ========== */
.notification-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--error); position: absolute; top: -2px; right: -2px;
}

/* ========== SEARCH BAR ========== */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  font-size: 13px; color: var(--text-secondary);
}
.search-bar input {
  border: none; background: none; outline: none;
  font-family: inherit; font-size: 13px; color: var(--text-primary);
  flex: 1;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
  .sidebar { width: 64px; min-width: 64px; }
  .sidebar .sidebar-title-group,
  .sidebar .sidebar-title,
  .sidebar .sidebar-version,
  .sidebar .nav-group-label,
  .sidebar .nav-item span,
  .sidebar .sidebar-user-info { display: none; }
  .sidebar .sidebar-header { justify-content: center; }
  .sidebar .sidebar-footer { justify-content: center; }
  .sidebar .nav-item { justify-content: center; padding: 8px; }
  .widget-grid { grid-template-columns: repeat(2, 1fr); }
  .kanban-col { min-width: 180px; }
}

@media (max-width: 640px) {
  .sidebar { display: none; }
  .topbar { padding: 0 12px; }
  .content { padding: 12px; }
  .widget-grid { grid-template-columns: 1fr; }
  .kanban { flex-direction: column; }
  .kanban-col { min-width: 100%; max-width: 100%; }
  .modal-box { width: 100%; max-width: 100%; border-radius: 0; min-height: 100vh; }
}
