/* ============================================================
   base.css — Structural layout styles
   Derived from the Armoredillo app.css brand shell.
   All colors reference CSS variables defined in hub.css.
   ============================================================ */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: 'Inter', Helvetica, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg) 200px);
  min-height: 100vh;
}

a, button, input, select, textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

/* ─── Accessibility ──────────────────────────────────────────── */
.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  text-decoration: none;
  z-index: 1000;
  font-size: 14px;
}

.skip-link:focus {
  top: 16px;
}

/* ─── Layout Shell ───────────────────────────────────────────── */
.layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Topbar ─────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  color: var(--topbar-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--content-padding);
  border-bottom: 1px solid var(--topbar-border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  /* Constrained to topbar height so SVG logo never overflows */
  max-height: 36px;
  width: auto;
  object-fit: contain;
  display: block;
}

.app-version {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.65;
  letter-spacing: 0.5px;
  color: var(--topbar-text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-username {
  font-size: 0.82rem;
  color: var(--text);
  margin-right: 6px;
}

.icon-btn {
  background: transparent;
  border: none;
  border-radius: 6px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--topbar-text);
  font-size: 16px;
  transition: background 0.15s ease;
  padding: 0;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.icon-btn svg {
  display: block;
}

/*.menu-toggle-btn {
  margin-right: 4px;
}*/

.menu-toggle-icon {
  width: 18px;
  height: 18px;
  display: block;
}

.icon-btn#notificationBtn {
  position: relative;
}

.icon-btn.has-unread {
  background: rgba(255, 255, 255, 0.16);
}

.notif-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
}

/* ─── Main Wrapper ───────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  min-height: calc(100vh - var(--topbar-height));
}

/* ─── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

.side-block {
  background: transparent;
  border: none;
  padding: 18px 24px;
  font-weight: 700;
  font-size: 13px;
  color: var(--sidebar-text);
  text-decoration: none;
  text-align: left;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  transition: background 0.15s ease, color 0.15s ease;
  border-right: 3px solid transparent;
}

.side-label {
  white-space: nowrap;
}

.side-icon-wrap {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.side-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display: none;
}

[data-theme="light"] .side-icon-light {
  display: inline-block;
}

[data-theme="dark"] .side-icon-light {
  display: none;
}

[data-theme="dark"] .side-icon-dark {
  display: inline-block;
}

[data-theme="light"] .side-icon-dark {
  display: none;
}

.side-block:hover {
  background: var(--sidebar-hover);
}

.side-block.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  border-right-color: var(--primary);
}

.side-subnav {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 0 0 4px 12px;
}

.side-subnav.is-open {
  display: flex;
}

.side-block.sub {
  padding: 10px 24px;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.3px;
}

.sidebar.collapsed {
  width: 72px;
  overflow-x: hidden;
}

.sidebar.collapsed .side-label {
  display: none;
}

.sidebar.collapsed .side-block {
  justify-content: center;
  padding-left: 10px;
  padding-right: 10px;
}

.sidebar.collapsed .side-subnav {
  display: none !important;
}

/* ─── Content Area ───────────────────────────────────────────── */
.content {
  flex: 1;
  padding: var(--content-padding);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
}

/* ─── Page Title ─────────────────────────────────────────────── */
.page-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: var(--topbar-text);
  margin: 4px 0;
}

/* Keep the topbar brand title pure white in all themes */
.topbar-left .page-title {
  color: #ffffff !important;
}

/* ─── Content Card ───────────────────────────────────────────── */
.content-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-soft);
}

.btn-light {
  background: var(--surface-soft);
  border-color: var(--border);
  color: var(--text);
}

.btn-light:hover {
  background: var(--surface-accent);
}

.btn-view {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
}

.btn-view:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-escalate {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-escalate:hover {
  opacity: 0.88;
}

/* ─── Table ──────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
}

.table-wrap--scrollable {
  overflow-y: auto;
  max-height: calc(100vh - 340px);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 680px;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  z-index: 1;
}

.data-table tbody tr {
  transition: background 0.1s ease;
}

.data-table tbody tr:hover {
  background: var(--surface-accent);
}

.data-table tbody tr.is-selected {
  background: var(--primary-soft) !important;
}

.align-right {
  text-align: right;
}

/* ─── Modal ──────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal.is-open {
  display: flex;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.modal-panel {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: min(900px, 96vw);
  padding: 18px 20px 20px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  z-index: 1;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  color: var(--muted);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
}

.modal-close:hover {
  background: var(--surface-soft);
}

/* ─── Toast ──────────────────────────────────────────────────── */
.app-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--text);
  color: var(--surface);
  padding: 10px 16px;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1200;
  font-size: 13px;
  font-weight: 500;
  pointer-events: none;
}

.app-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ─── Hidden utility ─────────────────────────────────────────── */
[hidden] {
  display: none !important;
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1366px) {
  .logo {
    max-height: 32px;
    width: auto;
    height: 54px;
  }

  .sidebar {
    width: 190px;
  }

  .side-block {
    padding: 14px 18px;
    font-size: 12px;
  }

  .page-title {
    font-size: 20px;
  }
}

@media (max-width: 1080px) {
  .sidebar {
    width: 170px;
  }

  .side-block {
    padding: 13px 16px;
  }
}

@media (max-width: 768px) {
  .main {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-top: 0;
    gap: 0;
  }

  .side-block {
    flex: 1 1 100px;
    padding: 10px 8px;
    font-size: 11px;
    text-align: center;
    border-right: none;
    border-bottom: 3px solid transparent;
  }

  .side-block.active {
    border-right: none;
    border-bottom-color: var(--primary);
  }

  .content {
    padding: 14px;
    gap: 12px;
  }
}
