/* START OF FILE style.css */
/* ==========================================================================
   1. General Body & Page Styles
   ========================================================================== */

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  background-color: #f0f2f5;
  color: #333;
  margin: 0;
  padding: 20px;
}

/* ==========================================================================
   2. Layout Containers & Views
   ========================================================================== */

.hidden {
  display: none !important;
}

header#app-header {
  max-width: 1200px;
  margin: 0 auto 20px auto;
  background: #ffffff;
  padding: 15px 0px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.header-content {
  display: flex;
  padding: 0px 25px;
  justify-content: space-between;
  align-items: center;
}
#header-user-display {
  font-weight: 600;
  color: #2d3748;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ==========================================================================
   Usage / plan badge (header)
   ========================================================================== */
.usage-badge {
  margin: 0;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85em;
  font-weight: 600;
  color: #2d3748;
  background: #edf2f7;
  white-space: nowrap;
  line-height: 1.2;
}
.usage-badge--exceeded {
  color: #c53030;
  background: #fff5f5;
}
.usage-badge--manage {
  cursor: pointer;
}
.usage-badge--manage:hover {
  background: #e2e8f0;
}
.usage-badge--manage.usage-badge--exceeded:hover {
  background: #fed7d7;
}

.view-container {
  max-width: 400px;
  margin: 60px auto;
  background: #ffffff;
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.view-container h1 {
  border-bottom: none;
  text-align: center;
  margin-bottom: 20px;
}

.settings-back-btn {
  display: inline-block;
  width: auto;
  margin: 0 0 12px 0;
  padding: 8px 14px;
}

.boot-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.boot-loading-text {
  margin: 0;
  font-size: 1.05em;
  font-weight: 600;
  color: #2d3748;
}

.boot-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e2e8f0;
  border-top-color: #4a5568;
  border-radius: 50%;
  animation: bootSpin 0.8s linear infinite;
}

@keyframes bootSpin {
  to {
    transform: rotate(360deg);
  }
}
.view-container p {
  color: #718096;
  font-size: 0.9em;
  text-align: center;
  margin-bottom: 20px;
}

.layout-container {
  display: flex;
  gap: 25px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  align-items: flex-start;
  box-sizing: border-box;
}
.main-content {
  flex: 3;
  min-width: 0;
  background: #ffffff;
  padding: 25px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  box-sizing: border-box;
}
.sidebar {
  flex: 1;
  min-width: 0;
  position: sticky;
  top: 20px;
}

/* ==========================================================================
   3. Auth Tabs & Settings UI Improvements
   ========================================================================== */

.auth-tabs {
  display: flex;
  border-bottom: 2px solid #edf2f7;
  margin-bottom: 20px;
}
.auth-tab {
  flex: 1;
  background: none;
  color: #718096;
  padding: 12px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  border: none;
  outline: none;
  transition: all 0.2s;
}
.auth-tab:hover {
  color: #2d3748;
  background-color: #f7fafc;
}
.auth-tab.active {
  color: #3182ce;
  border-bottom: 2px solid #3182ce;
  margin-bottom: -2px;
}

.info-box {
  background: #ebf8ff;
  border: 1px solid #bee3f8;
  padding: 12px;
  border-radius: 6px;
  margin-top: 10px;
  margin-bottom: 10px;
}
.info-box small {
  color: #2b6cb0;
  display: block;
  margin-bottom: 8px;
}

/* ==========================================================================
   4. Form Elements & Buttons
   ========================================================================== */

.form-container {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 25px;
}
.input-wrapper {
  position: relative;
  display: flex;
  width: 100%;
  align-items: stretch;
}
.input-wrapper.search-wrapper {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.sku-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sku-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sku-row-inputs {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.sku-row .input-wrapper {
  flex: 1;
  min-width: 0;
  width: auto;
}
.sku-row .sku-input {
  flex: 1;
  min-width: 0;
}
.sku-qty-input {
  flex: 0 0 72px;
  width: 72px;
  min-width: 72px;
  text-align: center;
  padding-left: 8px;
  padding-right: 8px;
}
.sku-row-inputs .mode-toggle,
.sku-remove-btn {
  flex: 0 0 46px;
  padding: 0;
  margin-top: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #edf2f7;
  border: 1px solid #cbd5e0;
  color: #4a5568;
  cursor: pointer;
  width: auto;
  box-sizing: border-box;
}
.sku-remove-btn:hover {
  background-color: #fed7d7;
  border-color: #fc8181;
  color: #c53030;
}
.sku-remove-btn svg {
  width: 20px;
  height: 20px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-group label {
  font-size: 14px;
  font-weight: 600;
  color: #2d3748;
}
.field-group .required {
  color: #e53e3e;
}
.field-error {
  font-size: 13px;
  color: #e53e3e;
  line-height: 1.2;
}
.field-error:empty {
  display: none;
}
.field-hint {
  font-size: 12px;
  color: #718096;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
button {
  padding: 12px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: 16px;
  transition: all 0.2s;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="datetime-local"] {
  width: 100%;
  box-sizing: border-box;
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="datetime-local"]:focus {
  border-color: #4a5568;
  outline: none;
  box-shadow: 0 0 0 3px rgba(74, 85, 104, 0.1);
}
input.invalid {
  border-color: #e53e3e;
}
input.invalid:focus {
  box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.15);
}

/* Hidden traps for password managers; real secret stays type=text so Chrome won't autofill */
.autofill-trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.masked-secret {
  -webkit-text-security: disc;
}

button {
  background-color: #4a5568;
  color: white;
  cursor: pointer;
  border: none;
  font-weight: 600;
  width: 100%;
}
.form-container > button[type="submit"] {
  margin-top: 0;
}
button:hover {
  background-color: #2d3748;
}
button:disabled {
  background-color: #a0aec0;
  cursor: not-allowed;
}

button.secondary-btn {
  background-color: #edf2f7;
  color: #4a5568;
  width: auto;
  font-size: 14px;
  padding: 8px 16px;
  margin-top: 0;
}
button.secondary-btn:hover {
  background-color: #e2e8f0;
}

button.danger-btn {
  background-color: #fff5f5;
  color: #c53030;
  border: 1px solid #feb2b2;
  width: 100%;
  font-size: 14px;
  padding: 12px;
  margin-top: 8px;
}
button.danger-btn:hover {
  background-color: #fed7d7;
}

.password-wrapper input {
  padding-right: 44px;
}
.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #718096;
  cursor: pointer;
  box-shadow: none;
}
.password-toggle:hover {
  background: transparent;
  color: #2d3748;
}
.password-toggle svg {
  width: 20px;
  height: 20px;
}

.mode-toggle {
  flex: 0 0 46px;
  padding: 0;
  margin-top: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #edf2f7;
  border: 1px solid #cbd5e0;
  color: #4a5568;
  cursor: pointer;
  width: auto;
  box-sizing: border-box;
}
.mode-toggle svg {
  width: 24px;
  height: 24px;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.mode-toggle:hover {
  background-color: #e2e8f0;
  border-color: #a0aec0;
}
.mode-toggle.active {
  background-color: #3182ce;
  border-color: #3182ce;
  color: white;
}
.mode-toggle.active:hover {
  background-color: #2c5282;
}
.mode-toggle.active svg {
  transform: rotate(135deg);
}
input.create-mode-active {
  border-color: #3182ce;
  background-color: #ebf8ff;
}
input.create-mode-active:focus {
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.2);
}

/* ==========================================================================
   5. Inventory Status & Notifications
   ========================================================================== */

.sku-product-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f7fafc;
}
.sku-product-preview.hidden {
  display: none;
}
.sku-product-image {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 4px;
  background: #e2e8f0;
  flex-shrink: 0;
}
.sku-product-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sku-product-title {
  font-size: 0.95em;
  font-weight: 600;
  color: #2d3748;
  line-height: 1.3;
}
.sku-product-status {
  font-size: 0.85em;
  font-weight: 600;
  color: #4a5568;
}
.sku-product-status.error {
  color: #c53030;
}

.notification-box {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 15px 25px;
  border-radius: 8px;
  color: white;
  font-weight: 600;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  transition:
    top 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    opacity 0.5s;
  opacity: 1;
}
.notification-box.hidden {
  top: -100px;
  opacity: 0;
}
.notification-box.error {
  background-color: #e53e3e;
}
.notification-box.success {
  background-color: #48bb78;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: transparent;
  padding: 16px;
}
.modal-overlay::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: rgba(45, 55, 72, 0.45);
}
.modal-dialog {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
  margin: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
}
body.modal-open {
  overflow: hidden;
}
.modal-dialog h3 {
  margin: 0 0 10px;
  color: #2d3748;
  font-size: 1.15rem;
}
.modal-dialog p {
  margin: 0 0 20px;
  color: #718096;
  font-size: 0.95em;
  line-height: 1.45;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}
.modal-actions button {
  width: auto;
  padding: 10px 18px;
  font-size: 14px;
  margin: 0;
}
.modal-actions #btn-confirm-ok {
  background-color: #e53e3e;
}
.modal-actions #btn-confirm-ok:hover {
  background-color: #c53030;
}
.modal-actions #btn-upgrade-ok {
  background-color: #3182ce;
}
.modal-actions #btn-upgrade-ok:hover {
  background-color: #2b6cb0;
}
.modal-actions #btn-upgrade-ok:disabled {
  background-color: #a0aec0;
  cursor: not-allowed;
}
.modal-actions .upgrade-cancel-plan {
  margin-right: auto;
  color: #c53030;
  border-color: #feb2b2;
}
.modal-actions .upgrade-cancel-plan:hover {
  background: #fff5f5;
  color: #9b2c2c;
}
.upgrade-dialog {
  max-width: 440px;
}
.upgrade-plan-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 20px;
}
.upgrade-plan-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid #cbd5e0;
  border-radius: 8px;
  cursor: pointer;
  background: #fff;
}
.upgrade-plan-option:hover {
  border-color: #3182ce;
}
.upgrade-plan-option.is-selected {
  border-color: #3182ce;
  background: #ebf8ff;
}
.upgrade-plan-option input {
  margin-top: 3px;
}
.upgrade-plan-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.upgrade-plan-meta strong {
  color: #2d3748;
  font-size: 0.95rem;
}
.upgrade-plan-meta span {
  color: #718096;
  font-size: 0.85rem;
}
#form-create-customer {
  margin-bottom: 0;
}
#form-create-customer .modal-actions {
  margin-top: 4px;
}
.autocomplete-create {
  color: #3182ce;
  font-weight: 600;
  border-top: 1px solid #bee3f8;
  background: #ebf8ff;
}
.autocomplete-create:hover {
  background-color: #bee3f8 !important;
}
.autocomplete-active.autocomplete-create {
  background-color: #3182ce !important;
  color: #fff;
}

/* ==========================================================================
   6. Autocomplete List
   ========================================================================== */
.autocomplete-items {
  position: absolute;
  z-index: 99;
  width: 100%;
  left: 0;
  top: 100%;
  margin-top: 4px;
  background-color: white;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  max-height: 300px;
  overflow-y: auto;
}
.autocomplete-items div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px;
  cursor: pointer;
  border-bottom: 1px solid #edf2f7;
}
.autocomplete-items div:last-child {
  border-bottom: none;
}
.autocomplete-items div:hover {
  background-color: #f7fafc;
}
.autocomplete-active {
  background-color: #4a5568 !important;
  color: #ffffff;
}
.autocomplete-active .autocomplete-order-id,
.autocomplete-active .autocomplete-email {
  color: #e2e8f0;
}
.autocomplete-order-id {
  font-weight: 600;
  white-space: nowrap;
  color: #4a5568;
}
.autocomplete-name {
  flex-grow: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.autocomplete-email {
  color: #718096;
  font-size: 0.9em;
  white-space: nowrap;
}
.autocomplete-count {
  background-color: #edf2f7;
  color: #4a5568;
  font-size: 0.85em;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  white-space: nowrap;
  margin-left: auto;
}

/* ==========================================================================
   7. Sidebar & History
   ========================================================================== */
details {
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 10px;
}
summary {
  font-weight: 600;
  cursor: pointer;
  color: #2d3748;
}
.instructions ol {
  padding-left: 20px;
  line-height: 1.6;
  color: #4a5568;
}
.instructions code {
  background-color: #edf2f7;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}
.activity-log-container {
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 15px;
  margin-top: 20px;
}
#activity-log {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 400px;
  overflow-y: auto;
  font-size: 0.9em;
}
#activity-log li {
  background-color: #fff;
  padding: 10px;
  border-bottom: 1px solid #e2e8f0;
  animation: fadeIn 0.5s ease-in-out;
}
.log-product {
  font-weight: 600;
  color: #2d3748;
}
.log-details {
  font-size: 0.9em;
  color: #718096;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}
.history-header h2 {
  margin: 0;
}
.history-header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.session-select-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #4a5568;
  margin: 0;
}
#session-select {
  min-width: 160px;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
}
#btn-clear-history:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.history-search {
  width: 100%;
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.history-search:focus {
  border-color: #90cdf4;
  background: #ebf8ff;
  outline: none;
}
#form-save-session .modal-actions {
  margin-top: 8px;
}
.history-container {
  min-width: 0;
  max-width: 100%;
}
#history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
#history-list li {
  background: #f7fafc;
  border-radius: 6px;
  padding: 10px;
  border: 1px solid #e2e8f0;
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  align-items: center;
  box-sizing: border-box;
  min-width: 36rem;
}
#history-list li.history-item {
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
#history-list li.history-item:hover,
#history-list li.history-item:focus-visible {
  border-color: #90cdf4;
  background: #ebf8ff;
  outline: none;
}
#history-list li input {
  background-color: #fff;
  border: 1px solid #e2e8f0;
  padding: 8px;
  text-align: left;
  font-size: 14px;
  border-radius: 4px;
  pointer-events: none;
  flex-shrink: 0;
  white-space: nowrap;
}
#history-list li.history-empty {
  justify-content: center;
  color: #718096;
  font-size: 14px;
  border-style: dashed;
  cursor: default;
  min-width: 0;
  width: 100%;
}
.modal-actions #btn-history-detail-undo {
  width: auto;
  margin-top: 0;
  padding: 10px 18px;
}
.history-detail-dialog {
  max-width: 440px;
}
.history-detail-image {
  display: block;
  width: min(250px, 100%);
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  background: #e2e8f0;
  margin: 0 auto 16px;
}
.history-detail-list {
  margin: 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.history-detail-list > div {
  display: grid;
  grid-template-columns: minmax(5.5em, 7.5em) minmax(0, 1fr);
  gap: 8px 12px;
  align-items: baseline;
}
.history-detail-list dt {
  margin: 0;
  font-size: 0.85em;
  font-weight: 600;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.history-detail-list dd {
  margin: 0;
  color: #2d3748;
  font-size: 0.95em;
  word-break: break-word;
  overflow-wrap: anywhere;
}
@media (max-width: 420px) {
  .modal-overlay {
    padding: 12px;
  }
  .modal-dialog {
    padding: 16px;
  }
  .history-detail-list > div {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .history-detail-dialog .modal-actions {
    flex-direction: column-reverse;
  }
  .history-detail-dialog .modal-actions button {
    width: 100%;
  }
}
#history-list li input.history-sku {
  flex: 1.2 0 9em;
}
#history-list li input.history-quantity {
  flex: 0 0 4.5em;
  text-align: center;
}
#history-list li input.history-customer {
  flex: 1.6 0 10em;
}
#history-list li input.history-expiry {
  flex: 0 0 11em;
  font-size: 12px;
  color: #718096;
  text-align: right;
}
.history-expired-tag {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #9b2c2c;
  background: #fff5f5;
  border: 1px solid #feb2b2;
  border-radius: 4px;
  padding: 2px 6px;
  line-height: 1.2;
}
.history-new-marker {
  flex: 0 0 1.1em;
  font-weight: 700;
  color: #c05621;
  text-align: center;
  line-height: 1;
}
.history-new-marker--empty {
  visibility: hidden;
}
.history-created {
  border-color: #fbd38d;
  background: #fffaf0;
}
.history-expired {
  border-color: #feb2b2;
  background: #fff5f5;
}
.history-detail-status-expired {
  color: #9b2c2c;
  font-weight: 700;
}

/* (usage badge styles live under header) */
/* END OF FILE style.css */
