/* ============================================================================
   App-specific styles. Layered on top of AdminLTE 4 + Bootstrap 5.
   Keep this file small — prefer Bootstrap utility classes in templates.
   ============================================================================ */

:root {
  --app-font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

body, html { font-family: var(--app-font); }

/* ── Avatar circle in navbar ─────────────────────────────────────────── */
.avatar-circle {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bs-primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
}

/* ── Flash message stack ─────────────────────────────────────────────── */
.flash-stack { margin-bottom: 1rem; }
.flash-stack .alert { margin-bottom: 0.5rem; }

/* ── Disabled sidebar links (route not wired yet) ───────────────────── */
.sidebar-menu .disabled-link {
  opacity: 0.55;
  cursor: not-allowed;
}
.sidebar-menu .disabled-link:hover { background: transparent; }

/* ── Stat cards on dashboard ─────────────────────────────────────────── */
.stat-card {
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  padding: 1.25rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.08);
}
.stat-icon {
  width: 56px; height: 56px;
  border-radius: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}
.stat-label {
  font-size: 0.8rem;
  color: var(--bs-secondary-color);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
}

/* ── Login page polish ───────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bs-primary-bg-subtle) 0%, var(--bs-body-tertiary-bg) 100%);
}
.login-box { width: 100%; max-width: 420px; padding: 1rem; }

/* ── Card header tweak ───────────────────────────────────────────────── */
.card-header .card-title { font-size: 1rem; font-weight: 600; }

/* ── Sidebar brand ───────────────────────────────────────────────────── */

/* AdminLTE 4 clips .sidebar-brand to a toolbar-height row by default.
   Override so our logo block can take its natural height. */
.sidebar-brand {
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: visible !important;
  padding: 1rem 0.75rem 0.75rem !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand .brand-link {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: inherit;
  gap: 0.65rem;
  height: auto !important;
  padding: 0 !important;
}
.sidebar-brand .brand-link:hover {
  color: inherit;
}

/* Big square company logo. `object-fit: contain` shows the whole image
   inside the 200x200 box — never cropped. */
.sidebar-brand .company-logo-big {
  width: 200px;
  height: 200px;
  max-width: 100%;
  max-height: none;
  object-fit: contain;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.5rem;
  display: block;
}

/* Text fallback shown if the logo file is missing — same footprint so
   the layout doesn't jump when you drop the PNG in. */
.sidebar-brand .company-logo-fallback {
  width: 200px;
  height: 200px;
  max-width: 100%;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.2;
}

.sidebar-brand .brand-text {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
  color: rgba(255, 255, 255, 0.95);
}

/* ── Tables ──────────────────────────────────────────────────────────── */
.table thead th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bs-secondary-color);
  border-bottom-width: 2px;
}

/* ── DataTables tweaks ───────────────────────────────────────────────── */
table.dataTable {
  border-collapse: separate !important;
  border-spacing: 0;
}
table.dataTable thead th {
  background: var(--bs-tertiary-bg);
  vertical-align: middle;
}
table.dataTable tbody tr:hover {
  background-color: var(--bs-tertiary-bg);
}
.dataTables_wrapper .dataTables_filter input,
div.dt-search input {
  border-radius: 0.375rem;
  border: 1px solid var(--bs-border-color);
  padding: 0.375rem 0.75rem;
}
.dt-paging .page-link { font-size: 0.875rem; }
.dt-info { color: var(--bs-secondary-color); font-size: 0.85rem; }

/* Action button group inside table cells */
.table .action-btns {
  display: inline-flex;
  gap: 0.25rem;
}
.table .action-btns .btn {
  padding: 0.2rem 0.5rem;
  font-size: 0.85rem;
}

/* ── Modal form errors ───────────────────────────────────────────────── */
.modal .invalid-feedback {
  display: none;
  font-size: 0.8rem;
}
.modal .invalid-feedback:not(:empty) { display: block; }
.modal .form-label { font-weight: 500; font-size: 0.9rem; }

/* ── Scrollable modals ───────────────────────────────────────────────── */
/* Cap modal-body to 60% viewport so the body scrolls and header/footer
   stay visible. AdminLTE 4 + Bootstrap 5's default `modal-dialog-scrollable`
   doesn't always engage cleanly inside the AdminLTE app shell, so we
   force the cap here. */
.modal-body {
  max-height: 60vh !important;
  overflow-y: auto !important;
}

/* ── Permissions grid in role modal ──────────────────────────────────── */
.perm-module-card {
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  background: var(--bs-body-bg);
}
.perm-module-card h6 {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.8rem;
  color: var(--bs-secondary-color);
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.25rem 1rem;
}
.perm-grid .form-check { margin: 0; }

/* ── Page header ─────────────────────────────────────────────────────── */
.page-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ── Select2 + Bootstrap 5 height match ──────────────────────────────── */
.select2-container--bootstrap-5 .select2-selection {
  min-height: 38px;
}


/* ── Sidebar: scrollable nav ──────────────────────────────────────────
   AdminLTE's .sidebar-wrapper holds the nav. On dense menus or shorter
   viewports it overflows the sidebar height — let the wrapper scroll
   internally so the brand stays pinned and only the menu list scrolls. */
.app-sidebar {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;          /* prevent the whole sidebar from scrolling */
}

.app-sidebar .sidebar-brand {
  flex-shrink: 0;            /* logo stays pinned at the top */
}

.app-sidebar .sidebar-wrapper {
  flex: 1 1 auto;
  min-height: 0;             /* critical: lets the child overflow inside flex */
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;     /* slim scrollbar on Firefox */
}

/* Slim, low-contrast scrollbar on WebKit so it doesn't fight the sidebar */
.app-sidebar .sidebar-wrapper::-webkit-scrollbar {
  width: 6px;
}
.app-sidebar .sidebar-wrapper::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}
.app-sidebar .sidebar-wrapper::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}
.app-sidebar .sidebar-wrapper::-webkit-scrollbar-track {
  background: transparent;
}