/* ============================================================
   OnCall Intelligence — App Stylesheet
   Bootstrap 5 + Brand Overrides + App Shell
   Reference: /docs/brand.md
   ============================================================ */

/* ── Brand Tokens ─────────────────────────────────────────── */
:root {
  --ink:   #172f2d;
  --muted: #61706b;
  --paper: #f8f9f3;
  --line:  #dce2d7;
  --green: #264f44;
  --lime:  #d9efb9;

  /* Sidebar palette */
  --sb-bg:       #1a3530;
  --sb-hover:    #243e38;
  --sb-active:   #2d5447;
  --sb-border:   #2d4a43;
  --sb-text:     #b0c4bc;
  --sb-muted:    #5a7a70;
  --sb-width:    240px;
  --sb-collapsed:64px;

  /* Header */
  --hdr-height:  60px;

  /* Bootstrap overrides */
  --bs-primary:            #172f2d;
  --bs-primary-rgb:        23, 47, 45;
  --bs-body-bg:            #f8f9f3;
  --bs-body-color:         #172f2d;
  --bs-border-color:       #dce2d7;
  --bs-link-color:         #264f44;
  --bs-link-hover-color:   #325e4e;
  --bs-font-sans-serif:    Arial, Helvetica, sans-serif;
  --bs-border-radius:      6px;
  --bs-border-radius-lg:   10px;
}

/* ── Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: Arial, Helvetica, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
  margin: 0;
}

a { color: var(--green); }
a:hover { color: #325e4e; }

h1, h2, h3, h4, h5, h6 {
  line-height: 1.12;
  letter-spacing: -0.045em;
  font-weight: 500;
  color: var(--ink);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary {
  --bs-btn-bg:                var(--ink);
  --bs-btn-border-color:      var(--ink);
  --bs-btn-color:             #ffffff;
  --bs-btn-hover-bg:          #325e4e;
  --bs-btn-hover-border-color:#325e4e;
  --bs-btn-hover-color:       #ffffff;
  --bs-btn-active-bg:         #264f44;
  --bs-btn-active-border-color:#264f44;
  --bs-btn-focus-shadow-rgb:  23, 47, 45;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  padding: 10px 20px;
  transition: background .2s, transform .2s;
}
.btn-primary:hover { transform: translateY(-1px); }

.btn-lime {
  background: var(--lime);
  color: #183b2d;
  border: none;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  padding: 10px 20px;
  transition: background .2s;
}
.btn-lime:hover { background: #eefbdc; color: #183b2d; }

/* ── Forms ────────────────────────────────────────────────── */
.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 5px;
}

.form-control, .form-select {
  border-color: var(--line);
  border-radius: 6px;
  font-size: 14px;
  color: var(--ink);
  background-color: #fff;
}

.form-control:focus, .form-select:focus {
  border-color: #9a6500;
  box-shadow: 0 0 0 3px rgba(154, 101, 0, .15);
  outline: none;
}

.form-control::placeholder { color: var(--muted); }
.form-text { font-size: 11px; color: var(--muted); }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffefb;
  box-shadow: 0 10px 30px rgba(32,59,52,.07);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  padding: 18px 24px;
}

.card-body { padding: 24px; }

/* ── Status Pills ─────────────────────────────────────────── */
.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.pill-amber { background: #f5edcf; color: #73561b; }
.pill-green { background: #e5efde; color: #426239; }
.pill-gray  { background: #edf0ed; color: #526354; }

/* ── Eyebrow Labels ───────────────────────────────────────── */
.eyebrow {
  font-size: 10px;
  letter-spacing: 1.8px;
  font-weight: 700;
  color: var(--green);
  text-transform: uppercase;
}

/* ── Brand Mark ───────────────────────────────────────────── */
.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.8px;
  line-height: 1.02;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark .mark-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: var(--lime);
  width: 44px;
  height: 44px;
  border-radius: 13px;
  flex-shrink: 0;
}
.brand-mark .mark-icon svg { width: 28px; height: 28px; }
.brand-mark .brand-sub {
  display: block;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 1.3px;
  margin-top: 5px;
}

/* ── Auth Layout ──────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  padding: 40px 16px;
}

.auth-card { width: 100%; max-width: 440px; }
.auth-card .card-body { padding: 36px 40px; }

.auth-brand { text-align: center; margin-bottom: 28px; }

.auth-title {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.04em;
  margin-bottom: 4px;
}

.auth-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 24px;
}

/* ── Alerts ───────────────────────────────────────────────── */
.alert-brand-error {
  background: #fdf3f3;
  border: 1px solid #e8c4c4;
  color: #7a2a2a;
  border-radius: 6px;
  font-size: 13px;
  padding: 10px 14px;
}
.alert-brand-success {
  background: #f0f8ea;
  border: 1px solid #c5ddb4;
  color: #2f5c1e;
  border-radius: 6px;
  font-size: 13px;
  padding: 10px 14px;
}

/* ── Divider ──────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}

/* ── Utilities ────────────────────────────────────────────── */
.text-muted-brand { color: var(--muted) !important; }
.text-green       { color: var(--green) !important; }
.bg-paper         { background: var(--paper) !important; }
.border-brand     { border-color: var(--line) !important; }

/* ============================================================
   App Shell Layout
   ============================================================ */

/* ── Shell wrapper ────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sb-width);
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width .2s ease;
  z-index: 100;
}

.sidebar.collapsed {
  width: var(--sb-collapsed);
}

/* Brand area */
.sidebar-brand {
  padding: 18px 14px 17px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  overflow: hidden;
  min-height: var(--hdr-height);
}

/* Override brand-mark colours for dark sidebar */
.sidebar-brand .brand-mark {
  color: #e5ede8;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-brand .brand-mark .mark-icon {
  background: var(--lime);
  color: var(--ink);
  flex-shrink: 0;
}

/* Hide wordmark when collapsed */
.sidebar.collapsed .sidebar-brand .brand-mark > span:last-child {
  display: none;
}

/* Nav scroll area */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--sb-border) transparent;
}

/* Group headings */
.nav-group-label {
  font-size: 9px;
  letter-spacing: 1.6px;
  font-weight: 700;
  color: var(--sb-muted);
  padding: 16px 20px 5px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
}

.sidebar.collapsed .nav-group-label { opacity: 0; height: 0; padding: 0; overflow: hidden; }

/* Admin group toggle button */
.nav-group-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  background: none;
  border: none;
  padding: 16px 20px 5px;
  cursor: pointer;
  font-size: 9px;
  letter-spacing: 1.6px;
  font-weight: 700;
  color: var(--sb-muted);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
}

.nav-group-toggle .toggle-caret {
  margin-left: auto;
  font-size: 11px;
  transition: transform .2s;
}

.nav-group-toggle.is-closed .toggle-caret { transform: rotate(-90deg); }

.sidebar.collapsed .nav-group-toggle { opacity: 0; height: 0; padding: 0; overflow: hidden; }

/* Admin items collapse */
.admin-nav-items {
  overflow: hidden;
  transition: max-height .25s ease;
  max-height: 600px; /* tall enough to fit all items */
}

.admin-nav-items.is-closed { max-height: 0; }
.sidebar.collapsed .admin-nav-items { max-height: 600px !important; }

/* Nav items */
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  margin: 1px 8px;
  border-radius: 6px;
  color: var(--sb-text);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  transition: background .15s, color .15s;
  cursor: pointer;
}

.nav-item:hover  { background: var(--sb-hover);  color: #e0ede8; }
.nav-item.active { background: var(--sb-active);  color: #ffffff; }

.nav-item .nav-icon {
  font-size: 15px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  line-height: 1;
}

.nav-item .nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-badge {
  background: var(--lime);
  color: #183b2d;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: auto;
  flex-shrink: 0;
  line-height: 1.6;
}

/* Collapsed: center icons, hide text + badges */
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px 0;
  margin: 1px 8px;
  gap: 0;
}

.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-badge { display: none; }

/* ── Mobile backdrop ──────────────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 99;
}

.sidebar-backdrop.visible { display: block; }

/* ── App content area ─────────────────────────────────────── */
.app-content {
  margin-left: var(--sb-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left .2s ease;
}

.app-shell.sidebar-collapsed .app-content {
  margin-left: var(--sb-collapsed);
}

/* ── App Header ───────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  height: var(--hdr-height);
  background: #fffefb;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px 0 16px;
  z-index: 50;
  flex-shrink: 0;
}

.header-toggle {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 5px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.header-toggle:hover { color: var(--ink); background: #eef1ec; }

/* Search */
.header-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.header-search .search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}

.header-search input {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 12px 7px 34px;
  font-size: 13px;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}

.header-search input:focus {
  outline: none;
  border-color: #9a6500;
  box-shadow: 0 0 0 3px rgba(154,101,0,.15);
  background: #fff;
}

.header-search input::placeholder { color: var(--muted); }

/* Right-side actions */
.header-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.btn-new-request {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 7px 15px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s;
  margin-right: 6px;
}
.btn-new-request:hover { background: #325e4e; color: #fff; }

.header-icon-btn {
  position: relative;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 19px;
  padding: 7px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1;
  transition: color .15s, background .15s;
}
.header-icon-btn:hover { color: var(--ink); background: #eef1ec; }

/* Notification dropdown */
.notif-wrap { position: relative; }

.notif-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 310px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(23,47,45,.12);
  z-index: 200;
  overflow: hidden;
}
.notif-dropdown.open { display: block; }

.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
}

.notif-empty {
  padding: 36px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.notif-empty i { font-size: 28px; display: block; margin-bottom: 10px; color: var(--line); }

/* User menu */
.user-menu-wrap { position: relative; }

.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 6px;
  transition: background .15s;
}
.user-menu-btn:hover { background: #eef1ec; }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
}

.user-info { text-align: left; line-height: 1.25; }
.user-name { font-size: 13px; font-weight: 600; color: var(--ink); display: block; }
.user-role { font-size: 10px; color: var(--muted); text-transform: capitalize; display: block; }

.user-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 185px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(23,47,45,.1);
  z-index: 200;
  overflow: hidden;
}
.user-dropdown.open { display: block; }

.user-dropdown a,
.user-dropdown button {
  display: block;
  width: 100%;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--ink);
  text-decoration: none;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background .12s;
}
.user-dropdown a:hover,
.user-dropdown button:hover { background: var(--paper); }

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

.user-dropdown .sign-out-btn { color: #7a2a2a; }

/* ── Page content ─────────────────────────────────────────── */
.app-main {
  flex: 1;
  padding: 36px 40px;
}

/* ── Placeholder screens ──────────────────────────────────── */
.placeholder-page { max-width: 600px; }

.placeholder-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f5edcf;
  color: #73561b;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 22px;
}

.placeholder-title {
  font-size: clamp(28px, 3vw, 44px);
  font-weight: 500;
  letter-spacing: -0.04em;
  color: var(--ink);
  margin-bottom: 14px;
  line-height: 1.1;
}

.placeholder-desc {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.75;
  max-width: 520px;
  margin: 0;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sb-width) !important; /* never icon-only on mobile */
    transition: transform .25s ease;
  }

  .sidebar.mobile-open { transform: translateX(0); }

  .app-content {
    margin-left: 0 !important;
  }

  .app-main { padding: 24px 20px; }
}

@media (max-width: 575px) {
  .header-search { display: none; }
  .btn-new-request .btn-label { display: none; }
  .user-info { display: none; }
  .app-main { padding: 20px 16px; }
}
