/*
  MJ Labs CRM — stylesheet
  ========================================
  @author    Jimmy Lindmark
  @copyright MJ STRATEGI TECH SOLUTIONS SL
  @license   All Rights Reserved

  Same look as mjlabs.ai: Rajdhani and Nunito (served from this site), bright
  blue actions and a peach tint. Calmer than the public site: this is a work tool.
*/

@font-face { font-family: "Rajdhani"; font-weight: 600; font-display: swap; src: url("../fonts/rajdhani-600.woff2") format("woff2"); }
@font-face { font-family: "Rajdhani"; font-weight: 700; font-display: swap; src: url("../fonts/rajdhani-700.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 400 700; font-display: swap; src: url("../fonts/nunito.woff2") format("woff2"); }

:root {
  --blue:      #0c5adb;
  --blue-dark: #0a49b3;
  --navy:      #1c375b;
  --tint:      #fff8f4;
  --tint-2:    #f2f7ff;
  --ok:        #16855c;
  --red:       #c8372d;
  --amber:     #8a6200;
  --text:      #232323;
  --text-soft: #5f6368;
  --line:      #e6e9ef;
  --white:     #ffffff;
  --shadow:    0 10px 30px rgba(20, 40, 63, 0.07);
  --font-head: "Rajdhani", "Arial Narrow", Arial, sans-serif;
  --font-body: "Nunito", "Helvetica Neue", Arial, sans-serif;
  --font-mono: Consolas, "Courier New", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--tint); color: var(--text); font: 400 1rem/1.55 var(--font-body); -webkit-font-smoothing: antialiased; }
h1, h2 { margin: 0; color: var(--text); font-family: var(--font-head); font-weight: 700; line-height: 1.15; }
h1 { font-size: 2rem; }
h2 { margin: 1.8rem 0 0.8rem; font-size: 1.4rem; }
p { margin: 0; }
a { color: var(--blue); }
.muted { color: var(--text-soft); }
.lead { margin-bottom: 1.2rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header */
.topbar { display: flex; align-items: center; gap: 1.5rem; padding: 0.7rem clamp(1rem, 4vw, 2.5rem); background: var(--white); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--navy); font: 700 1.25rem/1 var(--font-head); letter-spacing: 0.04em; text-decoration: none; }
.brand em { color: var(--blue); font-style: normal; }
.brand-center { justify-content: center; width: 100%; margin-bottom: 1.5rem; }
.topnav { display: flex; gap: 0.3rem; flex: 1; flex-wrap: wrap; }
.topnav a { padding: 0.4rem 0.8rem; border-radius: 6px; color: var(--text-soft); font: 600 1.05rem/1.2 var(--font-head); text-decoration: none; transition: background-color 0.15s, transform 0.1s; }
.topnav a:hover { background: var(--tint-2); color: var(--blue); }
.topnav a:active { transform: scale(0.97); }
.topnav a.is-current { background: var(--tint-2); color: var(--blue); }
.topbar-logout { margin: 0; }
@media (max-width: 680px) {
  .topbar { gap: 0.6rem; justify-content: space-between; }
  .topnav { order: 3; flex: 1 0 100%; }
}

/* Page */
.page { max-width: 1120px; margin: 0 auto; padding: 1.8rem clamp(1rem, 4vw, 2.5rem) 4rem; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.card { padding: 1.3rem; background: var(--white); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.stack { display: grid; gap: 1rem; }
.actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.actions form { margin: 0; }
.empty { padding: 2rem; color: var(--text-soft); text-align: center; }
.notice { margin-bottom: 1rem; padding: 0.7rem 1rem; background: #fdf0cf; border-radius: 8px; color: #5c4400; }

/* Login */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.login-card { width: 100%; max-width: 420px; padding: 2rem; background: var(--white); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.login-card h1 { margin-bottom: 0.5rem; font-size: 1.7rem; }
.login-card p { margin-bottom: 1.2rem; }
.login-again { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; margin-top: 1rem; }
.link-quiet { color: var(--text-soft); font-size: 0.92rem; }
.field-code { font: 700 1.5rem/1.2 var(--font-mono); letter-spacing: 0.25em; text-align: center; }

/* Fields */
.field-wrap { display: grid; gap: 0.3rem; font-weight: 600; font-size: 0.92rem; }
.field { width: 100%; min-height: 44px; padding: 0.55rem 0.8rem; border: 1px solid #cfd5df; border-radius: 7px; background: var(--white); color: var(--text); font: 400 1rem/1.4 var(--font-body); }
textarea.field { resize: vertical; }
.field:focus-visible { outline: 3px solid rgba(12, 90, 219, 0.4); outline-offset: 1px; border-color: var(--blue); }
.field-error { min-height: 0; color: var(--red); font-weight: 600; font-size: 0.88rem; }
.field-error:empty { display: none; }

/* Buttons: every button presses; those that start something get spinner and receipt (crm.js) */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; min-height: 46px; padding: 0.6rem 1.5rem; border: 1px solid transparent; border-radius: 7px; font: 700 1rem/1.2 var(--font-body); text-decoration: none; cursor: pointer; transition: transform 0.1s ease, background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease; }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn:focus-visible, .topnav a:focus-visible, .brand:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid rgba(12, 90, 219, 0.45); outline-offset: 2px; }
.btn-primary { background: var(--blue); color: var(--white); }
.btn-primary:hover { background: var(--blue-dark); }
.btn-ghost { background: var(--white); border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); }
.btn-danger { background: var(--white); border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red); color: var(--white); }
.btn-small { min-height: 40px; padding: 0.4rem 1.1rem; font: 600 0.98rem/1.2 var(--font-head); letter-spacing: 0.02em; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.9; transform: none; }
.btn.is-busy { cursor: progress; }
.btn.is-busy::before { content: ""; width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
.btn.is-ok { background: var(--ok); border-color: transparent; color: var(--white); }
.btn.is-fail { background: var(--red); border-color: transparent; color: var(--white); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn.is-busy::before { animation-duration: 2s; } }

/* Search */
.search-bar { display: grid; grid-template-columns: 1fr 200px auto; gap: 0.6rem; margin-bottom: 1.2rem; }
@media (max-width: 680px) { .search-bar { grid-template-columns: 1fr; } }

/* Lists */
.table-wrap { overflow-x: auto; background: var(--white); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.list { width: 100%; border-collapse: collapse; }
.list th { padding: 0.7rem 1rem; color: var(--text-soft); font: 600 0.95rem/1.2 var(--font-head); text-align: left; border-bottom: 1px solid var(--line); }
.list td { padding: 0.65rem 1rem; border-bottom: 1px solid var(--line); }
.list tr:last-child td { border-bottom: 0; }
.list td a { font-weight: 700; text-decoration: none; }
.list td a:hover { text-decoration: underline; }
.cell-action { text-align: right; }
.cell-action form { margin: 0; }
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.2rem; }
.add-row { display: grid; grid-template-columns: 1fr 1fr auto; align-items: start; gap: 0.8rem; margin-bottom: 1.2rem; }
.add-row .btn { margin-top: 1.55rem; }
@media (max-width: 680px) { .add-row { grid-template-columns: 1fr; } .add-row .btn { margin-top: 0; } }

/* Status badges: text always says the status, colour only helps */
.status { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 20px; font-size: 0.85rem; font-weight: 700; white-space: nowrap; }
.status-lead { background: var(--tint-2); color: var(--blue-dark); }
.status-contacted { background: #e3f6fb; color: #0b6478; }
.status-quote { background: #fdf0cf; color: #6e5200; }
.status-customer { background: #dcf5e6; color: #0f6a48; }
.status-dormant { background: #eef0f3; color: #555b63; }

/* Facts */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin: 0; }
.facts dt { color: var(--text-soft); font-size: 0.85rem; font-weight: 600; }
.facts dd { margin: 0.1rem 0 0; overflow-wrap: anywhere; }
.facts-tight { grid-template-columns: 1fr; gap: 0.6rem; }

/* Notes */
.note { margin-top: 0.8rem; }
.note-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.note footer { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; margin-top: 0.7rem; font-size: 0.88rem; flex-wrap: wrap; }
.note footer form { margin: 0; }

/* Deploy */
.deploy-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.2rem; }
.deploy-card { display: grid; gap: 0.9rem; align-content: start; }
.deploy-card header { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap; }
.deploy-card h2 { margin: 0; }
.deploy-card h2 a { color: inherit; text-decoration: none; }
.deploy-state { font-size: 0.88rem; font-weight: 700; color: var(--ok); }
.deploy-state[data-state="failed"] { color: var(--red); }
.deploy-state[data-state="running"] { color: var(--blue); }
.deploy-state[data-state="unknown"] { color: var(--text-soft); }
.deploy-live { min-height: 1.4em; color: var(--text-soft); font-size: 0.92rem; }
.deploy-card .js-pull { justify-self: start; }
.deploy-log summary { color: var(--text-soft); font-size: 0.88rem; cursor: pointer; }
.deploy-log pre { max-height: 260px; margin: 0.5rem 0 0; padding: 0.7rem; overflow: auto; background: #14283f; border-radius: 6px; color: #dbe6f5; font: 0.8rem/1.45 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.is-warning { color: var(--red); font-weight: 700; }
