/* ==========================================================================
   Custom component layer — loaded AFTER the Tailwind CDN script on every
   page. Tailwind itself (https://cdn.tailwindcss.com, no Node/npm/build
   step) now generates every utility class (flex, gap-4, text-sm, bg-white,
   rounded-lg, border, spacing, etc.) directly from class="..." usage in the
   HTML. This file only defines the small set of reusable named components
   Tailwind doesn't provide out of the box: buttons, badges, modals, the
   sidebar/topbar shell, tabs, toasts. Dark mode for these follows the same
   [data-theme="dark"] attribute the rest of the app already uses (see
   assets/js/theme.js), configured as Tailwind's dark-mode selector too so
   `dark:` utility variants also work if used directly in markup.
   ========================================================================== */

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
:focus-visible { outline: 2px solid #2f3e9e; outline-offset: 1px; }

/* Typography scale used for consistent page/section/card headings */
.text-page-title { font-size: 1.375rem; font-weight: 600; letter-spacing: -0.01em; color: #16171f; }
.text-section-title { font-size: 1rem; font-weight: 600; color: #16171f; }
.text-card-title { font-size: 0.875rem; font-weight: 600; color: #16171f; }
.text-label { font-size: 0.75rem; font-weight: 500; color: #4d5061; }
.text-helper { font-size: 0.75rem; color: #6b6f80; }
.text-metadata { font-size: 0.7rem; color: #9497a6; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgb(15 23 42 / 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 60; padding: 1rem;
}
.modal-box {
  background: #fff; border-radius: 0.625rem; max-width: 30rem; width: 100%;
  max-height: 90vh; overflow-y: auto; padding: 1.5rem;
  box-shadow: 0 12px 32px -8px rgb(15 23 42 / 0.18);
}

/* Badges — consistent, subtle status colors reused everywhere */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 9999px;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.01em; line-height: 1.4;
}
.badge-success { background: #d3f0e0; color: #0e7a4e; }
.badge-warning { background: #faecc4; color: #92650c; }
.badge-danger  { background: #f9d9de; color: #a12a48; }
.badge-info    { background: #dde1f7; color: #2f3e9e; }
.badge-neutral { background: #eef0f4; color: #4d5061; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; background: #eef1fb; color: #2f3e9e;
  font-size: 0.7rem; padding: 2px 8px; border-radius: 9999px; margin: 2px;
}

/* Button hierarchy: primary / secondary / tertiary / danger */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: #2f3e9e; color: #fff; font-size: 0.8125rem; font-weight: 500;
  border-radius: 0.375rem; padding: 0.5rem 1rem; border: none; transition: background-color 0.12s ease;
}
.btn-primary:hover { background: #262f7c; }
.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: #f6f7f9; color: #363948; font-size: 0.8125rem; font-weight: 500;
  border-radius: 0.375rem; padding: 0.5rem 1rem; border: 1px solid #e5e7ec; transition: background-color 0.12s ease;
}
.btn-secondary:hover { background: #eef0f4; }
.btn-tertiary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: transparent; color: #2f3e9e; font-size: 0.8125rem; font-weight: 500;
  border-radius: 0.375rem; padding: 0.5rem 0.75rem; border: none; transition: background-color 0.12s ease;
}
.btn-tertiary:hover { background: #eef1fb; }
.btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: #fdf1f2; color: #a12a48; font-size: 0.8125rem; font-weight: 500;
  border-radius: 0.375rem; padding: 0.5rem 1rem; border: 1px solid #f4b8c4; transition: background-color 0.12s ease;
}
.btn-danger:hover { background: #f9d9de; }

/* Tables */
.data-table thead { background: #f6f7f9; }
.data-table th {
  text-align: left; font-size: 0.7rem; font-weight: 600; color: #6b6f80;
  text-transform: uppercase; letter-spacing: 0.04em; padding: 0.6rem 1rem;
}
.data-table td { padding: 0.65rem 1rem; border-top: 1px solid #eef0f4; font-size: 0.8125rem; }
.data-table tbody tr:hover { background: #fafbfc; }

.empty-state { text-align: center; padding: 3rem 1.5rem; color: #9497a6; font-size: 0.8125rem; }

/* Toasts */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 100;
  padding: 0.75rem 1.1rem; border-radius: 0.5rem; font-size: 0.8125rem; font-weight: 500;
  color: #fff; box-shadow: 0 8px 24px -6px rgb(15 23 42 / 0.25);
  display: flex; align-items: center; gap: 8px;
  animation: toast-in 0.18s ease-out;
}
.toast-success { background: #0e7a4e; }
.toast-error { background: #c53254; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* Tabs */
.tab-bar { display: flex; gap: 0.25rem; border-bottom: 1px solid #e5e7ec; margin-bottom: 1.25rem; }
.tab-btn {
  padding: 0.55rem 0.9rem; font-size: 0.8125rem; font-weight: 500; color: #6b6f80;
  border: none; background: transparent; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-btn:hover { color: #16171f; }
.tab-btn.active { color: #2f3e9e; border-bottom-color: #2f3e9e; }
.tab-panel.hidden { display: none; }

/* Application shell — sidebar + topbar. Sidebar is fixed-position so no page
   markup needs changing; body.app-content-offset (added once via the shared
   nav include) shifts content right on desktop; sidebar becomes an
   off-canvas drawer on smaller screens. */
.app-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 232px;
  background: #ffffff; border-right: 1px solid #e5e7ec;
  display: flex; flex-direction: column; z-index: 40;
  transition: transform 0.18s ease;
}
.app-sidebar-brand {
  display: flex; align-items: center; gap: 10px; padding: 1.1rem 1.1rem 0.9rem;
  border-bottom: 1px solid #eef0f4; margin-bottom: 0.5rem;
}
.app-sidebar-mark {
  width: 30px; height: 30px; border-radius: 7px; background: #2f3e9e; color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; flex-shrink: 0;
}
.app-sidebar-nav { flex: 1; overflow-y: auto; padding: 0.25rem 0.6rem; }
.app-nav-link {
  display: flex; align-items: center; gap: 10px; padding: 0.5rem 0.7rem; margin-bottom: 2px;
  border-radius: 0.375rem; font-size: 0.8125rem; font-weight: 500; color: #4d5061;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.app-nav-link:hover { background: #f6f7f9; color: #16171f; }
.app-nav-link.active { background: #eef1fb; color: #2f3e9e; }
.app-sidebar-footer { padding: 0.75rem 1.1rem; border-top: 1px solid #eef0f4; font-size: 0.75rem; color: #6b6f80; }

.app-topbar {
  position: sticky; top: 0; z-index: 30;
  background: #ffffff; border-bottom: 1px solid #e5e7ec;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.5rem; gap: 0.75rem;
}
.app-topbar > div:first-child { min-width: 0; flex-shrink: 1; overflow: hidden; }
.app-topbar > div:first-child span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.app-topbar > div:last-child { flex-shrink: 0; }
.app-main { padding: 1.75rem; max-width: 80rem; }
.sidebar-toggle-btn {
  display: none; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 0.375rem; border: 1px solid #e5e7ec; background: #fff;
}

@media (min-width: 1024px) {
  body.app-content-offset { margin-left: 232px; }
}
@media (max-width: 1023px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgb(15 23 42 / 0.15); }
  .sidebar-toggle-btn { display: inline-flex; }
  .app-sidebar-backdrop { position: fixed; inset: 0; background: rgb(15 23 42 / 0.4); z-index: 39; }
}

.theme-toggle-btn {
  display: inline-flex; align-items: center; gap: 4px; font-size: 0.75rem;
  padding: 4px 10px; border-radius: 0.375rem; border: 1px solid #e5e7ec; cursor: pointer;
  background: transparent; color: inherit;
}

/* ==========================================================================
   DARK MODE — for this custom component layer only. Tailwind's own
   generated utilities (bg-white, text-slate-900, etc.) get dark-mode
   coverage through Tailwind's `dark:` variant if/when used in markup;
   the config below tells Tailwind to key that variant off the same
   [data-theme="dark"] attribute assets/js/theme.js already toggles.
   ========================================================================== */
[data-theme="dark"] { color-scheme: dark; }
[data-theme="dark"] body { background-color: #12131a; color: #e5e7ec; }
[data-theme="dark"] .modal-box { background: #1b1d27; }
[data-theme="dark"] .data-table thead { background: #1b1d27; }
[data-theme="dark"] .data-table tbody tr:hover { background: #22242f; }
[data-theme="dark"] .data-table td { border-color: #2a2c38; }
[data-theme="dark"] .btn-secondary { background: #22242f; color: #d7d9e0; border-color: #3a3d4d; }
[data-theme="dark"] .btn-secondary:hover { background: #2a2c38; }
[data-theme="dark"] .btn-tertiary:hover { background: #24285c; }
[data-theme="dark"] .btn-danger { background: #3d1420; border-color: #5c1c2b; }
[data-theme="dark"] .btn-danger:hover { background: #5c1c2b; }
[data-theme="dark"] .badge-success { background: #10553a; color: #6fdba8; }
[data-theme="dark"] .badge-warning { background: #5c3f0d; color: #f5c96b; }
[data-theme="dark"] .badge-danger { background: #5c1c33; color: #f094a8; }
[data-theme="dark"] .badge-info { background: #2e3470; color: #a9b3e8; }
[data-theme="dark"] .badge-neutral { background: #2a2c38; color: #c7cad3; }
[data-theme="dark"] .app-sidebar { background: #1b1d27; border-color: #2a2c38; }
[data-theme="dark"] .app-sidebar-brand { border-color: #2a2c38; }
[data-theme="dark"] .app-sidebar-footer { border-color: #2a2c38; color: #9497a6; }
[data-theme="dark"] .app-nav-link { color: #c7cad3; }
[data-theme="dark"] .app-nav-link:hover { background: #22242f; color: #f1f2f5; }
[data-theme="dark"] .app-nav-link.active { background: #24285c; color: #a9b3e8; }
[data-theme="dark"] .app-topbar { background: #1b1d27; border-color: #2a2c38; }
[data-theme="dark"] .sidebar-toggle-btn { background: #1b1d27; border-color: #2a2c38; }
[data-theme="dark"] .theme-toggle-btn { border-color: #3a3d4d; }
[data-theme="dark"] .tab-bar { border-color: #2a2c38; }
[data-theme="dark"] .tab-btn { color: #9497a6; }
[data-theme="dark"] .tab-btn:hover { color: #f1f2f5; }
[data-theme="dark"] .tab-btn.active { color: #a9b3e8; border-bottom-color: #a9b3e8; }
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea {
  background-color: #1b1d27; color: #f1f2f5; border-color: #3a3d4d;
}

/* Every existing bg-*/text-*/border-* utility class used throughout the app's
   PHP pages (bg-white, bg-slate-50, text-slate-900, border-slate-200, etc.)
   is now generated live by Tailwind from the class="..." attributes already
   in the markup — no separate definition needed here. Dark-mode coverage for
   those specific utilities (as opposed to the custom components above) is a
   follow-up item: it would mean adding `dark:` variants to the class lists
   throughout the 25 page files, which is a larger, separate pass.
*/
