/* apps/web/css/styles.css */

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

:root {
  /* HSL Color System */
  --bg-hue: 40;
  --bg-saturation: 30%;
  --bg-lightness: 96%;
  
  --bg: hsl(var(--bg-hue), var(--bg-saturation), var(--bg-lightness));
  --panel: hsl(var(--bg-hue), 25%, 98%);
  --panel-glass: rgba(255, 250, 240, 0.82);
  --ink: hsl(30, 15%, 10%);
  --muted: hsl(30, 10%, 40%);
  --line: hsl(30, 15%, 85%);
  --line-light: hsl(30, 15%, 92%);
  
  --accent: hsl(28, 55%, 35%);
  --accent-light: hsl(28, 50%, 48%);
  --accent-glow: rgba(138, 90, 43, 0.15);
  
  --good: hsl(152, 75%, 26%);
  --good-bg: hsl(152, 70%, 94%);
  --bad: hsl(355, 75%, 38%);
  --bad-bg: hsl(355, 70%, 95%);
  --warn: hsl(38, 85%, 38%);
  --warn-bg: hsl(38, 80%, 94%);
  
  --chip: hsl(35, 40%, 90%);
  --shadow: 0 16px 45px rgba(55, 38, 20, 0.08);
  --shadow-sm: 0 4px 12px rgba(55, 38, 20, 0.03);
  
  --radius: 20px;
  --radius-sm: 12px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font-display: 'Outfit', sans-serif;
  --font-sans: 'Inter', sans-serif;
}

/* Dark Mode Overrides */
body.dark {
  --bg-lightness: 8%;
  --bg: hsl(var(--bg-hue), 15%, var(--bg-lightness));
  --panel: hsl(var(--bg-hue), 10%, 12%);
  --panel-glass: rgba(30, 26, 22, 0.85);
  --ink: hsl(40, 20%, 92%);
  --muted: hsl(40, 10%, 65%);
  --line: hsl(30, 10%, 22%);
  --line-light: hsl(30, 10%, 18%);
  
  --accent: hsl(28, 55%, 52%);
  --accent-light: hsl(28, 60%, 62%);
  --accent-glow: rgba(184, 129, 69, 0.25);
  
  --good: hsl(152, 65%, 45%);
  --good-bg: rgba(15, 122, 79, 0.15);
  --bad: hsl(355, 70%, 58%);
  --bad-bg: rgba(180, 35, 24, 0.15);
  --warn: hsl(38, 80%, 55%);
  --warn-bg: rgba(183, 121, 31, 0.15);
  
  --chip: hsl(30, 12%, 18%);
  --shadow: 0 16px 45px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.5;
  transition: var(--transition);
  min-height: 100vh;
}

.shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 30px 24px;
}

/* Top Actions & Theme toggle */
.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 24px;
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle-btn {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 50%;
  width: 42px;
  height: 42px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.theme-toggle-btn:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

/* Cards & Hero */
.card {
  background: var(--panel-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.hero {
  display: grid;
  grid-template-columns: 1.35fr 0.65fr;
  gap: 20px;
  margin-bottom: 24px;
}

.hero-main {
  padding: 36px 40px;
  position: relative;
  overflow: hidden;
}

.hero-main::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -60px;
  width: 240px;
  height: 240px;
  background: var(--accent-glow);
  border-radius: 50%;
  filter: blur(20px);
  z-index: 0;
}

.eyebrow {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: 800;
  color: var(--accent-light);
  background: var(--chip);
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}

h1 {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}

.sub {
  font-size: 15px;
  color: var(--muted);
  max-width: 860px;
  line-height: 1.6;
  position: relative;
  z-index: 1;
}

.hero-side {
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.mini {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 12px;
}

.mini:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.mini .label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

.mini .value {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

/* Nav & Tabs sticky bar */
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0;
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 10px;
  background: rgba(var(--bg-hue), 20%, 95%, 0.8);
  backdrop-filter: blur(16px);
  border-radius: 999px;
  border: 1px solid var(--line);
}

.tab-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  transition: var(--transition);
}

.tab-btn:hover {
  background: var(--chip);
}

.tab-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

button.action {
  border: 0;
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(138, 90, 43, 0.2);
}

button.action:hover {
  background: var(--accent-light);
  transform: translateY(-1px);
}

button.action.secondary {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

button.action.secondary:hover {
  border-color: var(--accent);
  background: var(--chip);
}

button.action.danger {
  background: var(--bad);
  box-shadow: 0 4px 12px rgba(180, 35, 24, 0.2);
}

button.action.danger:hover {
  background: hsl(355, 75%, 48%);
}

/* Grids & Panels */
.grid {
  display: grid;
  gap: 20px;
}

.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.tab {
  display: none;
  animation: fadeIn 0.4s ease;
}

.tab.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.section {
  padding: 30px;
}

.section h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.section p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 20px;
}

/* KPI Cards */
.kpis {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line-light);
  border-radius: 16px;
  padding: 20px;
  min-height: 120px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.kpi:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.kpi::before {
  content: "";
  position: absolute;
  right: -20px;
  bottom: -20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent-glow);
  z-index: 0;
  transition: var(--transition);
}

.kpi:hover::before {
  transform: scale(1.2);
}

.kpi .name {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 800;
  color: var(--muted);
  position: relative;
  z-index: 1;
}

.kpi .num {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 900;
  margin-top: 10px;
  letter-spacing: -0.03em;
  position: relative;
  z-index: 1;
}

.kpi .hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  position: relative;
  z-index: 1;
}

/* Alerts / Callouts */
.callout {
  border-left: 4px solid var(--accent);
  background: var(--panel);
  border-radius: 12px;
  padding: 16px;
  border-top: 1px solid var(--line-light);
  border-right: 1px solid var(--line-light);
  border-bottom: 1px solid var(--line-light);
  font-size: 13px;
  box-shadow: var(--shadow-sm);
}

.callout.good { border-left-color: var(--good); }
.callout.bad { border-left-color: var(--bad); }
.callout.warn { border-left-color: var(--warn); }

.callout b {
  display: block;
  font-weight: 700;
  margin-bottom: 4px;
}

.callout p {
  margin: 0;
  color: var(--muted);
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

label.field {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  transition: var(--transition);
}

label.field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

label.field span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 8px;
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--bg);
  color: var(--ink);
  outline: none;
  transition: var(--transition);
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
  border-color: var(--accent-light);
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
}

input[type="range"]:focus {
  outline: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  cursor: pointer;
  background: var(--line);
  border-radius: 3px;
}

input[type="range"]::-webkit-slider-thumb {
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  -webkit-appearance: none;
  margin-top: -6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  transition: var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: var(--accent-light);
  transform: scale(1.15);
}

.toggle {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 14px;
  border-radius: 14px;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 900px;
}

th, td {
  border-bottom: 1px solid var(--line-light);
  padding: 12px 16px;
  text-align: right;
  vertical-align: middle;
  font-size: 14px;
}

th:first-child, td:first-child {
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  background: var(--chip);
  color: var(--ink);
  font-weight: 800;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  z-index: 2;
}

tr.group td {
  background: var(--chip);
  font-weight: 800;
  color: var(--ink);
}

tr.subtotal td {
  font-weight: 800;
  background: rgba(138, 90, 43, 0.05);
}

tr:last-child td {
  border-bottom: 0;
}

td.note {
  color: var(--muted);
  font-size: 12px;
  text-align: left;
}

.input-table input {
  max-width: 130px;
  text-align: right;
}

/* Status Pills */
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 800;
  background: var(--chip);
  color: var(--ink);
}

.pill.good { background: var(--good-bg); color: var(--good); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }

/* Horizontal Bars chart */
.bars {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 160px 1fr 120px;
  gap: 16px;
  align-items: center;
  font-size: 13px;
}

.bar-row b {
  font-weight: 600;
}

.bar {
  height: 12px;
  background: var(--line-light);
  border-radius: 999px;
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-light), var(--accent));
  border-radius: 999px;
  min-width: 2px;
  transition: width 0.6s ease;
}

/* Contact & Info Cards */
.contact-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
}

.contact-card h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 8px;
}

.contact-card p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 16px;
}

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.contact-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
  transition: var(--transition);
}

.contact-actions a.primary {
  background: var(--accent);
  color: #fff;
}

.contact-actions a.primary:hover {
  background: var(--accent-light);
}

.contact-actions a.secondary {
  background: var(--panel);
  color: var(--accent);
  border: 1px solid var(--accent);
}

.contact-actions a.secondary:hover {
  background: var(--chip);
}

.links a {
  display: block;
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  margin: 12px 0;
  transition: var(--transition);
}

.links a:hover {
  color: var(--accent-light);
  text-decoration: underline;
}

.footer {
  margin: 30px 0 10px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.footer-meta {
  font-size: 11px;
  margin-top: 6px;
  color: var(--muted);
}

/* Modals (Authentication) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px;
  width: 100%;
  max-width: 420px;
  transform: translateY(20px);
  transition: var(--transition);
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 900;
  margin-bottom: 8px;
  text-align: center;
}

.modal p {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  margin-bottom: 24px;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Turnstile Widget */
.cf-turnstile-container {
  display: flex;
  justify-content: center;
  margin: 10px 0;
}

/* Projects selection panel */
.project-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  padding: 12px 20px;
  border-radius: 16px;
  border: 1px solid var(--line);
  margin-bottom: 20px;
}

.project-select {
  flex-grow: 1;
  max-width: 320px;
}

.project-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
}

/* Color definitions */
.positive { color: var(--good) !important; }
.negative { color: var(--bad) !important; }
.warning { color: var(--warn) !important; }

/* Responsive adjustments */
@media (max-width: 1100px) {
  .hero {
    grid-template-columns: 1fr;
  }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .kpis {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .shell {
    padding: 16px;
  }
  .grid-2, .grid-3, .grid-4, .form-grid {
    grid-template-columns: 1fr;
  }
  .kpis {
    grid-template-columns: 1fr 1fr;
  }
  .nav {
    border-radius: 16px;
  }
  .actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }
}

@media print {
  body { background: white; color: black; }
  .nav, .actions, button, .theme-toggle-btn, .top-header, .project-bar {
    display: none !important;
  }
  .tab {
    display: block !important;
    page-break-after: always;
  }
  .card {
    border: none;
    box-shadow: none;
    background: transparent;
  }
}
