/* ========== Design Tokens ========== */
:root {
  --font-primary: 'Century Gothic', Arial, 'Arial Unicode MS', Helvetica, sans-serif;
  --font-size-base: 11px;
  --font-size-heading: 20px;
  --letter-spacing-base: 1px;
  --letter-spacing-heading: 3px;

  --color-bg-light: #FBFDEC;
  --color-bg-accent: #DFEF62;
  --color-bg-highlight: #CFE817;
  --color-bg-deep: #96A711;
  --color-text-primary: #12130B;
  --color-text-heading: #617321;
  --color-text-subheading: #7C922A;
  --color-text-muted: #595D37;
  --color-link: #000000;
  --color-link-hover: #818F00;
  --color-link-visited: #595D37;
  --color-border: #818650;
  --color-shadow: rgba(0, 0, 0, 0.3);
  --color-sheet-border: rgba(184, 188, 143, 0.4);

  --dropdown-width: 200px; /* default, overridden by JS */
  --tabpanel-width: auto;
}

/* ========== Base Styles ========== */
body {
  font-family: var(--font-primary);
  font-size: var(--font-size-base);
  letter-spacing: var(--letter-spacing-base);
  padding: 20px;
  margin: 0;
  background: var(--color-bg-light);
  color: var(--color-text-primary);
}

h1 {
  font-size: var(--font-size-heading);
  letter-spacing: var(--letter-spacing-heading);
  color: var(--color-text-heading);
  margin-bottom: 20px;
}

a {
  color: var(--color-link);
  text-decoration: underline;
}
a:hover {
  color: var(--color-link-hover);
  text-decoration: none;
}
a:visited {
  color: var(--color-link-visited);
}

/* ========== Layout ========== */

.header-inline {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-top: 1.5em;
  flex-wrap: wrap;
}

.helena-promo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5em;
}

.main-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-start;
  max-width: 100%;
  margin: 0 auto;
  padding: 10px;
  box-sizing: border-box;
}

.search-pane {
  flex: 0 0 300px;
  max-width: 450px;
  padding: 20px;
  background: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin-bottom: 30px;
  box-sizing: border-box;
}

.search-pane h2 {
  margin-top: 0;
  color: var(--color-text-subheading);
}

.product-pane {
  flex-grow: 1;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

#product-table {
  width: 100%;
  max-width: 100%;
  display: none;
}

#nameInput {
  margin-top: 10px;
  padding: 6px;
  font-size: var(--font-size-base);
  width: var(--dropdown-width);
  box-sizing: border-box;
  transition: width 0.3s ease;
}


/* ========== Reservation Form ========== */
#products-reservation-data {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 50%;
}

#products-reservation-data label {
  display: block;
  text-align: left;
  margin-bottom: 0.3em;
}

#products-reservation-data input,
#products-reservation-data textarea,
#products-reservation-data input[type="file"] {
  display: block;
  width: 100%;
  text-align: left;
  margin-bottom: 1em;
  box-sizing: border-box;
}

#products-reservation-data input[type="checkbox"] {
  display: inline-block;
  width: auto;
  margin-left: 0;
  margin-right: 0.5em;
  vertical-align: middle;
}

#products-reservation-data input[type="hidden"] {
  display: none;
}


/* Highlight invalid fields */
.invalid {
  border: 2px solid red;
}

/* Optional: style the response box */
#products-reservation-response {
  margin-top: 1em;
  font-weight: bold;
}


/* ========== Breadcrumb Navigation ========== */

.breadcrumb {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  margin: 0;
}

.breadcrumb-item {
  cursor: pointer;
  padding: 6px 12px;
  background: #eee;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.breadcrumb-item.active {
  background: #007bff;
  color: white;
}

.breadcrumb-item.disabled {
  background: #ccc;
  cursor: not-allowed;
}

.breadcrumb-separator {
  color: #888;
  user-select: none;
}


/* ========== Filter Controls ========== */
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

/* ========== Dropdowns ========== */
.search-pane select,
.search-pane .dropdown,
.search-pane .ui-selectmenu-button,
.search-pane .select2-container,
#search-category select,
[id^="category-dropdown_"] {
  width: var(--dropdown-width);
  box-sizing: border-box;
  transition: width 0.3s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ui-autocomplete {
  max-height: 150px;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1000; /* Ensure it stays above other UI elements */
}

/* ========== Category Dropdowns ========== */
#search-category {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

/* ========== Brandlogo Dropdown (Select2) ========== */
#brandlogo.select2-hidden-accessible + .select2-container.select2-container--default .select2-selection--single {
  height: calc(4em) !important;
  line-height: calc(4em) !important;
  padding: 0 12px;
  font-size: var(--font-size-base);
  font-family: var(--font-primary);
  background-color: #fff;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text-primary);
  width: var(--dropdown-width);
  box-sizing: border-box;
  transition: width 0.3s ease;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ========== Arrow container alignment ========== */
#brandlogo.select2-hidden-accessible + .select2-container.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 100%;
  width: 20px;
  position: absolute;
  top: 0;
  right: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* ========== Replace default triangle with "v" arrow ========== */
#brandlogo.select2-hidden-accessible + .select2-container.select2-container--default .select2-selection--single .select2-selection__arrow b {
  display: none;
}

#brandlogo.select2-hidden-accessible + .select2-container.select2-container--default .select2-selection--single .select2-selection__arrow::before {
  content: "v";
  font-size: 14px;
  color: #555;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* ========== Tab Panels ========== */
.ui-tabs-panel {
  width: var(--tabpanel-width);
  max-width: 100%;
  box-sizing: border-box;
  transition: width 0.3s ease;
}

/* ========== Vertical Tabs ========== */
.ui-tabs-vertical {
  display: flex;
  flex-direction: row;
}

.ui-tabs-vertical > ul {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: max-content;
  margin: 0;
  padding: 0;
  list-style: none;
  border-right: 1px solid var(--color-border);
}

.ui-tabs-vertical > ul li {
  width: 100%;
  margin: 0;
  border-bottom: 1px solid var(--color-border);
}

.ui-tabs-vertical > ul li a {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
  font-size: 11px;
  color: var(--color-text-primary);
  text-decoration: none;
}

.ui-tabs-vertical > ul li.ui-tabs-active a {
  background-color: var(--color-bg-accent);
  font-weight: bold;
  color: var(--color-text-heading);
}

.ui-tabs-vertical > div[role="tabpanel"],
.ui-tabs-panel.ui-corner-bottom.ui-widget-content {
  flex-grow: 1;
  padding: 20px;
  box-sizing: border-box;
}

/* ========== Tables ========== */
.tables {
  display: flex;
  gap: 40px;
  flex-wrap: wrap;
}

.table-container {
  flex: 1;
  min-width: 300px;
}

#total {
  font-weight: bold;
  margin-top: 10px;
}

#products-table {
  position: relative;
}

#products-table-text {
  text-align: center;
  margin-top: 20px;
}

/* ========== Tabulator Enhancements ========== */
.tabulator-row.highlighted-row {
  background-color: var(--color-bg-highlight) !important;
  box-shadow: inset 0 0 0 2px var(--color-bg-deep);
  transition: background-color 1s ease;
  z-index: 1;
}

.tabulator-cell.wrap-text {
  white-space: normal;
  word-break: break-word;
}

.tabulator-cell i {
  vertical-align: middle;
}

.price-original {
  color: red;
  text-decoration: line-through;
}

.price-discounted {
  color: green;
  font-weight: bold;
}

.tabulator-header-filter input, 
.tabulator-header-filter select {
  min-width: 200px;
  padding: 5px;
}

/* ========== Accordion ========== */
.ui-accordion-header {
  background-color: var(--color-bg-accent);
  color: var(--color-text-heading);
  padding: 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
}

.ui-accordion-content {
  background-color: var(--color-bg-light);
  padding: 10px 15px;
  border-bottom: 1px solid var(--color-sheet-border);
}

.accordion-inner h3 {
  font-size: 14px;
  color: var(--color-text-subheading);
  margin-top: 1em;
}

.product-title {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 1em;
}

/* ========== Spinner ========== */
#product-spinner {
  position: absolute;
  top: 10%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  background: rgba(255, 255, 255, 0.85);
  padding: 20px;
  border-radius: 8px;
  display: none;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}

/* ========== Checkout Pane ========== */
.checkout-pane {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  height: 100%;
  background: #fff;
  box-shadow: -4px 0 10px var(--color-shadow);
  padding: 20px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.4s ease-in-out;
  z-index: 1000;
}

.checkout-pane.visible {
  transform: translateX(0);
}

/* ========== Cell Validation ========== */
.invalid-cell {
  background-color: #ffe0e0;
  border: 1px solid #cc0000;
  cursor: help;
}

/* ========== Tabulator Icons ========== */
.icon-medicine     { color: lime !important; }
.icon-prescription { color: red !important; }
.icon-cart         { color: green !important; }
.icon-piggy        { color: blue !important; }
.icon-trash        { color: red !important; }

/* ========== Modal ========== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  padding: 2em;
  border-radius: 8px;
  text-align: left;
  max-width: 400px;
  box-shadow: 0 0 10px var(--color-shadow);
  box-sizing: border-box;
}

/* ========== Buttons ========== */
.btn {
  font-family: var(--font-primary);
  font-size: var(--font-size-base);
  background-color: var(--color-bg-accent);
  border: 1px solid var(--color-border);
  box-shadow: 0 0 2px 1px var(--color-shadow);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-sizing: border-box;
}

.btn:hover {
  background-color: var(--color-bg-highlight);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.btn .close-icon {
  color: red;
}

/* ========== Responsive Layout: Mobile (≤768px) ========== */

@media (max-width: 768px) {
  /* Stack layout vertically on mobile */
  .main-layout {
    flex-direction: column;
    /* flex-wrap: wrap; */
    gap: 10px;
  }

  /* Full-width panes for mobile */
  .search-pane,
  .product-pane,
  .checkout-pane {
    flex-grow: 1;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  /* Responsive product images */
  #product-table img {
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
  }

  /* Full-width buttons with spacing */
  .btn {
    width: 100%;
    max-width: 70px;
    margin-top: 10px;
  }

  /* Center spinner for loading */
  #product-spinner {
    display: block;
    margin: 10px auto;
  }

  /* Responsive modal content */
  .modal-content {
    width: 90%;
    padding: 1em;
    box-sizing: border-box;
  }

  /* Hide Tabulator header filters for cleaner mobile view */
  .tabulator-header-filter {
    display: none;
  }

  :root {
    --dropdown-width: 100%;
  }

  .search-pane select,
  #search-category select,
  [id^="category-dropdown_"] {
    width: 100% !important;
  }
}
