/* ==========================================================
   NDRL Portal v2 – Light Admin Theme (Readable & Grouped)
   ========================================================== */

/* ----------------------------------------------------------
   Global Variables & Base Typography
   ---------------------------------------------------------- */
:root {
  --portal-red: #d71414;
  --portal-orange: #d47d0a;
  --portal-accent: #0052cc;
  --portal-bg: #f7f7f9;
  --portal-fg: #00000000;
  --portal-panel: #ffffff;
  --portal-border: #ddd;
  --portal-text: #222;
  --portal-fieldbg: #e0e0e333;
  --portal-muted: #666;
  --portal-highlight: #eef5ff;
  --portal-accent-card: color-mix(in srgb, var(--portal-accent, #6c43f3) 14%, transparent);
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --font-ui: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, "Helvetica Neue", Arial;
  --header-hieght: 45px;
  --header-offset: 75px;
  /* height of your sticky header/nav area */
  --field-gap-x: 16px;
  /* horizontal gap between fields */
  --field-gap-y: 14px;
  /* vertical gap between fields  */
  --field-min: 260px;
  /* min width before a field wraps */
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--portal-bg);
  color: var(--portal-text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.45;
}

/* ----------------------------------------------------------
   Header & Navigation
   ---------------------------------------------------------- */
header.site {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  height: var(--header-hieght);
  background: var(--portal-panel);
  border-bottom: 1px solid var(--portal-border);
  box-shadow: var(--shadow);
}

header.site .brand a {
  color: var(--portal-red);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.2em;
  letter-spacing: 0.5px;
}

.nav-toggle {
  display: none;
  font-size: 1.4rem;
  background: none;
  border: none;
  cursor: pointer;
}


nav.top {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

nav.top a {
  text-decoration: none;
  color: var(--portal-muted);
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
}

nav.top a.active,
nav.top a:hover {
  background: var(--portal-highlight);
  color: var(--portal-accent);
  font-weight: 600;
}

ul.clean {
  padding-left: 20px;
  margin: 0;
}


/* Container */
.drop-nav {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
  position: relative;
  z-index: 98;
}

/* Top-level menu blocks in a row */
.drop-nav .menu {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: stretch;
  vertical-align: top;
}

/* Main trigger (NOT a link) */
.drop-nav .menu>.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  cursor: pointer;
  white-space: nowrap;
}

/* Hover only highlights the button; does NOT open the menu */
.drop-nav .menu>.btn:hover {
  filter: brightness(0.97);
}

/* Active section button */
.drop-nav .menu>.btn.active {
  background: var(--portal-highlight);
  color: var(--portal-accent);
  font-weight: 600;
}

/* Dropdown panel */
.drop-nav .dropdown {
  position: absolute;
  left: 0;
  top: 100%;
  /* flush under button */
  transform: translateY(6px);
  /* visual spacing without hover gap */
  min-width: 220px;
  width: max-content;
  max-width: min(92vw, 340px);
  max-height: min(60vh, 480px);
  overflow: auto;
  padding: 6px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e4e4e7);
  border-radius: .75rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .08);
  display: none;
  z-index: 99;
}

/* Open state only on click */
.drop-nav .menu.open>.dropdown {
  display: block;
}

/* Submenu items: full width, easy to click */
.drop-nav .dropdown .btn {
  display: block;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  margin: 4px 0;
  padding: .4rem .6rem;
  font-size: .92rem;
  line-height: 1.25;
  white-space: normal;
  word-break: break-word;
}

/* Make sure nothing clips the dropdown */
.drop-nav,
.drop-nav .menu,
.container,
main,
.page {
  overflow: visible;
}

/* Optional: right-edge alignment if needed
   <div class="menu right-edge">...</div> */
.drop-nav .menu.right-edge>.dropdown {
  right: 0;
  left: auto;
}

/* (If your global .btn sets width:100%) keep top buttons inline */
.drop-nav .menu>.btn {
  width: auto;
}

.nav-mobile {
  display: none;
  position: fixed;
  top: var(--header-hieght);
  left: 0;
  right: 0;
  background: var(--portal-panel);
  border-bottom: 1px solid var(--portal-border);
  box-shadow: var(--shadow);
  z-index: 99;
  padding: 10px;
}

.nav-mobile.open {
  display: block;
}

.nav-mobile a {
  display: block;
  padding: 12px 14px;
  border-radius: var(--radius);
  color: var(--portal-text);
  text-decoration: none;
}

.nav-mobile a:hover,
.nav-mobile a.active {
  background: var(--portal-highlight);
  color: var(--portal-accent);
}

/* Badges grid*/
.cols-3-stack-2 {
  grid-template-columns: repeat(3, 1fr);
}

/* Mobile breakpoint */
@media (max-width: 900px) {
  nav.nav-desktop {
    display: none;
  }
  .nav-toggle {
    display: inline-flex;
    align-items: center;
  }
  .cols-3-stack-2 {
    grid-template-columns: repeat(2, 1fr);
  }
}


.btn {
  line-height: 1;
  /* or 1.2 depending on your design */
}

a.btn,
button.btn {
  display: inline-flex;
  align-items: center;
}



/* Color helpers (match your palette) */
.btn.red{
  border-color: var(--portal-red);
  color: var(--portal-red);
}
.btn.green{
  border-color: #09aa09 ;
  color: #09aa09;
}

.btn.orange,
.btn.yellow {
  /* allow either 'orange' or 'yellow' from PHP */
  border-color: var(--portal-orange);
  color: var(--portal-orange);
}

.btn.red:hover,
.btn.orange:hover,
.btn.yellow:hover {
  filter: brightness(0.95);
}



/* ----------------------------------------------------------
   Page Structure
   ---------------------------------------------------------- */
.container {
  box-sizing: border-box;
  /* include padding in total width */
  width: 100%;
  max-width: 1300px;
  margin: 0 auto;
  padding: 24px;
  overflow-x: visible !important;
  /* <-- this is the blocker */
  overflow-y: visible !important;
}

footer {
  margin-top: 40px;
  padding: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--portal-muted);
  background: var(--portal-panel);
  border-top: 1px solid var(--portal-border);
}

/* ----------------------------------------------------------
   Buttons
   ---------------------------------------------------------- */
.btn {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--portal-border);
  background: var(--portal-panel);
  color: var(--portal-text);
  border-radius: var(--radius);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
}

.btn:hover {
  background: var(--portal-highlight);
  border-color: var(--portal-accent);
}

.btn.red {
  border-color: var(--portal-red);
  color: var(--portal-red);
}

.btn.red:hover {
  background: #fff0f0;
}

.btn.orange {
  border-color: var(--portal-orange);
  color: var(--portal-orange);
}

.btn.orange:hover {
  background: #fff0f0;
}

/* ----------------------------------------------
   Quiet button (neutral, low-visibility)
   ---------------------------------------------- */
.btn.is-quiet {
  background: transparent;
  border-color: var(--muted, #475569);
  color: var(--muted, #94a3b8);
}

.btn.is-quiet:hover:not(.is-disabled) {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text);
}

/* ----------------------------------------------
   Primary blue button
   ---------------------------------------------- */
.btn.is-blue {
  background: var(--accent, #3b82f6);
  border-color: var(--accent, #3b82f6);
  color: #fff;
}

.btn.is-blue:hover:not(.is-disabled) {
  background: #60a5fa;
}

/* ----------------------------------------------
   Success / green
   ---------------------------------------------- */
.btn.is-green {
  background: var(--good, #10b981);
  border-color: var(--good, #10b981);
  color: #fff;
}

.btn.is-green:hover:not(.is-disabled) {
  background: #34d399;
}

/* ----------------------------------------------
   Danger / red
   ---------------------------------------------- */
.btn.is-red {
  background: var(--bad, #ef4444);
  border-color: var(--bad, #ef4444);
  color: #fff;
}

.btn.is-red:hover:not(.is-disabled) {
  background: #f87171;
}

/* ----------------------------------------------
   Warning / orange
   ---------------------------------------------- */
.btn.is-orange {
  background: var(--warn, #f59e0b);
  border-color: var(--warn, #f59e0b);
  color: #0f172a;
}

.btn.is-orange:hover:not(.is-disabled) {
  background: #fbbf24;
}

/* ----------------------------------------------
   Working (yellow pulse)
   ---------------------------------------------- */
.btn.is-working {
  background: #eab308;
  border-color: #eab308;
  color: #0f172a;
}

.btn.is-working:hover:not(.is-disabled) {
  background: #facc15;
}

/* ----------------------------------------------
   "Done" state (green outline, subtle)
   ---------------------------------------------- */
.btn.is-done {
  background: transparent;
  border-color: var(--good, #10b981);
  color: var(--good, #10b981);
}

.btn.is-done:hover:not(.is-disabled) {
  background: rgba(16, 185, 129, 0.15);
}

/* ----------------------------------------------
   Disabled
   ---------------------------------------------- */
.btn.is-disabled,
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}


/* Section navigation (button bars) */
.section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 20px;
}

.section-nav .btn.active {
  background: var(--portal-highlight);
  color: var(--portal-accent);
  font-weight: 600;
}

/* ----------------------------------------------------------
   Tables
   ---------------------------------------------------------- */

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--portal-panel);
  border: 1px solid var(--portal-border);
  box-shadow: var(--shadow);
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--portal-border);
}

table thead th {
  position: static;
  /* was: sticky */
  top: auto;
  /* was: 52px (or similar) */
  z-index: auto;
  /* was: >0 */
  background: #fafafa;
  /* keep your visual */
}

/* Zebra Striping */
tr:nth-child(even) td {
  background: #fcfcfc;
}

tr:hover td {
  background: #f1f5ff;
}

/* Vertical dividers */
.cell-div-left {
  border-left: 2px solid var(--portal-border-strong, #bbb);
}

.cell-div-right {
  border-right: 2px solid var(--portal-border-strong, #bbb);
}

/* Optional: lighter divider */
.cell-div-light {
  border-left: 1px dashed var(--portal-border);
}

/* Tighten divider alignment */
th.cell-div-left,
td.cell-div-left {
  padding-left: 14px;
}

th.cell-div-right,
td.cell-div-right {
  padding-right: 14px;
}

/* ---------- Table Legend ---------- */
.table-legend {
  margin: 8px 0 14px;
  padding: 8px 12px;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--muted-text, #666);
  background: #fafafa;
  border: 1px dashed var(--portal-border);
  border-radius: 6px;
}

.table-legend strong {
  color: #222;
  font-weight: 600;
}

.table-legend span {
  white-space: nowrap;
}

.table-legend .sep {
  margin: 0 6px;
  color: #aaa;
}



/* ===== Opt-in sticky table headers =====
   Usage options:
   1) <table class="data-table sticky-headers">
   2) <div class="table-wrap sticky-headers"><table class="data-table">...</table></div>

   You can control the offset with --sticky-top (defaults to 0).
   Example: <div class="sticky-headers" style="--sticky-top: 56px">...</div>
*/
.sticky-headers thead th {
  position: sticky;
  top: var(--sticky-top, 0);
  z-index: 6;
  /* above row cells, below modals */
  background: #fafafa;
  /* keep readable header */
  border-bottom: 1px solid var(--portal-border, #ccc);
  /* optional: small shadow to separate header on scroll */
  box-shadow: 0 1px 0 rgba(0, 0, 0, .06);
}


/* Compact table buttons */
table .btn {
  padding: 5px 10px;
  font-size: 13px;
  border-radius: 4px;
  background: var(--portal-highlight);
  border-color: var(--portal-border);
}

table .btn:hover {
  background: var(--portal-accent);
  color: #fff;
  border-color: var(--portal-accent);
}

table.rounded {
  border-collapse: separate;
  /* required for border-radius to show */
  border-spacing: 0;
  /* optional — removes spacing gaps */
  border: 1px solid var(--border, #e4e4e7);
  border-radius: 10px;
  /* adjust corner roundness */
  overflow: hidden;
  /* clips inner edges */
}


/* Inline table forms */
form.intable {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  margin: 0;
  display: inline;
}

/* Compact controls in table rows */
form.intable input,
form.intable select,
form.intable button {
  font-size: 13px;
  padding: 4px 8px;
  line-height: 1.2;
  border-radius: 4px;
}

/* Grouping border */
.group-box {
  border: 1px solid #ccc;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  background: #fafafa;
}

/* ----------------------------------------------------------
   Forms & Inputs
   ---------------------------------------------------------- */
form {
  background: var(--portal-panel);
  border: 1px solid var(--portal-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

form.intable {
  display: contents;
}

input[type=text],
input[type=email],
input[type=password],
input[type=tel],
input[type=date],
input[type=number],
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--portal-border);
  border-radius: var(--radius);
  background: var(--portal-fieldbg);
  color: var(--portal-text);
  font-family: var(--font-ui);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--portal-accent);
  box-shadow: 0 0 0 2px rgba(0, 82, 204, 0.1);
}

label {
  display: block;
  margin: 6px 0 3px;
  color: var(--portal-muted);
}

/* ----------------------------------------------------------
   Section Frame
   ---------------------------------------------------------- */

.section-frame {
  position: relative;
  border: 1.5px solid var(--portal-border);
  border-radius: 8px;
  padding: 18px 14px 14px;
  background: var(--portal-panel);
  margin: 14px 0;
}

/* Floating title */
.section-frame-title {
  position: absolute;
  top: -0.6em;
  left: 12px;
  padding: 0 8px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--portal-panel);
  color: var(--muted-text, #666);
}

/* Inner spacing safety */
.section-frame-body> :first-child {
  margin-top: 0;
}

/* ---------- Tooltip ---------- */
.section-frame-title.has-tip {
  cursor: help;
}

/* Tooltip bubble */
.section-tip {
  position: absolute;
  left: 0;
  top: 140%;
  min-width: 220px;
  max-width: 320px;

  padding: 10px 12px;
  font-size: 0.75rem;
  line-height: 1.4;

  background: #1f2937;
  /* dark neutral */
  color: #fff;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);

  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity .15s ease, transform .15s ease;

  z-index: 50;
}

/* Tooltip arrow */
.section-tip::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 14px;
  border-width: 0 6px 6px 6px;
  border-style: solid;
  border-color: transparent transparent #1f2937 transparent;
}

/* Show tooltip */
.section-frame-title.has-tip:hover .section-tip,
.section-frame-title.has-tip:focus-within .section-tip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}



/* ----------------------------------------------------------
   Grid System
   ---------------------------------------------------------- */
.grid {
  display: grid;
  gap: 10px;
}

.grid>.with-margin {
  margin: 10px;
}

.cols-1 {
  grid-template-columns: 1fr;
}

.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

.cols-5 {
  grid-template-columns: repeat(5, 1fr);
}

.cols-6 {
  grid-template-columns: repeat(6, 1fr);
}

.cols-7 {
  grid-template-columns: repeat(7, 1fr);
}

.cols-label-input {
  display: grid;
  grid-template-columns: 100px 1fr;
  align-items: center;
}

/* Drop-in form grid */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--field-min), 1fr));
  column-gap: var(--field-gap-x);
  row-gap: var(--field-gap-y);
}

/* Make fields behave nicely inside grid cells */
.form-grid>.field,
.section .row>div,
.cell {
  min-width: 0;
  /* prevents overflow/squish */
}

.field label {
  display: block;
  margin-bottom: 6px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  box-sizing: border-box;
}

/* ----------------------------------------------------------
   Cards, Sections, and Decorative Blocks
   ---------------------------------------------------------- */
.card {
  background: var(--portal-panel);
  border: 1px solid var(--portal-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  margin-bottom: 20px;
}

.card-header {
  align-items: center;
  text-align: center;
  height: 45px;
  font-size: 2rem;
  font-weight: 800;
  background: var(--portal-panel);
  border: 1px solid var(--portal-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 2px;
}

/* Dashboard Cards */
.dash-card {
  background: color-mix(in srgb, var(--portal-accent) 20%, transparent);
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .2);
  backdrop-filter: blur(4px);
  /* optional nice glass effect */
}

.kpis {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.kpi .label {
  font-size: 1rem;
  opacity: .75;
  margin-bottom: 6px;
}

.kpi .value {
  font-size: 1.6rem;
  font-weight: 700;
}

.kpi .data {
  font-size: 1rem;
}

/* Section wrappers */
.section-box {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e4e4e7);
  border-radius: 14px;
  padding: 10px;
  margin: 4px 0;
  scroll-margin-top: 80px;
}

/* Section titles (expand/collapse headers) */
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  color: var(--portal-muted);
  border-radius: var(--radius);
  font-size: 1.5rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.section-id {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.section-title:hover {
  background: var(--portal-highlight);
  color: var(--portal-accent);
  font-weight: 600;
}

/* Divider lines */
.divider {
  height: 1px;
  background: var(--border, #e4e4e7);
  margin: 14px 0;
}

/* ----------------------------------------------------------
   Alerts, Badges & Flash Messages
   ---------------------------------------------------------- */
.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.75rem;
  background: var(--badge-bg, #eef2ff);
  color: var(--badge-fg, #3730a3);
  border: 1px solid var(--badge-border, #e0e7ff);
}

.badge.ok {
  border-color: #16a34a33;
  background: #16a34a9e;
  color: #000000;
}

.badge.warn {
  border-color: #f59e0b33;
  background: #f59f0b94;
  color: #000000;
}

.badge.danger {
  border-color: #ef444433;
  background: #ef44449e;
  color: #000000;
}

.flash {
  margin: 10px 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--portal-border);
  background: #fff;
  box-shadow: var(--shadow);
}

.flash.info {
  border-left: 4px solid var(--portal-accent);
}

.flash.ok {
  border-left: 4px solid #21a366;
}

.flash.warn {
  border-left: 4px solid #fbbc05;
}

.flash.err {
  border-left: 4px solid var(--portal-red);
}

/* Floating “toast” style notifications */
/* Flash container: bottom-right corner, stacked vertically */
#flash-container {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}

.flash-message {
  min-width: 240px;
  padding: 10px 14px;
  border-radius: 6px;
  color: #fff;
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  opacity: 0.95;
  transform: translateX(150%);
  animation: slideInRight 0.4s ease-out forwards;
}

/* Color variants */
.flash-message.success {
  background: #21a366;
}

.flash-message.error {
  background: #d93025;
}

.flash-message.info {
  background: #2289ef;
}

.flash-message.db {
  background: #6c43f3;
}

/* Slide animations */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(150%);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }

  to {
    opacity: 0;
    transform: translateX(150%);
  }
}



/* ----------------------------------------------------------
   Sticky Elements & Context Strips
   ---------------------------------------------------------- */
.strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  background: color-mix(in srgb, var(--portal-accent) 60%, white);
  border: 1px solid var(--border, #e4e4e7);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 10px 0;
}

.sticky-top-compact {
  position: sticky;
  top: var(--header-offset);
  height: 80px;
  padding-bottom: 10px;
  z-index: 50;
}

.sticky-top {
  position: sticky;
  /* offest top to header hieght. */
  top: var(--header-offset);
  z-index: 50;
}

/* ----------------------------------------------------------
   Utility Classes
   ---------------------------------------------------------- */
hr {
  border: none;
  border-bottom: 1px solid var(--portal-border);
  margin: 24px 0;
}

.muted {
  color: var(--portal-muted);
}

.right {
  text-align: right;
}

.center {
  text-align: center;
}

.small {
  font-size: 0.9rem;
}