/* ============================================================================
 * app.css — Qualify Check project-specific styles.
 * Loaded LAST in base.html so these rules can override the Valantic CI defaults.
 * ============================================================================ */

/* --- Layout --- */

.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(16px, 2.5vw, 28px);
}


/* --- Header (polish #9): brand · nav cluster · user cluster --- */

/* Wordmark — keep on a single line, two-tone */

.logo {
  text-decoration: none;
  flex-shrink: 0;
}

.logo-text {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  font-family: "Maven Pro", sans-serif;
  font-weight: 700;
  font-size: 22px;
  line-height: 1;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.logo-text-primary { color: var(--Black, #100C2A); }
.logo-text-accent  { color: var(--Vibrant-Purple, #4B26B7); }


/* Nav cluster (primary navigation) */

.nav-cluster {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0 clamp(12px, 2vw, 24px);
  flex-wrap: wrap;
}

.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  color: var(--fg);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 6px;
  transition: background-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.nav-link:hover,
.nav-link:focus-visible {
  background: rgba(75, 38, 183, 0.08);
  color: var(--Vibrant-Purple, #4B26B7);
  outline: none;
}

.nav-link.is-active {
  color: var(--Vibrant-Purple, #4B26B7);
  background: rgba(75, 38, 183, 0.06);
}

.nav-link.is-active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 2px;
  height: 2px;
  background: var(--Vibrant-Purple, #4B26B7);
  border-radius: 2px;
}

.nav-divider {
  display: inline-block;
  width: 1px;
  height: 20px;
  background: var(--line);
  margin: 0 8px;
}


/* Submenu groups (native <details>/<summary> disclosure) */

.nav-group {
  position: relative;
}

.nav-group-toggle {
  cursor: pointer;
  list-style: none;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.nav-group-toggle::-webkit-details-marker { display: none; }

.nav-group-toggle::after {
  content: "▾";
  font-size: 9px;
  color: var(--muted);
  margin-left: 4px;
  transition: transform 0.15s ease;
}

.nav-group[open] > .nav-group-toggle::after { transform: rotate(180deg); }

.nav-group[open] > .nav-group-toggle {
  background: rgba(75, 38, 183, 0.08);
  color: var(--Vibrant-Purple, #4B26B7);
}

.nav-submenu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-sublink {
  display: block;
  padding: 9px 12px;
  color: var(--fg);
  text-decoration: none;
  font-size: 14px;
  border-radius: 4px;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-sublink:hover,
.nav-sublink:focus-visible {
  background: rgba(75, 38, 183, 0.08);
  color: var(--Vibrant-Purple, #4B26B7);
  outline: none;
}

.nav-sublink.is-active {
  background: rgba(75, 38, 183, 0.06);
  color: var(--Vibrant-Purple, #4B26B7);
  font-weight: 600;
}


/* Pending-count badge inside a nav-group toggle */

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--Coral-Red-Peach, #FF6A5C);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}


/* User cluster (language switcher + user menu) */

.user-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding-left: clamp(12px, 2vw, 20px);
  border-left: 1px solid var(--line);
}


/* User menu (native <details>/<summary>) */

.user-menu {
  position: relative;
}

.user-menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  list-style: none;
  font-weight: 500;
  font-size: 14px;
  transition: background-color 0.15s ease;
}

.user-menu-toggle::-webkit-details-marker { display: none; }

.user-menu-toggle::after {
  content: "▾";
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.user-menu[open] .user-menu-toggle::after { transform: rotate(180deg); }

.user-menu-toggle:hover { background: rgba(16, 12, 42, 0.05); }

.user-menu-name { color: var(--fg); }

.user-menu-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.4;
}

.user-menu-chip--employee      { background: #dbeafe; color: #2563eb; }
.user-menu-chip--qualify_admin { background: #fef3c7; color: #d97706; }
.user-menu-chip--full_admin    { background: #e9d5ff; color: #7c3aed; }

.user-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 200px;
  padding: 8px;
  z-index: 100;
}

.user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  color: var(--fg);
  border-radius: 4px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.user-menu-item:hover,
.user-menu-item:focus-visible {
  background: rgba(75, 38, 183, 0.08);
  color: var(--Vibrant-Purple, #4B26B7);
  outline: none;
}


/* Responsive: on narrow viewports, allow the header to wrap; nav links
   become full-width buttons and the user cluster sits below.
   A proper hamburger / off-canvas pattern is tracked separately. */

@media (max-width: 760px) {
  .header-bar {
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }

  .nav-cluster {
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    margin: 8px 0 0;
    gap: 2px;
  }

  .nav-link {
    width: 100%;
  }

  .nav-divider {
    width: auto;
    height: 1px;
    margin: 6px 0;
    flex-basis: 100%;
  }

  .user-cluster {
    border-left: none;
    padding-left: 0;
    margin-left: auto;
  }

  /* Submenus on mobile: render inline (no floating dropdown) */
  .nav-group {
    width: 100%;
  }

  .nav-submenu {
    position: static;
    box-shadow: none;
    border: none;
    border-left: 2px solid var(--line);
    border-radius: 0;
    margin-left: 16px;
    padding: 4px 0 8px 0;
    background: transparent;
  }
}


/* --- Status badges --- */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.badge--active   { background: #dcfce7; color: #15803d; }
.badge--in-progress,
.badge--in_progress { background: #dbeafe; color: #2563eb; }
.badge--expired  { background: #fee2e2; color: #dc2626; }
.badge--revoked  { background: #f3f4f6; color: #6b7280; }
.badge--pending  { background: #fef3c7; color: #d97706; }
.badge--approved { background: #dcfce7; color: #15803d; }
.badge--rejected { background: #fee2e2; color: #dc2626; }
.badge--disabled { background: #f3f4f6; color: #6b7280; }


/* --- Expiry warning levels --- */

.expiry              { font-weight: 500; }
.expiry--ok          { color: var(--fg); }
.expiry--warning     { color: #ca8a04; }   /* ≤ 90 days */
.expiry--danger      { color: #ea580c; }   /* ≤ 30 days */
.expiry--expired     { color: #dc2626; font-weight: 600; }


/* --- Empty state --- */

.empty-state {
  text-align: center;
  padding: clamp(32px, 6vw, 64px);
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.empty-state p {
  margin: 0 0 16px 0;
  font-size: 16px;
}


/* --- Messages / toasts --- */

.messages {
  margin-bottom: 16px;
}

.message {
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 8px;
  font-size: 14px;
}

.message--success { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.message--info    { background: #dbeafe; color: #2563eb; border: 1px solid #93c5fd; }
.message--warning { background: #fef3c7; color: #d97706; border: 1px solid #fcd34d; }
.message--error   { background: #fee2e2; color: #dc2626; border: 1px solid #fca5a5; }


/* --- Splash / login page --- */

.splash {
  max-width: 480px;
  margin: clamp(40px, 8vw, 96px) auto;
  text-align: center;
}

.splash .card {
  text-align: left;
  padding: clamp(20px, 3vw, 32px);
}

.splash h1 {
  margin-top: 0;
}

.splash-intro {
  color: var(--muted);
  margin-bottom: 24px;
}


/* --- Forms --- */

.form-field {
  margin-bottom: 16px;
}

.form-field label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
}

.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="password"],
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
  background: #fff;
  box-sizing: border-box;
}

.form-field input:focus-visible,
.form-field textarea:focus-visible,
.form-field select:focus-visible {
  outline: 2px solid var(--Vibrant-Purple, #4B26B7);
  outline-offset: 1px;
  border-color: var(--Vibrant-Purple, #4B26B7);
}

.form-error {
  color: #dc2626;
  font-size: 13px;
  margin-top: 4px;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}


/* --- Error pages (404/500/403) --- */

.error-page {
  text-align: center;
  padding: clamp(40px, 8vw, 96px) 16px;
  max-width: 600px;
  margin: 0 auto;
}

.error-page .error-code {
  font-size: clamp(64px, 10vw, 128px);
  font-weight: 800;
  color: var(--Vibrant-Purple, #4B26B7);
  line-height: 1;
  margin: 0;
}

.error-page h1 {
  margin: 12px 0;
}

.error-page p {
  color: var(--muted);
  margin-bottom: 24px;
}


/* --- CRUD page layout (Refs #14) --- */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.page-header h1 { margin: 0; }

.page-actions {
  display: flex;
  gap: 8px;
}

/* Detail grid */
.detail-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 16px;
}

.detail-grid dt {
  font-weight: 600;
  color: var(--muted, #6b7280);
}

.detail-grid dd { margin: 0; }

/* Back link */
.back-link { margin-top: 24px; }
.back-link a { color: var(--primary, #4B26B7); text-decoration: none; }
.back-link a:hover { text-decoration: underline; }

/* Danger card variant */
.card--danger {
  border-left: 4px solid var(--badge-expired-bg, #dc2626);
}

/* django-tables2 */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--silver, #e5e7eb);
}

.table th {
  font-weight: 600;
  color: var(--muted, #6b7280);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.table th a { color: inherit; text-decoration: none; }
.table th a:hover { text-decoration: underline; }

.table tr:hover { background: rgba(75, 38, 183, 0.03); }

/* Pagination (django-tables2) */
.pagination {
  display: flex;
  gap: 4px;
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
  justify-content: center;
}
.pagination li a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--silver, #e5e7eb);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text, #100c2a);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.pagination li a:hover {
  background: var(--card-bg, #f5f5f5);
  border-color: var(--silver, #cdcdcd);
}
.pagination li.active a {
  background: var(--primary-purple, #4b26b7);
  border-color: var(--primary-purple, #4b26b7);
  color: white;
}
.pagination li.previous a,
.pagination li.next a {
  font-size: 13px;
  letter-spacing: 0.02em;
}

/* Form field errors */
.form-field--error .form-input {
  border-color: var(--badge-expired-bg, #dc2626);
}

.field-errors {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
  color: var(--badge-expired-bg, #dc2626);
  font-size: 0.875rem;
}

.required { color: var(--badge-expired-bg, #dc2626); }

/* Danger button */
.vbtn--danger {
  background: var(--badge-expired-bg, #dc2626);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  text-decoration: none;
  display: inline-block;
}

.vbtn--danger:hover { opacity: 0.9; }

/* Secondary button */
.vbtn--secondary {
  background: transparent;
  color: var(--fg, #100C2A);
  border: 1px solid var(--silver, #CDCDCD);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  text-decoration: none;
  display: inline-block;
}

.vbtn--secondary:hover { background: rgba(0,0,0,0.04); }
