/* Global styles */
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  margin: 1rem;
  background: #f4f9fc;
  color: #333;
}

form {
  max-width: 960px;
  margin: auto;
  padding: 1rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Order section */
fieldset.order-block {
  border: 1px solid #cce6ff;
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 2rem;
  background: #f9fbff;
}

legend {
  font-size: 1.2rem;
  font-weight: bold;
  padding: 0 0.5rem;
  color: #2a6496;
}

/* Reset basic nav styles */
header.navbar {
  background-color: #e0f0ff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 0.5em 0;
  position: sticky;
  top: 0;
  z-index: 1000;
}

#cssmenu {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1em;
}

#cssmenu ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  margin: 0;
  padding: 0;
}

#cssmenu li {
  margin: 0;
  padding: 0;
}

#cssmenu li a {
  display: block;
  padding: 0.75em 1em;
  text-decoration: none;
  color: #004080;
  font-weight: bold;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

#cssmenu li.active a,
#cssmenu li a:hover {
  background-color: #cce5ff;
  color: #002244;
}

#cssmenu li:last-child {
  margin-left: auto;
}

@media (max-width: 600px) {
  #cssmenu ul {
    flex-direction: column;
    align-items: stretch;
  }

  #cssmenu li {
    width: 100%;
  }

  #cssmenu li a {
    text-align: center;
  }
}

/* Form fields */
label {
  display: block;
  margin-top: 0.75rem;
  font-weight: 500;
  color: #333;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
select {
  width: 100%;
  max-width: 400px;
  padding: 0.5rem;
  margin-top: 0.25rem;
  border: 1px solid #b3d7ff;
  border-radius: 4px;
  font-size: 1rem;
  box-sizing: border-box;
}

input[type="checkbox"] {
  transform: scale(1.2);
  margin-top: 0.4rem;
}

/* Buttons */
input[type="submit"],
button {
  background: #4da6ff;
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  margin-top: 1rem;
  transition: background 0.2s ease;
}

input[type="submit"]:hover,
button:hover {
  background: #379fff;
}

button.remove-item {
  background: #ff6b6b;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.3em 0.6em;
  font-size: 0.9rem;
  cursor: pointer;
  vertical-align: middle;
  line-height: 1.2;
  margin: 0; /* remove weird default spacing */
}

button.remove-item:hover {
  background: #ff4c4c;
}

button.add-item {
  background: #4da6ff;
}

button.add-item:hover {
  background: #379fff;
}

textarea {
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 0.5em;
  font-size: 1rem;
  font-family: inherit;
  box-sizing: border-box;
  width: 100%;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea:focus {
  border-color: #4b9dea;
  box-shadow: 0 0 3px rgba(75, 157, 234, 0.5);
  outline: none;
}

/* Tables */
table.order-items {
  width: 100%;
  border-collapse: collapse;
}

table.order-items th,
table.order-items td {
  border: 1px solid #ddeaff;
  padding: 0.5rem;
  text-align: left;
  font-size: 0.95rem;
}

table.order-items th {
  background: #e6f3ff;
}

/* Autocomplete suggestions */
.customer-suggestions {
  list-style: none;
  max-height: 150px;
  overflow-y: auto;
  padding: 0;
  margin: 0;
  display: none; /* hidden by default */
  border: 1px solid #ccc;
  background: white;
  position: absolute;
  z-index: 10;
}

.customer-suggestions.visible {
  display: block;
}

.customer-suggestions li {
  padding: 8px 12px;
  cursor: pointer;
}

.customer-suggestions li:hover {
  background: #e6f3ff;
}

/* --- SLAP TOGGLE SWITCH --- */

.toggle {
  margin: 0 0 1.5rem;
  display: flex;
  font-size: 0;
}

.toggle input[type="radio"] {
  width: 0;
  height: 0;
  position: absolute;
  left: -9999px;
}

.toggle input[type="radio"] + label {
  padding: 0.75rem 2rem;
  border: 1px solid #ddd;
  background-color: #fff;
  font-size: 1rem;
  font-weight: 600;
  color: #333;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.toggle input[type="radio"]:first-of-type + label {
  border-radius: 6px 0 0 6px;
  border-right: none;
}

.toggle input[type="radio"]:last-of-type + label {
  border-radius: 0 6px 6px 0;
  border-left: none;
}

.toggle input[type="radio"]:hover + label {
  border-color: #213140;
}

.toggle input[type="radio"]:checked + label {
  background-color: #4b9dea;
  color: white;
  border-color: #4b9dea;
  z-index: 1;
  box-shadow: 0 0 10px rgba(75, 157, 234, 0.5);
}

/* Responsive tweaks */
@media (max-width: 800px) {
  .toggle input[type="radio"] + label {
    padding: 0.75rem 0.25rem;
    flex: 1 1 50%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
}

/* --- SLAP TOGGLE SWITCH --- */

.toggle {
  margin: 0 0 1.5rem;
  display: flex;
  font-size: 0;
}

.toggle input[type="radio"] {
  width: 0;
  height: 0;
  position: absolute;
  left: -9999px;
}

.toggle input[type="radio"] + label {
  padding: 0.75rem 2rem;
  border: 1px solid #ddd;
  background-color: #fff;
  font-size: 1rem;
  font-weight: 600;
  color: #333;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.toggle input[type="radio"]:first-of-type + label {
  border-radius: 6px 0 0 6px;
  border-right: none;
}

.toggle input[type="radio"]:last-of-type + label {
  border-radius: 0 6px 6px 0;
  border-left: none;
}

.toggle input[type="radio"]:hover + label {
  border-color: #213140;
}

.toggle input[type="radio"]:checked + label {
  background-color: #4b9dea;
  color: white;
  border-color: #4b9dea;
  z-index: 1;
  box-shadow: 0 0 10px rgba(75, 157, 234, 0.5);
}

/* Responsive tweaks */
@media (max-width: 800px) {
  .toggle input[type="radio"] + label {
    padding: 0.75rem 0.25rem;
    flex: 1 1 50%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
}

/* Responsive layout */
@media (max-width: 600px) {
  form {
    padding: 1rem;
  }

  input[type="text"],
  input[type="email"],
  input[type="number"],
  input[type="date"],
  input[type="datetime-local"],
  select {
    width: 100%;
  }

  table.order-items th,
  table.order-items td {
    font-size: 0.85rem;
    padding: 0.4rem;
  }

  legend {
    font-size: 1rem;
  }
}

table.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 1rem;
  background: white;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 3rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

table.data-table thead tr:nth-child(2) th {
  background-color: #b3d9f5; /* bluer and clearer */
  font-weight: 600;
  color: #002244;
  border-bottom: 2px solid #aacbe6;
  border-right: 1px solid #cce6ff;
  border-left: 1px solid #cce6ff;
}

table.data-table thead tr:nth-child(2) th:first-child {
  border-left: none;
}

table.data-table thead tr:nth-child(2) th:last-child {
  border-right: none;
}

table.data-table th,
table.data-table td {
  border: 1px solid #cce6ff;
  padding: 0.6rem 0.75rem;
  text-align: center;
}

table.data-table th {
  background: #e6f3ff;
  color: #002244;
}

table.data-table tr:nth-child(odd) {
  background-color: #f0f6fc;
}

table.data-table tr:nth-child(even) {
  background-color: #ffffff;
}

table.data-table tbody tr:hover {
  background-color: #ffff77;
}

/* Responsive tweaks */
@media (max-width: 700px) {
  table.data-table th,
  table.data-table td,
  table.items-table th,
  table.items-table td {
    font-size: 1rem;
    padding: 0.4rem;
  }

  table.items-table th,
  table.items-table td {
    white-space: nowrap;
  }

  table.items-table {
    display: block;
    overflow-x: auto;
  }
}

/* Unified order + items container */
.order-wrapper {
  margin: 2rem 0;
  border: 2px solid #4b9dea; /* darker, stronger blue */
  border-radius: 10px;
  overflow: hidden;
  background: white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

/* Each order is a separate block */
table.order-block {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 1rem;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

table.order-block th {
  background: #003366;
  color: #ffffff;
  font-weight: 600;
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid #002244;
}

table.order-block td {
  padding: 1rem;
  border-top: 1px solid #ddeaff;
}

table.item-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 1rem;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: #f9fbff;
}

table.item-table th {
  background: #cde4f7;
  color: #002244;
  font-weight: 500;
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid #aacbe6;
}

table.item-table td {
  padding: 0.75rem 1rem;
  border-top: 1px solid #ddeeff;
}

/* Alternating colors for item rows */
table.item-table tr.odd {
  background-color: #e0e8ef;
}

table.item-table tr.even {
  background-color: #ffffff;
}

table.order-info-table {
  width: 100%;
  font-size: 1rem;
  border-collapse: collapse;
  margin-bottom: 2rem;
  background: white;
  border: 1px solid #cce6ff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

table.order-info-table th {
  background: #e6f3ff;
  color: #002244;
  text-align: left;
  padding: 0.75rem 1rem;
  width: 30%;
  font-weight: 600;
  border-bottom: 1px solid #ddeaff;
}

table.order-info-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #ddeaff;
}

table.item-table.view {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
  background: white;
  border: 1px solid #aacbe6;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  margin-bottom: 2rem;
}

table.item-table.view th {
  background: #cde4f7;
  color: #002244;
  font-weight: 600;
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid #aacbe6;
}

table.item-table.view td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #ddeeff;
}

table.item-table.view tr.odd {
  background-color: #f0f6fc;
}

table.item-table.view tr.even {
  background-color: #ffffff;
}

table.item-table.view tbody tr:nth-child(odd) {
  background-color: #f0f6fc;
}

table.item-table.view tbody tr:nth-child(even) {
  background-color: #ffffff;
}

span.errormsg {
  color: red;
  font-weight: bold;
  font-size: 1rem;
}

.fulfillment-page table.data-table th,
.fulfillment-page table.data-table td {
  text-align: left;
  border: 1px solid #aacbe6;
  padding: 0.6rem 0.75rem;
  color: #222; /* darker than #333 */
  font-size: 1rem;
}

.fulfillment-page table.data-table th {
  background: #b8d9f3; /* bluer, stronger */
  font-weight: 600;
  color: #002244;
}

.fulfillment-page table.data-table tr:nth-child(odd) {
  background-color: #f0f6fc;
}

.fulfillment-page table.data-table tr:nth-child(even) {
  background-color: #ffffff;
}

/* Form Table Styling */
.add-table table {
  width: 100%;
  border-collapse: collapse;
}

.add-table table th,
.add-table table td {
  padding: 0.75rem 1rem;
  vertical-align: top;
  border-top: 1px solid #ddeaff;
}

.add-table table tr:first-child th,
.add-table table tr:first-child td {
  border-top: none;
}

.add-table table th {
  text-align: right;
  vertical-align: top; /* <-- this is the key fix */
  padding: 0.75rem 1rem;
  background-color: #f0f6fc;
  width: 200px;
  font-weight: 600;
  color: #002244;
  border-right: 1px solid #ddeaff;
}

.add-table table td {
  background-color: #f9fbff;
}

.add-table table tr:nth-child(even) {
  background-color: #eef5fb; /* noticeably different from white */
}

.add-table table tr:nth-child(odd) {
  background-color: #ffffff;
}

.add-table h4 {
  font-size: 1.1rem;
  color: #2a6496;
  border-bottom: 1px solid #aacbe6;
  padding-bottom: 0.25rem;
}

/* Buttons */
button.delete-item {
  background-color: #ff6b6b;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  font-size: 0.9rem;
}

button.delete-item:hover {
  background-color: #e63946;
}

/* Inline inputs (Price field) */
.add-table input[type="text"][style*="width:8ch;"] {
  display: inline-block;
  width: 8ch;
}

/* Error message styling */
span.errormsg {
  display: inline-block;
  margin-top: 0.25rem;
}

/* Section divider for visual structure */
.add-table .section-divider {
  margin-top: 2rem;
  border-top: 2px solid #aacbe6;
  padding-top: 1rem;
}

@media (max-width: 700px) {
  .order-items {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .order-items table {
    min-width: 700px; /* ensures horizontal scroll */
  }
}

@media (max-width: 600px) {
  .add-table table,
  .add-table table tr,
  .add-table table th,
  .add-table table td {
    display: block;
    width: 100%;
  }

  .add-table table th {
    text-align: left;
    background: transparent;
    padding-bottom: 0.25rem;
    border: none;
  }

  .add-table table td {
    padding-top: 0;
    background: none;
  }
}

.items-section {
  margin-top: 2rem;
  background: white;
  padding: 1rem;
  border: 1px solid #cce6ff;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.items-section h4 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: #2a6496;
}

.items-section table.order-items {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0;
}

.items-section table.order-items th,
.items-section table.order-items td {
  border: 1px solid #ddeaff;
  text-align: center;
  padding: 0.5rem;
  font-size: 0.95rem;
}

.items-section table.order-items th {
  background: #e6f3ff;
  font-weight: 600;
  color: #002244;
}

a.button-link {
  display: inline-block;
  background: #4da6ff;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 500;
  transition: background 0.2s ease;
}

a.button-link:hover {
  background: #379fff;
}

.pagination {
  text-align: center;
  margin: 2rem 0;
  font-size: 1rem;
}

.pagination a {
  color: #004080;
  text-decoration: none;
  margin: 0 0.5rem;
  font-weight: bold;
}

.pagination a:hover {
  color: #002244;
  text-decoration: underline;
}

.email-type {
    display: flex;
    gap: 0.5em;
    flex-wrap: nowrap; /* force single row */
}

.email-type input[type="radio"] {
    display: none;
}

.email-type label {
    display: inline-block; /* ensure side-by-side */
    padding: 0.5em 1em;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    background-color: #f0f0f0;
    transition: background-color 0.2s, border-color 0.2s;
    white-space: nowrap; /* prevent text wrapping */
}

.email-type input[type="radio"]:checked + label {
    background-color: #2a6496;
    border-color: #2a6496;
    color: #fff;
}

.email-type label:hover {
    background-color: #e0e0e0;
}

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  min-width: 240px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  background: #333;
  color: #fff;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 160ms ease, transform 160ms ease;
  font-size: 14px;
  line-height: 1.4;
}

.toast.success { background: #2e7d32; }

.toast.error { background: #c62828; }

.toast.show { opacity: 1; transform: translateY(0); }

/* --- Generic view page layout --- */
.container.view-page {
  max-width: 960px;
  margin: 1.5rem auto;
}

.view-header {
  margin: 0 0 1rem;
}

.view-title {
  margin: 0;
  font-size: 1.5rem;
  color: #2a6496;
}

.view-subtitle {
  margin-top: 0.25rem;
  color: #556;
  font-size: 0.95rem;
}

/* Reusable card wrapper */
.card {
  background: #fff;
  border: 1px solid #cce6ff;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  overflow: hidden;
}

/* Generic key–value table for view pages */
table.kv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
}

table.kv-table tr + tr td,
table.kv-table tr + tr th {
  border-top: 1px solid #ddeaff;
}

table.kv-table th {
  width: 30%;
  text-align: left;
  background: #e6f3ff;
  color: #002244;
  font-weight: 600;
  padding: 0.75rem 1rem;
  vertical-align: top;
}

table.kv-table td {
  padding: 0.75rem 1rem;
  background: #ffffff;
}

/* Hover highlight (optional for read-only) */
table.kv-table tbody tr:hover td,
table.kv-table tbody tr:hover th {
  background-color: #f0f6fc;
}

/* Actions row shared across view pages */
.view-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* Footer */
.site-footer {
  text-align: center;
  margin: 2rem 0 1rem;
  color: #556;
  font-size: 0.95rem;
}

/* Responsive */
@media (max-width: 700px) {
  table.kv-table th {
    width: 45%;
  }
}

@media (max-width: 520px) {
  /* Stack label above value on narrow screens */
  table.kv-table th, table.kv-table td {
    display: block;
    width: 100%;
  }
  table.kv-table th {
    border-top: none !important;
    background: #f0f6fc;
    border-bottom: 1px solid #ddeaff;
  }
  table.kv-table td {
    padding-top: 0.5rem;
  }
}

/* Parent <li> positions the dropdown */
#cssmenu > ul > li.has-sub { position: relative; }

/* Submenu panel */
#cssmenu .submenu {
  position: absolute;
  left: 0;
  top: 100%;
  display: none;
  min-width: 220px;
  background: #fff;            /* adjust for your theme */
  border: 1px solid #ddd;
  box-shadow: 0 6px 16px rgba(0,0,0,.08);
  padding: .25rem 0;
  z-index: 1000;
}

/* Submenu items */
#cssmenu .submenu li a {
  display: block;
  padding: .5rem .85rem;
  white-space: nowrap;
  color: #333;                 /* adjust for dark nav */
  text-decoration: none;
}
#cssmenu .submenu li a:hover { background: #f5f5f5; }

/* Show on hover or keyboard focus (and tap via :focus-within) */
#cssmenu li.has-sub:hover > .submenu,
#cssmenu li.has-sub:focus-within > .submenu {
  display: block;
}

/* Optional: little caret on the parent link */
#cssmenu li.has-sub > a::after {
  content: "▾";
  margin-left: .35em;
  font-size: .8em;
  opacity: .8;
}
