/* -------------------------------------------------------
   BRM PM — Corporate UI Styles
   Placement: /includes/styles.css
   Default: Light theme  |  Optional: [data-theme="dark"]
-------------------------------------------------------- */

/* ===== CSS Variables ===== */
:root{
  --bg: #f6f8fb;
  --page: #ffffff;
  --fg: #0f172a;
  --muted: #5b667a;
  --line: #e6eaf0;

  --brand: #1058e6;         /* BRM Blue */
  --brand-600: #0e4dcc;
  --brand-700: #0b3fa8;

  --success: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;

  --card: #ffffff;
  --card-hover: #f9fbff;

  --ring: rgba(16,88,230,.25);
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
  --shadow-md: 0 6px 18px rgba(16,24,40,.08);

  --radius: 12px;
  --radius-sm: 8px;

  --font: 14px/1.5 "Inter", ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Helvetica Neue", sans-serif;
}

html[data-theme="dark"]{
  --bg: #0b1220;
  --page: #0e1627;
  --fg: #e6edf6;
  --muted: #9aa8c0;
  --line: #1c2740;

  --card: #111a2e;
  --card-hover: #0f182c;

  --ring: rgba(56,132,255,.35);
  --shadow-sm: 0 1px 2px rgba(2,6,23,.4);
  --shadow-md: 0 6px 18px rgba(2,6,23,.45);
}

/* ===== Base ===== */
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background:var(--bg);
  color:var(--fg);
  font:var(--font);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}

a{color:var(--brand); text-decoration:none}
a:hover{text-decoration:underline}

img{max-width:100%; display:block}

/* ===== Layout ===== */
/* Ensure content doesn’t sit behind the header */
main.wrap {
  padding-top: 72px; /* adjust if header height changes */
}

.wrap{
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 20px;
}

.topbar{
  position:sticky; top:0; z-index:100;
  display:flex; align-items:center; gap:16px; justify-content:space-between;
  padding: 10px 20px;
  background: var(--page);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.topbar .brand{
  font-weight: 800;
  font-size: 18px;
  letter-spacing:.2px;
  display:flex; align-items:center; gap:8px;
}
.topbar .brand span{
  color: var(--brand);
}

.topbar nav{
  display:flex; gap:4px; flex-wrap:wrap;
}
.topbar nav a{
  display:inline-flex; align-items:center; gap:8px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--fg);
  text-decoration:none;
  border: 1px solid transparent;
}
.topbar nav a:hover{
  background: var(--card-hover);
  border-color: var(--line);
  text-decoration:none;
}
.topbar .user{
  display:flex; align-items:center; gap:10px;
  color: var(--muted);
}

/* ===== Cards & Panels ===== */
.card{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: background .2s ease, box-shadow .2s ease, transform .06s ease;
}
.card:hover{
  background: var(--card-hover);
}
.card h2, .card h3{
  margin:0 0 10px;
  letter-spacing:.2px;
}

/* ===== Grid Helpers ===== */
.grid{ display:grid; gap:16px }
.grid.cols-2{ grid-template-columns: repeat(2, minmax(0,1fr)) }
.grid.cols-3{ grid-template-columns: repeat(3, minmax(0,1fr)) }
.grid.cols-4{ grid-template-columns: repeat(4, minmax(0,1fr)) }

@media (max-width: 1024px){
  .grid.cols-4{ grid-template-columns: repeat(2, minmax(0,1fr)) }
}
@media (max-width: 800px){
  .grid.cols-3, .grid.cols-2, .grid.cols-4{ grid-template-columns: 1fr }
}

/* ===== Buttons ===== */
.btn{
  appearance:none;
  border:0;
  background: var(--brand);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  cursor:pointer;
  transition: transform .06s ease, box-shadow .2s ease, background .2s ease;
  display:inline-flex; align-items:center; gap:8px;
}
.btn:hover{ background: var(--brand-600) }
.btn:active{ transform: translateY(1px) }
.btn:focus{ outline:2px solid var(--ring); outline-offset:2px }

.btn.secondary{
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--line);
}
.btn.secondary:hover{
  background: var(--card-hover);
}
.btn.ghost{
  background: transparent;
  color: var(--brand);
  border: 1px dashed var(--brand);
}

/* Tag-like pills */
.pill{
  display:inline-flex; align-items:center; gap:8px;
  font-size:12px; padding:4px 8px; border-radius:999px;
  background:#eef3ff; color:#1f3a8a; border:1px solid #e0e7ff;
}
html[data-theme="dark"] .pill{ background:#07122a; color:#b9ccff; border-color:#0d1c3d }

/* ===== Forms ===== */
label{ display:block; font-weight:600; margin:8px 0 6px; color:var(--muted) }
.input, select, textarea{
  width:100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--fg);
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
html[data-theme="dark"] .input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea{ background:#0b1220 }

.input:focus, select:focus, textarea:focus{
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--ring);
  outline: none;
}
.input[readonly], .input:disabled{ background:#f3f5fa; color:#8b96a7 }
.row{ display:grid; grid-template-columns: 1fr 1fr; gap:12px }
@media (max-width: 800px){ .row{ grid-template-columns:1fr } }

/* Inline help + validation */
.help{ font-size:12px; color:var(--muted); margin-top:6px }
.err{ color: var(--danger) }

/* ===== Tables ===== */
.table{
  width:100%; border-collapse: separate; border-spacing:0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow:hidden;
  box-shadow: var(--shadow-sm);
}
.table th{
  text-align:left; font-size:12px; letter-spacing:.08em; text-transform:uppercase;
  color: var(--muted);
  background: linear-gradient(to bottom, #f9fbff, #f3f6fc);
  padding: 12px 12px; border-bottom: 1px solid var(--line);
}
.table td{
  padding: 12px; border-bottom: 1px solid var(--line);
}
.table tr:hover td{ background: var(--card-hover) }
.table tr:last-child td{ border-bottom:0 }

/* Numeric cells helper */
.t-right{text-align:right}
.t-center{text-align:center}

/* ===== Alerts / Flash ===== */
.flash{
  padding:12px 14px; border-radius:10px; border:1px solid;
  margin:10px 0; display:flex; gap:10px; align-items:flex-start;
  background:#f8fafc;
}
.flash.ok{ border-color: rgba(22,163,74,.35); background: rgba(22,163,74,.08); color:#065f46 }
.flash.warn{ border-color: rgba(217,119,6,.35); background: rgba(217,119,6,.08); color:#7c2d12 }
.flash.err{ border-color: rgba(220,38,38,.35); background: rgba(220,38,38,.08); color:#7f1d1d }
html[data-theme="dark"] .flash{ background:#0f182b }

/* ===== Breadcrumbs ===== */
.breadcrumbs{
  display:flex; flex-wrap:wrap; gap:8px; align-items:center;
  color: var(--muted); font-size:13px; margin-bottom:10px;
}
.breadcrumbs a{ color: var(--brand); text-decoration:none }
.breadcrumbs .sep{ opacity:.5 }

/* ===== Toolbar (lists, pages) ===== */
.toolbar{
  display:flex; flex-wrap:wrap; gap:10px; justify-content:space-between; align-items:center;
  margin-bottom:12px;
}
.toolbar .actions{ display:flex; gap:8px; align-items:center }

/* ===== Footer ===== */
.foot{
  color: var(--muted);
  text-align:center;
  padding: 26px 16px 40px;
}

/* ===== Small UX Polish ===== */
hr{ border:0; border-top:1px solid var(--line); margin:16px 0 }
kbd{
  background:#eef2ff; border:1px solid #e0e7ff; border-bottom-width:2px;
  padding:2px 6px; border-radius:6px; font-size:12px;
}
html[data-theme="dark"] kbd{ background:#0b1633; border-color:#102554 }

/* Focus visible for keyboard users */
:focus-visible{ outline:2px solid var(--ring); outline-offset:2px }

/* Reduce motion when user prefers */
@media (prefers-reduced-motion: reduce){
  *{animation-duration:0.01ms !important; animation-iteration-count:1 !important; transition-duration:0.01ms !important; scroll-behavior:auto !important}
}

/* ===== Print tweaks for PDFs (quotes, etc.) ===== */
@media print{
  .topbar, .toolbar, .btn{ display:none !important }
  body{ background:#fff; color:#000 }
  .card, .table{ box-shadow:none; border-color:#bbb }
}

/* ===== Empty states ===== */
.empty{
  padding:28px; border:1px dashed var(--line); border-radius: var(--radius);
  text-align:center; color:var(--muted); background: var(--page);
}

/* Dashboard Stat Cards */
.stat-card {
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  padding:20px;
  border-radius:var(--radius);
  background:var(--card);
  border:1px solid var(--line);
  box-shadow:var(--shadow-sm);
  transition: background .2s ease, transform .1s ease;
  min-height:140px;
}

.stat-card:hover {
  background:var(--card-hover);
  transform:translateY(-2px);
}

.stat-card b {
  font-size:2rem;
  font-weight:700;
  color:var(--brand);
  display:block;
}

.stat-card span {
  font-size:.95rem;
  color:var(--muted);
  display:block;
  margin-top:2px;
}

.stat-card a.btn {
  margin-top:12px;
  font-size:.8rem;
  padding:6px 10px;
  align-self:flex-start;
}

/* Active nav in dark mode */
html[data-theme="dark"] .topbar nav a.active {
  background: var(--brand);
  color: #fff;
  border-radius: 8px;
  font-weight: 600;
  padding: 8px 12px;
}
html[data-theme="dark"] .topbar nav a:hover {
  background: var(--card-hover);
  color: var(--ink);
}

/* Existing code remains unchanged above ... */

/* ===== Responsive Tweaks ===== */

/* Up to tablets (already in place) */
@media (max-width: 1024px){
  .grid.cols-4{ grid-template-columns: repeat(2, minmax(0,1fr)) }
}
@media (max-width: 800px){
  .grid.cols-3, .grid.cols-2, .grid.cols-4{ grid-template-columns: 1fr }
  .row{ grid-template-columns:1fr } /* forms stack */
}

/* Phones ≤ 480px */
@media (max-width: 480px){
  .topbar { flex-wrap:wrap; gap:8px; padding:8px 12px }
  .topbar nav a { padding:6px 8px; font-size:.9rem }
  .btn { padding:8px 12px; font-size:.9rem }
  .stat-card b { font-size:1.6rem }
  .stat-card { min-height:120px; padding:16px }
  .table th, .table td { padding:8px 6px; font-size:.85rem }
  .toolbar { flex-direction:column; align-items:flex-start; gap:8px }
}

/* Small devices ≤ 340px */
@media (max-width: 340px){
  body { font-size:13px }
  .topbar { padding:6px 10px; }
  .topbar .brand { font-size:16px }
  .btn { padding:6px 10px; font-size:.8rem; border-radius:6px }
  .stat-card { padding:14px; min-height:100px }
  .stat-card b { font-size:1.4rem }
  .stat-card span { font-size:.8rem }
  .card { padding:12px }
  .table th, .table td { padding:6px 4px; font-size:.75rem }
  .breadcrumbs { font-size:.8rem }
  .flash { padding:10px; font-size:.85rem }
  .foot { padding:18px 12px }
  .foot, .foot p, .foot ul { font-size:.8rem }
  .toolbar { flex-direction:column; align-items:stretch }
  .toolbar .actions { width:100%; flex-wrap:wrap; gap:6px }
}

/* Ensure content doesn’t sit behind the header */
main.wrap {
  padding-top: 150px; /* adjust if header height changes */
}
