/* ==========================================================================
   Tupine — Global Styles
   File: static/css/styles.css
   ========================================================================== */

/* ------------------------------
   Theme variables & base tweaks
   ------------------------------ */
:root {
  --brand: #4a62d9;          /* primary accent used across UI */
  --brand-dark: #2c3e50;     /* darker hover/active shade */
  --ink: #23395d;            /* primary text color */
  --muted: #6a7895;          /* secondary text color */
  --bg: #f8fafc;             /* app background */
  --card-shadow: 0 6px 18px rgba(35,57,93,.08);
  --border: #e5e8f3;
  --border-soft: #e6e8ef;
}

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg, video, canvas { max-width: 100%; height: auto; display: block; }
main { flex-grow: 1; }

/* Container max width polish (keeps layouts nicely centered on wide screens) */
@media (min-width: 1400px) {
  .container, .container-lg, .container-xl, .container-xxl { max-width: 1200px; }
}

/* ------------------------------
   Navbar
   ------------------------------ */
.navbar {
  padding: 1rem 2rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
  background: #fff;
}

.navbar-brand img {
  height: 40px; /* constrained height; inline styles can override if needed */
  margin-right: 10px;
}

.navbar-brand {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: .2px;
}

.nav-link {
  color: var(--brand);
  font-weight: 500;
  border-radius: .5rem;
}

.nav-link:hover,
.nav-link.active {
  color: var(--brand-dark);
  background-color: #e9ecef;
}

/* Offcanvas (optional sidebar) */
.offcanvas {
  background-color: #ffffff;
  border-right: 1px solid var(--border);
}

/* ------------------------------
   Cards
   ------------------------------ */
.card {
  border: none;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  transition: transform .2s ease, box-shadow .2s ease;
  background: #fff;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(35,57,93,.12);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.card-text {
  font-size: 1.05rem;
  font-weight: 500;
}

/* ------------------------------
   Tables
   ------------------------------ */
.table {
  background-color: #ffffff;
  border-radius: 12px;
  overflow: hidden;
}

.table thead th {
  background-color: var(--brand);
  color: #ffffff;
  border-bottom: 0;
}

.table td, .table th {
  vertical-align: middle;
  padding: .6rem .75rem;
}

.table-wrap { overflow-x: auto; }

/* Sticky header helper */
.table.sticky-head thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef2fb;
  color: var(--ink);
  font-weight: 700;
  border-bottom: 1px solid #dde3f0;
}

/* Hover polish */
.table-hover tbody tr:hover {
  background-color: #f6f8fc;
  transition: background-color .15s ease-in-out;
}

/* ------------------------------
   Buttons / dropdowns
   ------------------------------ */
.btn {
  border-radius: .6rem;
}

.btn-primary {
  background-color: var(--brand);
  border-color: var(--brand);
}

.btn-primary:hover {
  background-color: var(--brand-dark);
  border-color: var(--brand-dark);
}

.btn-outline-slate {
  border-color: #cfd6e4;
  color: var(--ink);
}
.btn-outline-slate:hover {
  background: #e9edf7;
}

.dropdown-menu {
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(35,57,93,.12);
  border: 1px solid var(--border);
}

/* Active state helpers (e.g., filter button groups) */
.btn-group .btn.active {
  background: #005BB5;
  color: #fff;
}

/* ------------------------------
   KPI chips (status pills)
   ------------------------------ */
.kpi-chip {
  display: inline-block;
  min-width: 44px;
  padding: .2rem .5rem;
  border-radius: .5rem;
  text-align: center;
  font-weight: 700;
  font-size: .9rem;
}
.kpi-ok   { background: #e8f6ee; color: #177245; }
.kpi-warn { background: #fff4e0; color: #a35b00; }
.kpi-bad  { background: #ffe9ea; color: #b00020; }

/* ------------------------------
   Panels
   ------------------------------ */
.panel {
  border: 0;
  border-radius: 1rem;
  background: #fff;
  box-shadow: var(--card-shadow);
}

/* ------------------------------
   Dashboard Layout (Topbar + Sidebar + Grid)
   These styles back the dashboard.html structure and are safe globally.
   ------------------------------ */

/* Overall wrap */
.dash-wrap {
  background: #f6f8fb;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px 1fr;
}

/* Top bar (fixed) */
:root { --topbar-h: 48px; }

.dash-topbar {
  background: #0078D4;
  color: #fff;
  border-radius: 10px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  height: var(--topbar-h);
}

.dash-topbar .logo {
  height: 26px;
  margin-right: 10px;
}

.dash-topbar .btn {
  background: #005BB5;
  color: #fff;
  padding: 5px 10px;
  font-size: .85rem;
  border: 0;
}
.dash-topbar .btn:hover { background: #004d99; }
.dash-topbar .btn-outline {
  background: transparent;
  border: 1px solid rgba(255,255,255,.5);
}

/* Sidebar */
.dash-sidebar {
  background: #f6f7fb;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  border-right: 1px solid var(--border-soft);
  padding: 12px 8px;
  position: sticky;
  top: var(--topbar-h);
}

.side-section { margin-bottom: 12px; }
.side-title {
  font-weight: 600;
  font-size: .8rem;
  color: #6c757d;
  padding: 4px 6px;
  text-transform: uppercase;
}

.side-list { list-style: none; margin: 0; padding: 0; }

.side-item > a,
.side-item button {
  width: 100%;
  display: flex;
  gap: 6px;
  align-items: center;
  text-align: left;
  padding: 6px 8px;
  border-radius: 6px;
  color: #1f2a44;
  background: transparent;
  border: 0;
  font-size: .85rem;
}

.side-item > a:hover,
.side-item button:hover {
  background: #e9eefc;
  text-decoration: none;
}

.side-sub {
  list-style: none;
  margin: 4px 0 0 6px;
  padding-left: 6px;
  border-left: 2px solid var(--border-soft);
}
.side-sub a {
  display: block;
  padding: 4px 8px;
  border-radius: 4px;
  color: #334155;
  font-size: .8rem;
}
.side-sub a:hover { background: #eef3ff; text-decoration: none; }

/* Main content */
.dash-main {
  padding: 14px;
  overflow: auto;
  min-width: 0;
  margin-top: var(--topbar-h);
}

/* Filter bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  font-size: .85rem;
}

/* Grid board (CSS-grid replacement for GridStack-like layout) */
.grid-board {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
}

/* Required for each widget/card inside the grid */
.grid-item {
  position: static !important; /* neutralize any external inline positioning */
  min-width: 0;
}

/* Width spans */
.grid-item[gs-w="12"] { grid-column: span 12; }
.grid-item[gs-w="9"]  { grid-column: span 9;  }
.grid-item[gs-w="8"]  { grid-column: span 8;  }
.grid-item[gs-w="6"]  { grid-column: span 6;  }
.grid-item[gs-w="4"]  { grid-column: span 4;  }
.grid-item[gs-w="3"]  { grid-column: span 3;  }

/* Height spans (visual scaling for rows) */
.grid-item[gs-h="1"] { grid-row: span 1; }
.grid-item[gs-h="2"] { grid-row: span 2; }
.grid-item[gs-h="3"] { grid-row: span 3; }
.grid-item[gs-h="4"] { grid-row: span 4; }
.grid-item[gs-h="5"] { grid-row: span 5; }
.grid-item[gs-h="7"] { grid-row: span 7; }

/* Responsive collapse */
@media (max-width: 1200px) {
  .dash-wrap { grid-template-columns: 1fr; } /* collapse sidebar if desired */
  .grid-board { grid-template-columns: repeat(8, 1fr); }
  .grid-item[gs-w="6"] { grid-column: span 8; }
  .grid-item[gs-w="4"] { grid-column: span 8; }
  .grid-item[gs-w="3"] { grid-column: span 4; }
  .dash-sidebar { position: static; height: auto; border-right: 0; top: 0; }
}

@media (max-width: 768px) {
  .grid-board { grid-template-columns: repeat(1, 1fr); }
  .grid-item { grid-column: 1 / -1 !important; grid-row: span 1 !important; }
}

/* ------------------------------
   Metric cards (used widely)
   ------------------------------ */
.metric-card {
  background: linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: var(--card-shadow);
  min-height: 100%;
  position: relative;
}

.metric-title {
  color: #6a7895;
  font-weight: 600;
  font-size: .9rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.metric-value {
  color: var(--ink);
  font-weight: 800;
  font-size: 1.75rem;
  line-height: 1.1;
}

.metric-sub {
  color: #7b8aa9;
  font-size: .95rem;
}

.metric-card h6 {
  font-size: 1.1rem;
  margin-bottom: 12px;
  font-weight: 700;
}

.metric-card .small { font-size: .9rem; color: #6b7280; }
.metric-card .h6 { font-size: 1.1rem; font-weight: 700; margin: 0; }

/* ------------------------------
   Home page light helpers
   ------------------------------ */
.home-hero * { box-sizing: border-box; }
.home-hero { overflow-x: clip; }
.home-card img { max-width: 100%; height: auto; display: block; }
.card-link { font-size: .95rem; }

/* ------------------------------
   Utility classes
   ------------------------------ */
.text-muted-compact { color: #6b7280; font-size: .9rem; }
.rounded-12 { border-radius: 12px; }
.shadow-soft { box-shadow: var(--card-shadow); }


