/*
  Pacerts — minimalist light theme (2026 refresh)

  Goals:
  - Keep ALL existing functionality intact (PHP + DB + endpoints unchanged)
  - Modern, clean UI with accessible spacing + focus styles
  - Mobile-first + responsive tables (no horizontal scrolling where possible)

  Image guidance:
  - Nav logo (img/logo2.jpg): use a wide logo (recommended ~240×80px or larger).
    The CSS renders it at ~34px tall in the sticky nav bar.
  - Icons (tick/cross/email): recommended 32×32px or larger; CSS scales to 18–20px.
*/

/* -------------------- Design tokens -------------------- */
:root{
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #fbfcfe;
  --text: #0f172a;
  --muted: #667085;
  --border: rgba(15, 23, 42, 0.12);
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);

  /* Brand accent (subtle red) */
  --accent: #b91c1c;
  --accent-2: #ef4444;

  --success: #16a34a;
  --warning: #d97706;
  --danger: #b91c1c;

  --radius: 14px;
  --radius-sm: 10px;
  --container: 1200px;

  --focus-ring: 0 0 0 3px rgba(239, 68, 68, 0.25);
}

html{
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
}

*{ box-sizing: border-box; }

body.pc-body{
  margin: 0;
  font-family: Roboto, system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

/* Accessible skip link */
.pc-skip{
  position: absolute;
  left: -999px;
  top: -999px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  color: var(--text);
  z-index: 10000;
}
.pc-skip:focus{
  left: 12px;
  top: 12px;
}

/* Links */
a{
  color: var(--accent);
  text-decoration: none;
}
a:hover{ text-decoration: underline; }

/* Headings */
h1, h2, h3{
  margin: 0 0 12px 0;
  line-height: 1.2;
}
h2{ font-size: 22px; }
h3{ font-size: 18px; }

/* Layout */
.pc-page{
  padding: 22px 14px 38px;
}

.pc-container{
  width: min(var(--container), 100%);
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

@media (min-width: 900px){
  .pc-container{ padding: 26px; }
}

/* Utility classes */
.text-center{ text-align: center; }
.mt-20{ margin-top: 20px; }
.mb-20{ margin-bottom: 20px; }
.pc-muted{ color: var(--muted); }

/* Simple responsive grid (two columns on desktop) */
.pc-grid-2{ display: grid; gap: 14px; }
@media (min-width: 900px){ .pc-grid-2{ grid-template-columns: 1fr 1fr; } }

/* Width helpers for centering cards/forms */
.pc-limit-700{ max-width: 700px; margin-left: auto; margin-right: auto; }
.pc-limit-900{ max-width: 900px; margin-left: auto; margin-right: auto; }
.pc-limit-1100{ max-width: 1100px; margin-left: auto; margin-right: auto; }

/* -------------------- Flash messages -------------------- */
.flash-wrap{
  max-width: 900px;
  margin: 0 auto 16px auto;
}
.flash{
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 14px;
}
.flash + .flash{ margin-top: 10px; }

.flash-success{ border-color: rgba(22,163,74,.35); background: rgba(22,163,74,.08); }
.flash-warning{ border-color: rgba(217,119,6,.35); background: rgba(217,119,6,.10); }
.flash-error{ border-color: rgba(185,28,28,.35); background: rgba(185,28,28,.08); }
.flash-info{ border-color: var(--border); }

/* -------------------- Buttons -------------------- */
.button,
button.button{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(185,28,28,.25);

  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  transition: transform .06s ease, filter .12s ease;
  width: auto; /* override legacy fixed widths */
}

.button:hover{
  text-decoration: none;
  filter: brightness(0.97);
}
.button:active{ transform: translateY(1px); }

.button:focus-visible{
  outline: none;
  box-shadow: var(--focus-ring);
}

.button.button--secondary{
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.button.button--secondary:hover{
  background: rgba(15,23,42,.04);
}

.button.button--ghost{
  background: transparent;
  border-color: transparent;
  color: var(--accent);
}
.button.button--ghost:hover{
  background: rgba(185,28,28,.08);
}

.button.button--danger{
  background: var(--danger);
  border-color: rgba(185,28,28,.25);
}

.button[disabled],
button[disabled]{
  opacity: .6;
  cursor: not-allowed;
}

/* Icon buttons (email/ticks) */
.pc-icon{
  width: 18px;
  height: 18px;
  vertical-align: middle;
}

/* -------------------- Form controls -------------------- */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="file"],
select,
textarea,
.TField,
.inputform{
  width: 100%;
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 14px;
}

textarea{ min-height: 120px; resize: vertical; }

input[type="checkbox"],
input[type="radio"]{
  accent-color: var(--accent);
}

input:focus,
select:focus,
textarea:focus{
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: rgba(239, 68, 68, 0.45);
}

label{ font-weight: 600; }

.pc-form{
  display: grid;
  gap: 14px;
  max-width: 820px;
  margin: 0 auto;
}

.pc-field{
  display: grid;
  gap: 6px;
}

.pc-help{
  font-size: 12px;
  color: var(--muted);
}

.pc-actions{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.pc-card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

@media (min-width: 900px){
  .pc-card{ padding: 18px; }
}

/* -------------------- Tables -------------------- */
.pc-table-wrap{
  width: 100%;
  overflow: auto; /* fallback for very wide tables */
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* Forms inside tables should not add extra spacing */
.pc-table-wrap form{ margin: 0; }

table{
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
}

th, td{
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

thead th{
  background: var(--surface-2);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

tbody tr:hover td{
  background: rgba(15,23,42,.02);
}

tbody tr:last-child td{
  border-bottom: 0;
}

td.text-center, th.text-center{ text-align: center; }

/* Apply the modern table look to legacy class names too */
.lookup_table{
  border: 0;
}

/* Responsive "card" table pattern (mobile) */
@media (max-width: 740px){
  .pc-table--responsive thead{
    display: none;
  }

  .pc-table--responsive,
  .pc-table--responsive tbody,
  .pc-table--responsive tr,
  .pc-table--responsive td{
    display: block;
    width: 100%;
  }

  .pc-table--responsive tr{
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
  }

  .pc-table--responsive td{
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 8px 14px;
    border: 0;
  }

  .pc-table--responsive td::before{
    content: attr(data-label);
    font-weight: 700;
    color: var(--muted);
    text-transform: none;
    letter-spacing: normal;
  }

  .pc-table--responsive td:last-child{
    padding-bottom: 12px;
  }

  /* Ensure inputs/buttons stay usable in the responsive stacked layout */
  .pc-table--responsive td > input,
  .pc-table--responsive td > select,
  .pc-table--responsive td > textarea,
  .pc-table--responsive td > form{
    flex: 1;
    min-width: 180px;
  }
}

/* -------------------- Auth screens (login/logout) -------------------- */
.pc-auth{
  max-width: 520px;
  margin: 0 auto;
}

.pc-auth__logo{
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}

.pc-auth__logo img{
  width: min(260px, 100%);
  height: auto;
  /*border-radius: 5px;*/
  /*padding:2px;
 border: 1px solid var(--border);*/
}

.pc-auth__title{
  text-align: center;
  margin-bottom: 6px;
}

.pc-auth__subtitle{
  text-align: center;
  color: var(--muted);
  margin-bottom: 16px;
}

/* -------------------- Modal -------------------- */
.pc-modal{
  position: fixed;
  inset: 0;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 14px 14px;
  background: rgba(15, 23, 42, 0.45);
  z-index: 9999;
}

.pc-modal.is-open{ display: flex; }

.pc-modal__panel{
  width: min(520px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.pc-modal__title{
  margin: 0 0 10px 0;
}

.pc-modal__meta{
  color: var(--muted);
  margin-bottom: 12px;
  font-size: 13px;
}

.pc-modal__status{
  font-size: 12px;
  color: var(--muted);
}

.pc-modal__result{
  margin-top: 10px;
  font-size: 13px;
}

/* -------------------- Nav (sticky, responsive) -------------------- */
.pc-nav{
  position: sticky;
  top: 0;
  z-index: 999;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.pc-nav__bar{
  max-width: min(var(--container), 100%);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  position: relative;
}

.pc-nav__brand{
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
  color: var(--text);
}

.pc-nav__brand img{
  height: 34px;
  width: auto;
  /*border-radius: 10px;/*
  /*border: 1px solid var(--border);*/
  background: #fff;
}

.pc-nav__right{
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.pc-nav__badge{
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15,23,42,.04);
  border: 1px solid rgba(15,23,42,.08);
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pc-nav__toggle{
  border: 1px solid var(--border);
  background: rgba(15,23,42,.04);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  line-height: 1;
  font-size: 16px;
}

.pc-nav__toggle:focus-visible{
  outline: none;
  box-shadow: var(--focus-ring);
}

.pc-nav__menu{
  display: none;            /* mobile default */
  position: absolute;       /* mobile dropdown */
  left: 0;
  right: 0;
  top: 100%;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 14px 14px;
}

.pc-nav.is-open .pc-nav__menu{ display: block; }

.pc-nav__links{
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.pc-nav__link{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  background: rgba(15,23,42,.03);
  border: 1px solid rgba(15,23,42,.06);
  font-weight: 700;
  font-size: 14px;
}

.pc-nav__link:hover{
  background: rgba(15,23,42,.06);
  border-color: rgba(15,23,42,.10);
  text-decoration: none;
}

.pc-nav__link[aria-current="page"],
.pc-nav__link.is-active{
  background: rgba(15,23,42,.10);
  border-color: rgba(15,23,42,.16);
}

@media (min-width: 900px){
  .pc-nav__toggle{ display: none; }

  .pc-nav__menu{
    display: block !important;
    position: static;
    border: 0;
    padding: 0;
    background: transparent;
    flex: 1;
  }

  .pc-nav__links{
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
  }

  .pc-nav__link{
    padding: 9px 12px;
    background: transparent;
    border-color: transparent;
  }

  .pc-nav__link:hover{
    background: rgba(15,23,42,.05);
    border-color: rgba(15,23,42,.06);
  }

  .pc-nav__link[aria-current="page"],
  .pc-nav__link.is-active{
    background: rgba(15,23,42,.07);
    border-color: rgba(15,23,42,.10);
  }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce){
  *{ scroll-behavior: auto !important; transition: none !important; }
}

tbody tr:nth-child(even) {
  background-color: #f2f2f2;
}

tbody tr:nth-child(odd) {
  background-color: #ffffff;
}