/**
 * murphy-app-shell.css — PATCH-154
 * Shared shell styles for all Murphy app pages (non-landing).
 * Canonical palette matching the landing page.
 * © 2020 Inoni LLC | BSL 1.1
 */

/* ── Google Fonts ────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Canonical Design Tokens ─────────────────────────────────────── */
:root {
  /* Landing-matching palette */
  --bg:         #0a0a0a;
  --bg2:        #111111;
  --bg3:        #161616;
  --surface:    #111111;
  --surface2:   #181818;
  --elevated:   #1a1a1a;

  /* Borders */
  --border:     rgba(0, 212, 170, 0.12);
  --border-mid: rgba(0, 212, 170, 0.22);
  --border-hi:  rgba(0, 212, 170, 0.4);

  /* Text */
  --text:       #e0e6ea;
  --text-dim:   #6b8090;
  --text-muted: #3a4a56;

  /* Brand colors */
  --teal:       #00D4AA;
  --teal-dim:   rgba(0, 212, 170, 0.1);
  --teal-glow:  rgba(0, 212, 170, 0.18);
  --green:      #00ff41;
  --cyan:       #00ffff;

  /* Semantic */
  --success:    #22C55E;
  --warning:    #FFA63E;
  --danger:     #EF4444;
  --info:       #3B9EFF;

  /* Fonts */
  --font:       Inter, system-ui, -apple-system, sans-serif;
  --font-code:  'JetBrains Mono', 'Courier New', monospace;

  /* Spacing */
  --space-1: 4px;  --space-2: 8px;   --space-3: 12px;
  --space-4: 16px; --space-5: 24px;  --space-6: 32px;
  --space-7: 48px; --space-8: 64px;

  /* Radius */
  --radius-sm: 4px;  --radius: 8px;
  --radius-md: 10px; --radius-lg: 14px; --radius-xl: 20px;

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(0,0,0,.4);
  --shadow-md:   0 4px 14px rgba(0,0,0,.5);
  --shadow-lg:   0 8px 28px rgba(0,0,0,.6);
  --shadow-teal: 0 0 20px rgba(0,212,170,.15);

  /* Layout */
  --sidebar-w:  220px;
  --topbar-h:   52px;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Scrollbar ───────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,212,170,.2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,212,170,.4); }
* { scrollbar-width: thin; scrollbar-color: rgba(0,212,170,.2) transparent; }

/* ── Focus ───────────────────────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

/* ── Typography ──────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 { font-weight: 700; line-height: 1.25; color: var(--text); }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }
h5 { font-size: .9rem; }
h6 { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); }

p { color: var(--text-dim); line-height: 1.7; margin-bottom: 12px; }

a { color: var(--teal); text-decoration: none; transition: color .15s; }
a:hover { color: var(--cyan); text-decoration: underline; }

code {
  font-family: var(--font-code); font-size: .85em;
  padding: 2px 6px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 4px; color: var(--teal);
}

pre {
  font-family: var(--font-code); font-size: .83rem;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; overflow-x: auto; margin-bottom: 16px;
}

/* ── App Shell Layout ────────────────────────────────────────────── */
.murphy-page-wrap {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.murphy-app-shell {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.murphy-app-main {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
  padding: 28px 32px;
}

/* ── Sidebar (populated by murphy-nav.js) ───────────────────────── */
#murphy-shared-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
}

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: border-color .2s, transform .2s, box-shadow .2s;
}
.card:hover {
  border-color: var(--border-mid);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0,212,170,.08);
}
.card-feat { background: rgba(0,212,170,.05); border-color: var(--border-mid); }
.card-feat:hover { border-color: var(--teal); box-shadow: var(--shadow-teal); }

/* ── Stat Cards ──────────────────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
}
.stat-label {
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-dim); margin-bottom: 6px;
}
.stat-value { font-size: 2rem; font-weight: 700; color: var(--teal); }
.stat-note  { font-size: .75rem; color: var(--text-dim); margin-top: 4px; }

/* ── Grids ───────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 18px; border-radius: var(--radius); border: none; cursor: pointer;
  font-family: var(--font); font-size: .875rem; font-weight: 600;
  transition: all .15s; text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary  { background: var(--teal); color: #0a0a0a; }
.btn-primary:hover { background: var(--cyan); color: #0a0a0a; box-shadow: 0 4px 18px rgba(0,212,170,.3); }
.btn-secondary { background: transparent; color: var(--teal); border: 1px solid rgba(0,212,170,.4); }
.btn-secondary:hover { background: var(--teal-dim); border-color: var(--teal); color: var(--teal); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); border-color: var(--border-mid); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 5px 12px; font-size: .78rem; border-radius: 6px; }
.btn-lg { padding: 11px 26px; font-size: 1rem; border-radius: var(--radius-lg); }
.btn:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }

/* ── Badges ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700;
}
.badge-teal    { background: rgba(0,212,170,.12); color: var(--teal); border: 1px solid rgba(0,212,170,.25); }
.badge-green   { background: rgba(34,197,94,.12); color: #22c55e;    border: 1px solid rgba(34,197,94,.25); }
.badge-yellow  { background: rgba(255,166,62,.12); color: #ffa63e;   border: 1px solid rgba(255,166,62,.25); }
.badge-red     { background: rgba(239,68,68,.12);  color: #ef4444;   border: 1px solid rgba(239,68,68,.25); }
.badge-blue    { background: rgba(59,158,255,.12); color: #3b9eff;   border: 1px solid rgba(59,158,255,.25); }

/* ── Tables ──────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th {
  color: var(--text-dim); font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border);
}
td { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,.04); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(0,212,170,.03); }

/* ── Form elements ───────────────────────────────────────────────── */
input, select, textarea {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-family: var(--font); font-size: .875rem;
  padding: 9px 12px; transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,212,170,.12);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
label { font-size: .82rem; font-weight: 600; color: var(--text-dim); display: block; margin-bottom: 5px; }

/* ── Page header ─────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 28px; gap: 16px; flex-wrap: wrap;
}
.page-title { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.page-sub   { font-size: .85rem; color: var(--text-dim); margin-top: 3px; }

/* ── Section panels ──────────────────────────────────────────────── */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 20px; margin-bottom: 20px;
}
.panel-title {
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-dim); margin-bottom: 14px;
  display: flex; align-items: center; gap: 6px;
}

/* ── Live pill ───────────────────────────────────────────────────── */
.pill-live {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(0,212,170,.08); border: 1px solid rgba(0,212,170,.22);
  border-radius: 999px; padding: 3px 10px;
  font-size: .7rem; font-weight: 700; color: var(--teal); letter-spacing: .04em;
}
.dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--teal);
  animation: dotPulse 1.4s infinite;
}
@keyframes dotPulse { 0%,100%{opacity:1} 50%{opacity:.35} }

/* ── Toast notification ──────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  background: var(--surface); border: 1px solid var(--border-mid);
  border-radius: var(--radius-md); padding: 14px 20px;
  box-shadow: var(--shadow-lg); font-size: .85rem; color: var(--text);
  animation: toastIn .2s ease;
}
.toast-success { border-color: rgba(34,197,94,.4); }
.toast-error   { border-color: rgba(239,68,68,.4); }
@keyframes toastIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

/* ── Responsive — PATCH-176 comprehensive mobile fix ─────────────── */

/* ─ Tablet (≤1024px) ─ */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }

  /* Common page-level panel rows (dashboard, compliance, etc.) */
  .panel-row          { grid-template-columns: 1fr !important; }
  .stats-row          { grid-template-columns: repeat(2,1fr) !important; }
  .metric-grid        { grid-template-columns: repeat(2,1fr) !important; }
  .kpi-grid           { grid-template-columns: repeat(2,1fr) !important; }
  .fw-grid            { grid-template-columns: repeat(2,1fr) !important; }
  .tier-grid          { grid-template-columns: repeat(3,1fr) !important; }
}

/* ─ Mobile (≤768px) — sidebar hidden by nav.js, content takes full width ─ */
@media (max-width: 768px) {
  /* ── Shell / layout ── */
  .murphy-app-shell,
  .shell,
  .app-layout,
  .layout,
  .forge-layout      { flex-direction: column !important; overflow: visible !important; }

  /* Sidebar: nav.js already hides it. Belt-and-suspenders here. */
  #murphy-shared-sidebar,
  aside              { display: none !important; }

  /* Main content fills the screen */
  .murphy-app-main,
  main,
  .main-area,
  .forge-main,
  .main-content      {
    flex: 1 !important;
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
    padding: 16px !important;
  }

  /* ── All grids collapse to 1 column ── */
  .grid-2, .grid-3, .grid-4, .grid-auto,
  .panel-row,
  .metric-grid,
  .kpi-grid,
  .stats-row,
  .compose-row,
  .fw-grid,
  .tier-grid,
  .shield-grid       { grid-template-columns: 1fr !important; }

  /* Tables — make scrollable rather than clipping */
  .table-wrap,
  .table-container   { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
  table              { min-width: 480px; }

  /* Headers / flex rows */
  .page-header,
  .page-header-row,
  .header-row,
  .controls          { flex-direction: column !important; align-items: flex-start !important; gap: 10px !important; }

  /* Buttons in header rows should stack or wrap */
  .page-header .btn,
  .header-row .btn   { width: 100%; justify-content: center; }

  /* Typography scale-down */
  h1, .page-title    { font-size: 1.3rem !important; }
  h2                 { font-size: 1.15rem !important; }
  .stat-value        { font-size: 1.6rem !important; }

  /* Cards shouldn't have hover transform on touch */
  .card:hover        { transform: none !important; }

  /* Modals & panels full-width */
  .modal-content,
  .panel             { width: 100% !important; max-width: 100% !important; box-sizing: border-box; }

  /* Toast — keep off the edge */
  .toast             { right: 12px !important; bottom: 12px !important; left: 12px !important; right: 12px !important; }

  /* Forms */
  .form-row,
  .input-row         { flex-direction: column !important; gap: 10px !important; }
  input, select, textarea { font-size: 16px !important; } /* prevent iOS zoom */

  /* Body safe */
  body               { overflow-y: auto !important; overflow-x: hidden !important;
                       height: auto !important; min-height: 100vh; }
}

/* ─ Small mobile (≤480px) ─ */
@media (max-width: 480px) {
  .murphy-app-main,
  main               { padding: 12px !important; }
  h1, .page-title    { font-size: 1.1rem !important; }
  .btn               { padding: 7px 14px !important; font-size: 0.8rem !important; }
  .stat-value        { font-size: 1.4rem !important; }
  table              { font-size: 0.78rem !important; }
  th, td             { padding: 8px !important; }
}
