/* =============================================================
   THORNE TECHNOLOGY — PORTAL UNIFIED SHELL
   v3.0 | portal-shell.css
   ============================================================= */

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

/* ── Reset / Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --purple:        #6B3FA0;
  --purple-dark:   #4E2D78;
  --purple-light:  #8B5CC8;
  --lime:          #A8FF3E;
  --lime-dim:      #7ACC1F;
  --bg:            #F4F5F8;
  --surface:       #FFFFFF;
  --border:        #E2E5EB;
  --text:          #1A1D23;
  --text-muted:    #6B7280;
  --sidebar-w:     240px;
  --topbar-h:      60px;
  --radius:        10px;
  --shadow:        0 2px 8px rgba(0,0,0,0.08);
}

html, body {
  height: 100%;
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* ── Layout ───────────────────────────────────────────────── */
.portal-wrap {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.portal-sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--purple-dark);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  position: fixed;
  left: 0; top: 0;
  z-index: 100;
}

.ps-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.ps-logo img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex-shrink: 0;
}

.ps-logo-text {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.ps-logo-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  line-height: 1.2;
}

.ps-nav {
  flex: 1;
  padding: 10px 0;
}

.ps-section {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  padding: 14px 16px 4px;
}

.ps-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}

.ps-link:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.ps-link.active {
  background: rgba(168,255,62,0.12);
  color: var(--lime);
  border-left-color: var(--lime);
}

.ps-icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.ps-bottom {
  padding: 10px 0 14px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.ps-bottom-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: color 0.15s;
}

.ps-bottom-link:hover { color: #fff; }

/* ── Main area ────────────────────────────────────────────── */
.portal-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Topbar ───────────────────────────────────────────────── */
.portal-topbar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.pt-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.pt-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pt-help-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: none;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  font-family: 'DM Sans', sans-serif;
}
.pt-help-btn:hover { border-color: var(--purple); color: var(--purple); }

/* Account dropdown */
.pt-account {
  position: relative;
}

.pt-account-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: none;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: border-color 0.15s;
}
.pt-account-btn:hover { border-color: var(--purple); }

.pt-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--purple);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pt-name-block {
  text-align: left;
  line-height: 1.2;
}
.pt-welcome { font-size: 12px; font-weight: 600; color: var(--text); }
.pt-company { font-size: 11px; color: var(--text-muted); }

.pt-caret { font-size: 10px; color: var(--text-muted); }

.pt-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 190px;
  z-index: 200;
}
.pt-dropdown.open { display: block; }

.pt-dropdown a,
.pt-dropdown button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.12s;
}
.pt-dropdown a:hover,
.pt-dropdown button:hover { background: var(--bg); }

.pt-dropdown hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

/* ── Content area ─────────────────────────────────────────── */
.portal-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 28px 40px;
}

/* ── Cards / Panels ───────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
}

/* Stat cards row */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--purple);
  line-height: 1;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-green  { background: #DCFCE7; color: #15803D; }
.badge-blue   { background: #DBEAFE; color: #1D4ED8; }
.badge-yellow { background: #FEF9C3; color: #A16207; }
.badge-red    { background: #FEE2E2; color: #B91C1C; }
.badge-grey   { background: #F3F4F6; color: #6B7280; }
.badge-purple { background: #EDE9FE; color: #6D28D9; }

/* ── Tables ───────────────────────────────────────────────── */
.tt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.tt-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
}
.tt-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tt-table tr:last-child td { border-bottom: none; }
.tt-table tbody tr:hover { background: #FAFBFC; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary   { background: var(--purple); color: #fff; }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--purple); color: var(--purple); }
.btn-danger    { background: #FEE2E2; color: #B91C1C; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s;
  outline: none;
}
.form-control:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(107,63,160,0.12); }
textarea.form-control { resize: vertical; min-height: 90px; }

/* ── Help modal ───────────────────────────────────────────── */
.help-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 900;
  align-items: center;
  justify-content: center;
}
.help-overlay.open { display: flex; }

.help-modal {
  background: var(--surface);
  border-radius: 14px;
  width: 480px;
  max-width: 95vw;
  max-height: 80vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.help-modal h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 18px;
}

.help-guide {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.help-guide:hover { border-color: var(--purple); }
.help-guide h4 { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.help-guide p  { font-size: 13px; color: var(--text-muted); }

.help-close {
  margin-top: 16px;
  width: 100%;
}

/* ── Pipeline (repairs) ───────────────────────────────────── */
.pipeline {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.pipeline-col {
  min-width: 200px;
  flex: 1;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px;
}

.pipeline-col-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.pipeline-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.pipeline-card .device  { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.pipeline-card .issue   { font-size: 12px; color: var(--text-muted); }
.pipeline-card .ref     { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* ── Permissions hidden ───────────────────────────────────── */
[data-perm] { /* shown by default, JS hides based on permissions */ }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .portal-sidebar { transform: translateX(-100%); transition: transform 0.25s; }
  .portal-sidebar.open { transform: translateX(0); }
  .portal-main { margin-left: 0; }
  .portal-content { padding: 16px; }
}
