/* ==========================================================================
   ADMIN / MANAGE PAGES STYLESHEET
   Shared by: credit_login.html, cosco_login.html, oocl_login.html,
   hlc_login.html.

   These pages show the same list.css table UI, but gate it behind a
   login box, tint the header/search bar purple to signal "admin area",
   and add edit controls (switches, an edit button, a captcha) to the
   table rows. Load order: common.css, list.css, auth.css.
   ========================================================================== */

body {
  background: linear-gradient(120deg, var(--admin-accent-2), var(--admin-accent));
  min-height: 100vh;
}

/* The real navbar/content only appears once login succeeds */
.navbar {
  display: none;
}

.navbar.show {
  display: flex;
}

.navbar-nav .nav-item + .nav-item {
  margin-left: 15px;
}

/* Admin-area tint for the header and search bar */
.sticky-container,
.header-first {
  background: linear-gradient(to right, var(--admin-accent), var(--admin-accent-2)) !important;
  color: var(--white);
}

.filter-section .search-container {
  animation: none !important;
  transition: none !important;
}

/* Default-admin-email field with a "use another email" toggle */
.login-email-field {
  margin-bottom: 20px;
}

.login-email-field input {
  margin-bottom: 0 !important;
}

.login-email-field input[readonly] {
  cursor: default;
  opacity: 0.85;
}

.toggle-email-btn {
  display: inline-block;
  margin-top: 6px;
  font-size: 13px;
  color: var(--admin-accent, #003087);
  text-decoration: underline;
  cursor: pointer;
  user-select: none;
}

.toggle-email-btn:hover,
.toggle-email-btn:focus {
  color: var(--admin-accent-2, #0057d9);
  outline: none;
}

/* Password field with a visibility toggle */
.password-wrapper {
  position: relative;
}

.password-wrapper input {
  width: 100%;
  padding-right: 40px;
  box-sizing: border-box;
}

#togglePassword {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(calc(-50% - 7px));
  font-size: 18px;
  color: #666;
  cursor: pointer;
  user-select: none;
  transition: color 0.3s ease;
}

#togglePassword:hover {
  color: #000;
}

.toast button {
  background: none;
  border: none;
  color: #00f;
  font-weight: bold;
  cursor: pointer;
  margin-left: 12px;
  font-size: 16px;
}

.toast button:hover {
  text-decoration: underline;
}

/* Editable rows: on manage pages the zebra-stripe hover is distracting
   next to switches and buttons, so it's turned off here only. */
#myTable tbody tr {
  transition: none !important;
  transform: none !important;
  background-color: transparent !important;
}

#myTable tbody tr:hover {
  background-color: inherit !important;
  transform: none !important;
}

#myTable td:first-child,
#myTable th:first-child,
#myTable td:nth-child(4),
#myTable th:nth-child(4) {
  text-align: center;
  vertical-align: middle;
}

.overdue-check {
  display: none;
}

.bg-overdue {
  background-color: var(--table-overdue) !important;
  transition: background-color 0.2s;
  font-weight: bold;
  color: #000;
}

.bg-overdue:hover {
  background-color: var(--table-overdue-hover) !important;
}

/* iOS-style on/off switch for row status */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--admin-accent);
  transition: 0.4s;
  border-radius: 34px;
}

.slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 3px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: red;
}

input:checked + .slider::before {
  transform: translateX(26px);
}

.custom-edit-btn {
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(to right, var(--success), var(--success-dark));
  position: relative;
  overflow: hidden;
  z-index: 1;
  transition: all 0.3s ease-in-out;
}

.custom-edit-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(to right, var(--success-dark), var(--success));
  transition: left 0.4s ease;
  z-index: -1;
}

.custom-edit-btn:hover::before {
  left: 0;
}

.custom-edit-btn:hover {
  color: #fff;
}

/* Delete button (row actions column). Explicit, self-contained styling —
   doesn't lean on Bootstrap's .btn/.btn-danger utility classes, which the
   row markup also carries for backwards compatibility with existing
   selectors elsewhere, but which shouldn't be the only thing keeping this
   button visible. */
.custom-delete-btn {
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(to right, var(--danger), var(--danger-dark));
  position: relative;
  overflow: hidden;
  z-index: 1;
  transition: all 0.3s ease-in-out;
}

.custom-delete-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(to right, var(--danger-dark), var(--danger));
  transition: left 0.4s ease;
  z-index: -1;
}

.custom-delete-btn:hover::before {
  left: 0;
}

.custom-delete-btn:hover {
  color: #fff;
}

.custom-delete-btn i {
  pointer-events: none;
}

/* Row actions cell: give the edit/delete buttons a predictable, robust
   layout instead of relying on percentage height inside a table cell
   (which table rows don't reliably support). */
td:last-child {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  overflow: visible;
  white-space: normal;
}

/* Logout button in the admin navbar. Explicit styling — the markup also
   carries Bootstrap's .btn.btn-link classes for legacy reasons, but this
   is what actually guarantees visible padding and color regardless of
   how those utility classes resolve. */
.admin-logout-btn {
  display: inline-block;
  padding: 8px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(to right, var(--danger), var(--danger-dark));
  border: none;
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s;
}

.admin-logout-btn:hover {
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* Captcha on the login form */
.captcha-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

#captchaInput,
#captchaCanvas {
  height: 40px;
  width: 150px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
  margin-bottom: 0;
}

#captchaCanvas {
  background: #f9f9f9;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}

#refreshCaptchaBtn {
  width: 40px;
  height: 40px;
  margin-left: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  border: none;
  outline: none;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--admin-accent-2), var(--admin-accent));
  color: #fff;
}

/* Add / Edit Company modal
   -------------------------------------------------------------------------
   These classes existed in the markup with no matching CSS at all, so the
   Save/Cancel buttons and inputs were rendering as unstyled browser
   defaults. Styled here to match the rest of the admin UI. */
.entry-form-box {
  text-align: left;
  background: var(--white);
  border-radius: 16px;
  max-width: 420px;
  padding: 30px 32px;
}

.entry-form-box::before {
  content: none;
}

/* Gradient title bar — matches the Credit List "Add New Company" form,
   so both admin tools feel like the same product. */
.entry-form-box__title {
  color: var(--white);
  text-shadow: none;
  margin: -30px -32px 22px;
  padding: 16px 20px;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  border-radius: 16px 16px 0 0;
  background: linear-gradient(45deg, var(--primary), var(--admin-accent), var(--primary));
  background-size: 200% 200%;
  animation: gradientAnimation 4s ease infinite;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

/* Bold, uppercase, underlined labels — much clearer at a glance than
   plain small-caps text. */
.entry-form-box label {
  display: inline-block;
  font-size: 0.85rem;
  color: #1a1a1a;
  margin-bottom: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: relative;
  padding-bottom: 4px;
}

.entry-form-box label::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 50%;
  height: 2px;
  background: linear-gradient(90deg, var(--secondary), var(--admin-accent));
  transition: width 0.3s ease;
}

.entry-form-box label:hover::after {
  width: 100%;
}

.entry-required {
  color: var(--secondary);
  font-size: 1rem;
  vertical-align: middle;
}

.entry-form-box input[type="text"] {
  display: block;
  width: 100%;
  padding: 12px 15px;
  margin-bottom: 18px;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  font-size: 0.95rem;
  background: #f8f9fa;
  box-shadow: none;
  transition: all 0.25s ease;
}

.entry-form-box input[type="text"]:focus {
  outline: none;
  border-color: var(--admin-accent);
  background: var(--white);
  box-shadow: 0 0 8px rgba(37, 117, 252, 0.25);
  transform: translateY(-2px);
}

.entry-form-box input[type="text"]::placeholder {
  color: #a0a0a0;
  opacity: 0.8;
}

.entry-save-btn,
.entry-cancel-btn {
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  color: #fff;
  transition: transform 0.2s, box-shadow 0.2s;
}

.entry-save-btn {
  background: linear-gradient(to right, var(--success), var(--success-dark));
}

.entry-cancel-btn {
  background: linear-gradient(to right, #6c757d, #565e64);
}

.entry-save-btn:hover,
.entry-cancel-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

@media (max-width: 480px) {
  .login-box,
  .logout-box {
    padding: 30px 20px;
  }

  .captcha-row {
    flex-wrap: wrap;
  }
}

/* Switch-list bar: lets an already-logged-in admin jump straight to
   managing any of the other three lists without logging in again (all
   four admin panels share one Firebase login session). */
.admin-switch-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 10px clamp(10px, 2vw, 15px) 0;
}

.admin-switch-list__link {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: clamp(0.8rem, 2vw, 0.9rem);
  font-weight: 600;
  color: var(--white);
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.4);
  text-decoration: none;
  transition: background 0.25s, transform 0.2s;
}

.admin-switch-list__link:hover {
  background: rgba(255, 255, 255, 0.32);
  color: var(--white);
  transform: translateY(-1px);
}

.admin-switch-list__link.is-active {
  background: var(--white);
  color: var(--admin-accent-2);
  cursor: default;
}

.admin-switch-list__link.is-active:hover {
  transform: none;
}

/* Backup Data button + modal */
.admin-backup-bar {
  display: flex;
  justify-content: center;
  padding: 0 clamp(10px, 2vw, 15px) 10px;
}

.admin-backup-btn {
  padding: 7px 18px;
  border-radius: 20px;
  font-size: clamp(0.8rem, 2vw, 0.9rem);
  font-weight: 600;
  color: var(--admin-accent-2);
  background: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: background 0.25s, transform 0.2s, box-shadow 0.2s;
}

.admin-backup-btn:hover {
  background: var(--white);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.modal-content .backup-modal-desc {
  font-size: 0.9rem;
  color: #555;
  font-weight: normal;
  margin-bottom: 16px;
  text-align: center;
}

.backup-checklist {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 8px;
}

.backup-checklist label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  font-weight: 500;
  color: #333;
  background: #f8f9fb;
  border: 1.5px solid #e1e5ea;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.backup-checklist label:hover {
  border-color: var(--admin-accent);
  background: #fff;
}

.backup-checklist input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--admin-accent);
  cursor: pointer;
}
