/* =====================================================
   Dashboard — HaleyJoesOS
   Design language inherits from theme.css tokens.
   ===================================================== */

/* App shell */
.app-body {
  min-height: 100vh;
  background: var(--bg);
}

/* ---- Nav ---- */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 0 40px;
  height: 60px;
  background: rgba(13, 13, 13, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-brand {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 800;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.nav-brand:hover { color: var(--accent); }

.nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav-link {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--fg-muted);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover { color: var(--fg); background: rgba(255,255,255,0.05); }
.nav-link.active { color: var(--fg); background: rgba(255,255,255,0.08); }

/* ---- Main ---- */
.app-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 40px 80px;
}

/* ---- Page header ---- */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 16px;
}

.page-badge {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--fg);
}

/* ---- Buttons ---- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 20px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-soft); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 20px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}
.btn-ghost:hover { border-color: var(--fg-muted); color: var(--fg); }

.btn-danger {
  display: inline-flex;
  align-items: center;
  background: transparent;
  color: #e05a5a;
  border: 1px solid #e05a5a44;
  border-radius: 6px;
  padding: 10px 20px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-danger:hover { background: rgba(224, 90, 90, 0.1); }

.btn-advance {
  background: transparent;
  color: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.btn-advance:hover { background: rgba(232,93,47,0.1); }

.btn-sm { padding: 5px 12px !important; font-size: 0.82rem !important; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: inherit;
  padding: 0;
  text-decoration: underline;
}

.link-subtle {
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 0.9rem;
}
.link-subtle:hover { color: var(--fg); }

/* ---- Stats row ---- */
.stats-row {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.stat-card {
  flex: 1;
  min-width: 110px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
}

.stat-card--danger { border-color: #e05a5a55; background: rgba(224,90,90,0.06); }
.stat-card--warn   { border-color: #e8a12f55; background: rgba(232,161,47,0.06); }

.stat-card-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--fg);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-card--danger .stat-card-value { color: #e05a5a; }
.stat-card--warn .stat-card-value { color: #e8a12f; }

.stat-card-label {
  font-size: 0.78rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* ---- Section card ---- */
.section-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 24px;
}

.section-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--fg);
}

/* ---- Table ---- */
.table-wrapper { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--fg-muted);
  padding: 12px 16px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--fg);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }

.table-row-link { cursor: pointer; transition: background 0.12s; }
.table-row-link:hover { background: rgba(255,255,255,0.03); }

.order-title { font-weight: 500; }
.customer-cell { color: var(--fg-muted); }
.action-cell { text-align: right; white-space: nowrap; }

.muted { color: var(--fg-muted); }
.text-danger { color: #e05a5a; }
.text-warn { color: #e8a12f; }

/* ---- Status badges ---- */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}

.status-badge.status-lg { padding: 5px 14px; font-size: 0.85rem; margin-bottom: 12px; }

.status-inquiry        { background: rgba(163,158,151,0.15); color: var(--fg-muted); border: 1px solid rgba(163,158,151,0.2); }
.status-design_approval{ background: rgba(113,166,232,0.15); color: #71a6e8; border: 1px solid rgba(113,166,232,0.25); }
.status-in_production  { background: rgba(232,161,47,0.15);  color: #e8a12f; border: 1px solid rgba(232,161,47,0.25); }
.status-ready          { background: rgba(80,200,120,0.15);  color: #50c878; border: 1px solid rgba(80,200,120,0.25); }
.status-delivered      { background: rgba(232,93,47,0.15);   color: var(--accent); border: 1px solid rgba(232,93,47,0.25); }

/* ---- Empty state ---- */
.empty-state {
  padding: 48px 28px;
  text-align: center;
  color: var(--fg-muted);
}

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}

.modal-backdrop.hidden { display: none; }

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 0;
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--fg-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.modal-close:hover { color: var(--fg); background: rgba(255,255,255,0.06); }

/* ---- Forms ---- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 28px 0;
}

.form-row {
  display: flex;
  gap: 0;
}

.form-row .form-group { flex: 1; }

label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

.form-input:focus { border-color: var(--accent); }
.form-input option { background: var(--bg-elevated); }
textarea.form-input { resize: vertical; }

.modal-actions, .form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 24px 28px;
}

/* ---- Order detail ---- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--fg-muted);
  margin-bottom: 24px;
}

.breadcrumb-link { color: var(--accent); text-decoration: none; }
.breadcrumb-link:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--border); }

.order-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  align-items: start;
}

.order-main {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
}

.order-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.order-title-large {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.order-customer { color: var(--fg-muted); margin-top: 8px; font-size: 0.9rem; }

.order-header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.badge-delivered {
  color: #50c878;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid rgba(80,200,120,0.3);
  border-radius: 6px;
  padding: 8px 16px;
}

/* Pipeline progress */
.pipeline-progress {
  display: flex;
  align-items: center;
  margin-bottom: 32px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 0;
}

.pipeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pipeline-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--border);
  transition: background 0.2s;
}

.pipeline-step.done .pipeline-dot { background: var(--accent); border-color: var(--accent); }
.pipeline-step.current .pipeline-dot { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px rgba(232,93,47,0.2); }

.pipeline-label {
  font-size: 0.72rem;
  color: var(--fg-muted);
  text-align: center;
  text-transform: capitalize;
  white-space: nowrap;
}

.pipeline-step.done .pipeline-label, .pipeline-step.current .pipeline-label { color: var(--fg); }

.pipeline-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  min-width: 24px;
  align-self: center;
  margin-bottom: 20px;
}

.pipeline-line.done { background: var(--accent); }

/* Detail grid */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.detail-item {}
.detail-label { font-size: 0.75rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.detail-value { font-size: 1rem; font-weight: 500; color: var(--fg); }

.notes-block { border-top: 1px solid var(--border); padding-top: 20px; }
.notes-text { color: var(--fg-muted); font-size: 0.95rem; line-height: 1.7; margin-top: 6px; }

/* Edit form */
.edit-form { border-top: 1px solid var(--border); padding-top: 24px; margin-top: 24px; }
.edit-form .form-group { padding: 0 0 16px 0; }
.edit-form .form-row { gap: 16px; }

/* ---- Sidebar ---- */
.order-sidebar {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.sidebar-title {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--fg-muted);
  margin-bottom: 20px;
}

.event-list { display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px; }

.event-item {
  display: flex;
  gap: 12px;
}

.event-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-top: 5px;
}

.event-body {}
.event-type { font-size: 0.85rem; font-weight: 500; color: var(--fg); text-transform: capitalize; }
.event-note { font-size: 0.82rem; color: var(--fg-muted); margin-top: 2px; }
.event-time { font-size: 0.78rem; color: var(--fg-muted); margin-top: 4px; }

.note-form { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--border); padding-top: 20px; }
.note-form .form-input { font-size: 0.88rem; }

.muted-text { color: var(--fg-muted); font-size: 0.9rem; }

/* ---- Pipeline board ---- */
.pipeline-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  align-items: start;
}

.pipeline-column {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.pipeline-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}

.pipeline-col-count {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--fg-muted);
}

.pipeline-cards { padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 80px; }

.pipeline-empty { color: var(--fg-muted); font-size: 0.82rem; padding: 8px; text-align: center; }

.pipeline-card {
  display: block;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.pipeline-card:hover { border-color: var(--accent); background: rgba(232,93,47,0.04); }

.pipeline-card-title { font-size: 0.88rem; font-weight: 500; color: var(--fg); margin-bottom: 4px; }
.pipeline-card-customer { font-size: 0.78rem; color: var(--fg-muted); margin-bottom: 6px; }
.pipeline-card-meta { display: flex; gap: 10px; font-size: 0.75rem; color: var(--fg-muted); }

/* ---- Hidden helper ---- */
.hidden { display: none !important; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .app-main { padding: 24px 16px 60px; }
  .app-nav { padding: 0 16px; }
  .order-layout { grid-template-columns: 1fr; }
  .pipeline-board { grid-template-columns: repeat(2, 1fr); }
  .stats-row { flex-wrap: wrap; }
  .stat-card { min-width: calc(50% - 8px); }
}

@media (max-width: 600px) {
  .pipeline-board { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .data-table { font-size: 0.82rem; }
  .data-table td, .data-table th { padding: 10px 10px; }
}
