/* ── Toolbar ── */

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  margin-bottom: 12px;
  flex-wrap: wrap;
  max-width: calc(var(--columns) * var(--label-width) + (var(--columns) - 1) * var(--gutter-x));
  margin-left: auto;
  margin-right: auto;
}

.toolbar select,
.toolbar button {
  font-family: "roboto-condensed", sans-serif;
  font-size: 13px;
  padding: 6px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

.toolbar button:hover {
  background: #f0f0f0;
}

.toolbar button.primary {
  background: #2285f5;
  color: #fff;
  border-color: #2285f5;
}

.toolbar button.primary:hover {
  background: #1a6fd4;
}

.toolbar .spacer {
  flex: 1;
}

/* ── Toggle switch ── */
.toggleVisible {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 200;
}

.toggleVisible input.tog {
  display: none;
}

.toggleVisible label.tog {
  display: block;
  width: 36px;
  height: 18px;
  border: 4px solid #cacaca;
  background: #cacaca;
  cursor: pointer;
  border-radius: 10px;
}

.toggleVisible label.tog::before {
  content: "";
  display: block;
  width: 50%;
  height: 100%;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s ease;
}

.toggleVisible input.tog:checked + label.tog {
  border-color: #2285f5;
  background: #2285f5;
}

.toggleVisible input.tog:checked + label.tog::before {
  transform: translateX(100%);
}

/* ── Per-label copy button ── */
.copy-btn {
  position: absolute;
  bottom: 4px;
  left: 4px;
  z-index: 200;
  background: #f5f5f5;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  font-size: 11px;
  font-family: "roboto-condensed", sans-serif;
  color: #555;
}

.copy-btn:hover {
  background: #e0e0e0;
}

/* ── Copy dropdown ── */
.copy-dropdown {
  position: absolute;
  bottom: 28px;
  left: 4px;
  z-index: 300;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  min-width: 150px;
  overflow: hidden;
}

.copy-dropdown-item {
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: "roboto-condensed", sans-serif;
  white-space: nowrap;
}

.copy-dropdown-item:hover {
  background: #f0f7ff;
}

/* ── Per-label picker button ── */
.picker-btn {
  position: absolute;
  bottom: 4px;
  right: 4px;
  z-index: 200;
  background: #f5f5f5;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  font-size: 11px;
  font-family: "roboto-condensed", sans-serif;
  color: #555;
}

.picker-btn:hover {
  background: #e0e0e0;
}

/* ── Material picker dropdown ── */
.picker-dropdown {
  position: absolute;
  bottom: 28px;
  right: 4px;
  z-index: 300;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  width: 280px;
  max-height: 300px;
  display: none;
  flex-direction: column;
}

.picker-dropdown.open {
  display: flex;
}

.picker-dropdown .picker-search {
  padding: 8px;
  border-bottom: 1px solid #eee;
}

.picker-dropdown .picker-search input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: "roboto-condensed", sans-serif;
  font-size: 12px;
  outline: none;
}

.picker-dropdown .picker-search input:focus {
  border-color: #2285f5;
}

.picker-dropdown .picker-list {
  overflow-y: auto;
  flex: 1;
  max-height: 240px;
}

.picker-dropdown .picker-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  border-bottom: 1px solid #f5f5f5;
}

.picker-dropdown .picker-item:hover {
  background: #f0f7ff;
}

.picker-dropdown .picker-item .picker-item-name {
  font-weight: 700;
  margin-bottom: 2px;
}

.picker-dropdown .picker-item .picker-item-detail {
  color: #888;
  font-size: 11px;
}

.picker-dropdown .picker-empty {
  padding: 16px;
  text-align: center;
  color: #999;
  font-size: 12px;
}

/* ── Library management dialog ── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.dialog-overlay.open {
  display: flex;
}

.dialog {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  width: 600px;
  max-width: 95vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
}

.dialog-header h2 {
  margin: 0;
  font-size: 16px;
  font-family: "roboto-condensed", sans-serif;
}

.dialog-header .close-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #999;
  padding: 0 4px;
}

.dialog-header .close-btn:hover {
  color: #333;
}

.dialog-toolbar {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid #eee;
  flex-wrap: wrap;
  align-items: center;
}

.dialog-toolbar input[type="search"] {
  flex: 1;
  min-width: 150px;
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: "roboto-condensed", sans-serif;
  font-size: 13px;
  outline: none;
}

.dialog-toolbar input[type="search"]:focus {
  border-color: #2285f5;
}

.dialog-toolbar button {
  font-family: "roboto-condensed", sans-serif;
  font-size: 12px;
  padding: 5px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  white-space: nowrap;
}

.dialog-toolbar button:hover {
  background: #f0f0f0;
}

.dialog-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.dialog-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.dialog-body table th {
  position: sticky;
  top: 0;
  background: #fafafa;
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid #eee;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  color: #888;
}

.dialog-body table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: top;
}

.dialog-body table tr:hover td {
  background: #f8f9ff;
}

.dialog-body .entry-name {
  font-weight: 700;
}

.dialog-body .entry-actions {
  white-space: nowrap;
}

.dialog-body .entry-actions button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: #2285f5;
  padding: 2px 6px;
  font-family: "roboto-condensed", sans-serif;
}

.dialog-body .entry-actions button:hover {
  text-decoration: underline;
}

.dialog-body .entry-actions button.delete {
  color: #d32f2f;
}

.dialog-body .empty-state {
  padding: 40px 20px;
  text-align: center;
  color: #999;
}

.dialog-footer {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid #eee;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.dialog-footer button {
  font-family: "roboto-condensed", sans-serif;
  font-size: 12px;
  padding: 6px 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

.dialog-footer button:hover {
  background: #f0f0f0;
}

.dialog-footer button.destructive {
  color: #d32f2f;
  border-color: #e7a5a5;
}

.dialog-footer button.destructive:hover {
  background: #fdecec;
}

/* ── Entry edit form (inline in dialog) ── */
.entry-form {
  padding: 20px;
}

.entry-form .form-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}

.entry-form .form-row label {
  width: 80px;
  font-size: 12px;
  font-weight: 700;
  text-align: right;
  flex-shrink: 0;
}

.entry-form .form-row input,
.entry-form .form-row textarea {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: "roboto-condensed", sans-serif;
  font-size: 13px;
  outline: none;
}

.entry-form .form-row input:focus,
.entry-form .form-row textarea:focus {
  border-color: #2285f5;
}

.entry-form .form-row textarea {
  resize: vertical;
  min-height: 40px;
}

.entry-form .form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

.entry-form .form-actions button {
  font-family: "roboto-condensed", sans-serif;
  font-size: 13px;
  padding: 6px 16px;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
}

.entry-form .form-actions button.save {
  background: #2285f5;
  color: #fff;
  border-color: #2285f5;
}

.entry-form .form-actions button.save:hover {
  background: #1a6fd4;
}

/* ── Calibration inputs ── */
.calibration {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #666;
}

.calibration label {
  font-size: 11px;
}

.calibration input[type="number"] {
  width: 60px;
  padding: 3px 6px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-family: "roboto-condensed", sans-serif;
  font-size: 12px;
  text-align: center;
}

/* ── Gist sync ── */
.gist-section {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
}

.gist-section input[type="password"] {
  width: 200px;
  padding: 5px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: "roboto-condensed", sans-serif;
  font-size: 12px;
}

.gist-status {
  font-size: 11px;
  color: #666;
}

/* ── Page navigation bar ── */
.page-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  max-width: calc(var(--columns) * var(--label-width) + (var(--columns) - 1) * var(--gutter-x));
  margin: 0 auto 8px;
  font-family: "roboto-condensed", sans-serif;
  font-size: 13px;
}

.page-nav button {
  font-family: "roboto-condensed", sans-serif;
  font-size: 13px;
  padding: 5px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

.page-nav button:hover:not(:disabled) {
  background: #f0f0f0;
}

.page-nav button:disabled {
  opacity: 0.4;
  cursor: default;
}

#page-indicator {
  font-weight: 700;
  min-width: 100px;
  text-align: center;
}

#btn-batch-clear {
  margin-left: auto;
  color: #d32f2f;
  border-color: #d32f2f;
}

#btn-batch-clear:hover {
  background: #fef0f0;
}

/* ── Batch import dialog ── */
.batch-body {
  padding: 20px;
}

.batch-help {
  margin: 0 0 12px;
  font-size: 13px;
  color: #666;
  line-height: 1.4;
}

#batch-textarea {
  width: 100%;
  min-height: 200px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: "roboto-condensed", monospace;
  font-size: 12px;
  resize: vertical;
  outline: none;
}

#batch-textarea:focus {
  border-color: #2285f5;
}

.batch-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.batch-actions button {
  font-family: "roboto-condensed", sans-serif;
  font-size: 13px;
  padding: 6px 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

.batch-actions button:hover {
  background: #f0f0f0;
}

.batch-actions button.primary {
  background: #2285f5;
  color: #fff;
  border-color: #2285f5;
}

.batch-actions button.primary:hover {
  background: #1a6fd4;
}

.batch-preview {
  font-size: 13px;
  color: #2285f5;
  font-weight: 700;
}

/* ── Dialog tabs ── */
.dialog-tabs {
  display: flex;
  border-bottom: 2px solid #eee;
  padding: 0 20px;
}

.dialog-tabs .tab {
  font-family: "roboto-condensed", sans-serif;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 20px;
  border: none;
  background: none;
  cursor: pointer;
  color: #888;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.dialog-tabs .tab:hover {
  color: #333;
}

.dialog-tabs .tab.active {
  color: #2285f5;
  border-bottom-color: #2285f5;
}

/* ── Catalog products header ── */
.catalog-products-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid #eee;
}

.catalog-products-header h3 {
  margin: 0;
  font-size: 15px;
  font-family: "roboto-condensed", sans-serif;
}

.catalog-products-header button {
  font-family: "roboto-condensed", sans-serif;
  font-size: 12px;
  padding: 5px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

.catalog-products-header button:hover {
  background: #f0f0f0;
}

/* ── Autocomplete dropdown ── */
.ac-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 500;
  background: #fff;
  border: 1px solid #ccc;
  border-top: none;
  border-radius: 0 0 4px 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  max-height: 220px;
  overflow-y: auto;
}

.ac-group {
  padding: 6px 10px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #999;
  background: #fafafa;
  border-top: 1px solid #eee;
}

.ac-group:first-child {
  border-top: none;
}

.ac-item {
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  font-family: "roboto-condensed", sans-serif;
}

.ac-item:hover,
.ac-item.ac-highlighted {
  background: #f0f7ff;
}

.ac-item-action {
  color: #0a66c2;
  font-style: italic;
  border-top: 1px dashed #e0e0e0;
}

/* ── Common Fields sidebar ── */
.common-sidebar {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 12px;
  align-self: flex-start;
  background: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 16px;
}

.common-sidebar h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-family: "roboto-condensed", sans-serif;
  font-weight: 700;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cf-group {
  margin-bottom: 10px;
}

.cf-group label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #666;
  margin-bottom: 3px;
  font-family: "roboto-condensed", sans-serif;
}

.cf-group input,
.cf-group textarea {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: "roboto-condensed", sans-serif;
  font-size: 12px;
  outline: none;
  resize: vertical;
}

.cf-group input:focus,
.cf-group textarea:focus {
  border-color: #2285f5;
}

.cf-group textarea {
  min-height: 36px;
}

/* ── Recent entries in sidebar ── */
.cf-recent {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #ddd;
}

.cf-recent h4 {
  margin: 0 0 8px;
  font-size: 11px;
  font-family: "roboto-condensed", sans-serif;
  font-weight: 700;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cf-recent-item {
  padding: 4px 8px;
  font-size: 12px;
  font-family: "roboto-condensed", sans-serif;
  cursor: pointer;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #333;
}

.cf-recent-item:hover {
  background: #e8f0fe;
}

.cf-recent-empty {
  font-size: 11px;
  color: #aaa;
  padding: 4px 8px;
}

/* ── Print: hide all controls ── */
@media print {
  .toolbar,
  .dialog-overlay,
  .picker-dropdown,
  .picker-btn,
  .copy-btn,
  .copy-dropdown,
  .toggleVisible,
  .calibration,
  .page-nav,
  .ac-dropdown,
  .common-sidebar {
    display: none !important;
  }
}
