/* ERP Prototype — shared styles */
/* Output (DJR) is licensed/self-hosted — Outfit is the loaded web stand-in with the same stack name */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

@font-face {
  font-family: 'Output';
  src: local('Output Sans'), local('Output');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --font: 'Output', 'Outfit', system-ui, sans-serif;
  --bg: #0f1419;
  --bg-elevated: #1a222d;
  --bg-card: #232d3b;
  --border: #2e3a4d;
  --text: #e8edf4;
  --text-muted: #8b9cb3;
  --accent: #3d8bfd;
  --accent-soft: rgba(61, 139, 253, 0.15);
  --crm: #6366f1;
  --helpdesk: #14b8a6;
  --ai: #a855f7;
  --reports: #f59e0b;
  --settings: #64748b;
  --field: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --sidebar-w: 260px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Layout */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand a {
  text-decoration: none;
  color: inherit;
}

.sidebar-brand h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-brand span {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 0.15rem;
}

.nav-modules {
  padding: 1rem 0.75rem;
  flex: 1;
}

.nav-modules ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-modules li {
  margin-bottom: 0.25rem;
}

.nav-modules a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}

.nav-modules a:hover {
  background: var(--bg-card);
  color: var(--text);
  text-decoration: none;
}

.nav-modules a.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.nav-dot.crm { background: var(--crm); }
.nav-dot.helpdesk { background: var(--helpdesk); }
.nav-dot.ai { background: var(--ai); }
.nav-dot.reports { background: var(--reports); }
.nav-dot.settings { background: var(--settings); }
.nav-dot.field { background: var(--field); }

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.topbar h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.content {
  padding: 1.75rem 2rem 3rem;
  flex: 1;
}

/* Buttons — distinguishable colors */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s, filter 0.12s, box-shadow 0.12s;
}

.btn:hover {
  filter: brightness(1.08);
  text-decoration: none;
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, #3d8bfd, #2563eb);
  color: #fff;
  box-shadow: 0 2px 12px rgba(61, 139, 253, 0.4);
}

.btn-success {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  box-shadow: 0 2px 12px rgba(34, 197, 94, 0.35);
}

.btn-warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #1a1206;
  box-shadow: 0 2px 12px rgba(245, 158, 11, 0.35);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 2px 12px rgba(239, 68, 68, 0.35);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-purple {
  background: linear-gradient(135deg, #a855f7, #7c3aed);
  color: #fff;
  box-shadow: 0 2px 12px rgba(168, 85, 247, 0.35);
}

.btn-teal {
  background: linear-gradient(135deg, #14b8a6, #0d9488);
  color: #fff;
  box-shadow: 0 2px 12px rgba(20, 184, 166, 0.35);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px dashed var(--border);
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

/* Cards & grid */
.grid {
  display: grid;
  gap: 1.25rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .content { padding: 1.25rem; }
  .topbar { padding: 1rem; }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.stat-card {
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.stat-card.crm::before { background: var(--crm); }
.stat-card.helpdesk::before { background: var(--helpdesk); }
.stat-card.ai::before { background: var(--ai); }
.stat-card.reports::before { background: var(--reports); }
.stat-card.field::before { background: var(--field); }

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0.5rem 0 0.15rem;
  letter-spacing: -0.03em;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Module hero on home */
.hero {
  background: linear-gradient(135deg, var(--bg-card) 0%, #1e2a3a 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 2.5rem;
  margin-bottom: 2rem;
}

.hero h2 {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
  font-weight: 700;
}

.hero p {
  margin: 0;
  color: var(--text-muted);
  max-width: 52ch;
}

.module-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.module-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, transform 0.2s;
  display: block;
}

.module-tile:hover {
  transform: translateY(-3px);
  text-decoration: none;
  border-color: var(--accent);
}

.module-tile .icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.module-tile.crm .icon { background: rgba(99, 102, 241, 0.2); color: var(--crm); }
.module-tile.helpdesk .icon { background: rgba(20, 184, 166, 0.2); color: var(--helpdesk); }
.module-tile.ai .icon { background: rgba(168, 85, 247, 0.2); color: var(--ai); }
.module-tile.reports .icon { background: rgba(245, 158, 11, 0.2); color: var(--reports); }
.module-tile.settings .icon { background: rgba(100, 116, 139, 0.25); color: #94a3b8; }
.module-tile.field .icon { background: rgba(239, 68, 68, 0.2); color: var(--field); }

.module-tile h3 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}

.module-tile ul {
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.module-tile li {
  padding: 0.2rem 0;
}

.module-tile li::before {
  content: '→ ';
  color: var(--accent);
  opacity: 0.7;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg-elevated);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}

.badge-open { background: rgba(61, 139, 253, 0.2); color: #93c5fd; }
.badge-won { background: rgba(34, 197, 94, 0.2); color: #86efac; }
.badge-hot { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.badge-sla { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.badge-ok { background: rgba(20, 184, 166, 0.2); color: #5eead4; }

/* Sub-nav tabs within module */
.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.subnav a {
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
}

.subnav a:hover,
.subnav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}

.section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 1rem;
  font-weight: 600;
}

/* Pipeline kanban mock */
.pipeline {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.pipeline-col {
  min-width: 200px;
  flex: 1;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  border: 1px solid var(--border);
}

.pipeline-col h4 {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.deal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.deal-card strong {
  display: block;
  margin-bottom: 0.25rem;
}

/* Chart placeholders */
.chart-bar {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  height: 120px;
  padding-top: 1rem;
}

.chart-bar span {
  flex: 1;
  background: linear-gradient(180deg, var(--accent), rgba(61, 139, 253, 0.3));
  border-radius: 4px 4px 0 0;
  min-height: 20%;
}

.chart-bar span:nth-child(1) { height: 45%; }
.chart-bar span:nth-child(2) { height: 72%; }
.chart-bar span:nth-child(3) { height: 58%; }
.chart-bar span:nth-child(4) { height: 90%; }
.chart-bar span:nth-child(5) { height: 65%; }
.chart-bar span:nth-child(6) { height: 80%; }

.timeline {
  border-left: 2px solid var(--border);
  margin-left: 0.5rem;
  padding-left: 1.25rem;
}

.timeline-item {
  position: relative;
  padding-bottom: 1.25rem;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.35rem;
  top: 0.35rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-card);
}

.timeline-item time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 1rem; }

/* Form mock */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
}

label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

input, select, textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  font-family: var(--font);
  font-size: 0.9rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
}

textarea {
  min-height: 80px;
  resize: vertical;
}

.kpi-ring {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.integration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.integration-tile {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 500;
}

.map-placeholder {
  height: 200px;
  background: linear-gradient(145deg, #1a2838, #0f1820);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}
