/*
  Shared BookTraq components.
  Apps should override these via local variables or local selectors,
  not by editing shared files per product.
*/

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-md);
  background: var(--theme-surface-alt);
}

.theme-toggle span {
  color: var(--theme-muted);
  font-family: var(--theme-font-mono);
  font-size: 20px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.theme-toggle select {
  min-width: 100px;
}

.logo {
  font-size: 45px;
  font-weight: 800;
  letter-spacing: -1px;
  font-family: var(--theme-font-heading);
}

.logo span {
  color: var(--theme-accent);
}

.tagline {
  margin-top: 4px;
  font-family: var(--theme-font-mono);
  font-size: 20px;
  color: var(--theme-muted);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.header-rule {
  height: 1px;
  background: linear-gradient(90deg, var(--theme-accent) 0%, transparent 60%);
  margin-bottom: 36px;
}

.upload-grid,
.mapping-grid {
  display: grid;
  gap: 16px;
}

.card,
.upload-card,
.mapping-section,
.results-panel {
  background: var(--theme-surface);
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-lg);
  box-shadow: var(--theme-shadow);
}

.card,
.upload-card,
.mapping-section {
  padding: var(--theme-card-padding);
}

.upload-card {
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s;
}

.upload-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--theme-accent-2), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

.upload-card.has-file::before {
  opacity: 1;
}

.upload-card.has-file {
  border-color: var(--theme-accent-2);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.card-label {
  margin-bottom: 12px;
  color: var(--theme-muted);
  font-family: var(--theme-font-mono);
  font-size: 20px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.card-title {
  margin: 0 0 4px;
  font-size: 27px;
  font-weight: 700;
  font-family: var(--theme-font-heading);
}

.card-sub {
  margin: 0 0 16px;
  color: var(--theme-muted);
  font-size: 21px;
}

.panel-title,
.mapping-title {
  margin: 0 0 14px;
  font-size: 21px;
  font-weight: 700;
  color: var(--theme-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.chip {
  padding: 6px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--theme-accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--theme-accent) 18%, transparent);
  color: var(--theme-accent);
  font-family: var(--theme-font-mono);
  font-size: 20px;
  white-space: nowrap;
}

.drop-zone {
  position: relative;
  border: 1.5px dashed var(--theme-border);
  border-radius: var(--theme-radius-md);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--theme-accent);
  background: color-mix(in srgb, var(--theme-accent) 4%, transparent);
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.drop-icon {
  margin-bottom: 6px;
  font-size: 36px;
}

.drop-text {
  color: var(--theme-muted);
  font-size: 21px;
}

.drop-text strong {
  color: var(--theme-text);
}

.file-badge,
.file-meta,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--theme-radius-sm);
  font-family: var(--theme-font-mono);
  font-size: 20px;
}

.file-badge {
  margin-top: 8px;
  background: color-mix(in srgb, var(--theme-accent-2) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--theme-accent-2) 30%, transparent);
  color: var(--theme-accent-2);
}

.file-meta {
  margin-top: 12px;
  background: color-mix(in srgb, var(--theme-success) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--theme-success) 20%, transparent);
  color: var(--theme-success);
}

.status-badge {
  background: color-mix(in srgb, var(--theme-surface-alt) 84%, transparent);
  border: 1px solid color-mix(in srgb, var(--theme-border) 92%, transparent);
  color: var(--theme-text);
}

.mapping-section {
  display: none;
}

.mapping-section.visible {
  display: block;
}

.mapping-grid {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.field-group label,
label {
  display: block;
  margin-bottom: 4px;
  color: var(--theme-muted);
  font-family: var(--theme-font-mono);
  font-size: 20px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.field-group select,
select,
input[type="number"],
input[type="text"] {
  width: 100%;
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-sm);
  background: var(--theme-field-bg);
  color: var(--theme-field-text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field-group select,
select {
  padding: 8px 10px;
  font-family: var(--theme-font-mono);
  font-size: 21px;
  cursor: pointer;
}

input[type="number"],
input[type="text"] {
  padding: 9px 10px;
  font-size: 21px;
}

.field-group select:focus,
select:focus,
input[type="number"]:focus,
input[type="text"]:focus {
  border-color: var(--theme-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-accent) 12%, transparent);
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  border: none;
  border-radius: var(--theme-radius-md);
  background: transparent;
  color: inherit;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.15s;
}

button:hover:not(:disabled),
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled,
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--theme-accent);
  color: var(--theme-accent-contrast);
}

.btn-primary:hover:not(:disabled) {
  background: #00ffb3;
}

.btn-primary:disabled {
  background: var(--theme-border);
  color: var(--theme-muted);
  opacity: 1;
}

.btn-secondary {
  background: var(--theme-surface);
  color: var(--theme-text);
  border: 1px solid var(--theme-border);
}

.btn-dl {
  background: var(--theme-surface);
  color: var(--theme-accent-2);
  border: 1px solid var(--theme-accent-2);
}

.btn-dl:hover:not(:disabled) {
  background: color-mix(in srgb, var(--theme-accent-2) 10%, transparent);
}

.btn-dl:disabled {
  opacity: 0.3;
}

.btn-warn {
  background: color-mix(in srgb, var(--theme-danger) 8%, transparent);
  color: var(--theme-danger);
  border: 1px solid color-mix(in srgb, var(--theme-danger) 16%, transparent);
}

.kpi {
  border: 1px solid var(--theme-border);
  border-radius: var(--theme-radius-md);
  background: var(--theme-surface);
  padding: 14px 12px;
  text-align: center;
  transition: border-color 0.2s;
}

.kpi-num {
  font-family: var(--theme-font-mono);
  font-size: 39px;
  font-weight: 800;
}

.kpi-label {
  margin-top: 2px;
  color: var(--theme-muted);
  font-size: 16px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.kpi-sub {
  margin-top: 8px;
  color: var(--theme-muted);
  font-size: 18px;
  line-height: 1.45;
}

.kpi.matched,
.kpi[data-tone="matched"] {
  border-top: 2px solid var(--theme-accent);
}

.kpi.mismatch,
.kpi[data-tone="journal"] {
  border-top: 2px solid var(--theme-warn);
}

.kpi.stmt-only,
.kpi[data-tone="exception"] {
  border-top: 2px solid var(--theme-danger);
}

.kpi.sch-only,
.kpi[data-tone="bank"] {
  border-top: 2px solid var(--theme-accent-2);
}

.kpi.ambig,
.kpi[data-tone="batch"] {
  border-top: 2px solid #a855f7;
}

.kpi.parse,
.kpi[data-tone="outstanding"] {
  border-top: 2px solid var(--theme-muted);
}

.tab-bar,
.tab-strip {
  display: flex;
  gap: 2px;
  margin-bottom: 0;
  overflow-x: auto;
}

.tab-bar {
  border-bottom: 1px solid var(--theme-border);
}

.tab-btn {
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--theme-muted);
  padding: 10px 16px;
  font-size: 20px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--theme-text);
}

.tab-btn.active {
  color: var(--theme-accent);
  border-bottom-color: var(--theme-accent);
}

.tab-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--theme-surface-alt);
  color: var(--theme-muted);
  font-family: var(--theme-font-mono);
  font-size: 16px;
}

.tab-btn.active .tab-badge {
  background: color-mix(in srgb, var(--theme-accent) 15%, transparent);
  color: var(--theme-accent);
}

.results-panel {
  overflow: hidden;
  display: none;
  margin-bottom: 24px;
  border-top-left-radius: 0;
}

.results-panel.visible {
  display: block;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: var(--theme-table-max-height);
}

.table-wrap table {
  min-width: 100%;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 11px 12px;
  background: var(--theme-table-header-bg);
  border-bottom: 1px solid var(--theme-border);
  color: var(--theme-muted);
  font-family: var(--theme-font-mono);
  font-size: 20px;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid color-mix(in srgb, var(--theme-text) 4%, transparent);
  transition: background 0.1s;
}

tbody tr:hover {
  background: var(--theme-table-row-hover);
}

tbody td {
  padding: 11px 12px;
  white-space: nowrap;
  font-size: 21px;
}

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 16px;
  letter-spacing: 0.5px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-green,
.badge.success {
  background: color-mix(in srgb, var(--theme-success) 12%, transparent);
  color: var(--theme-success);
}

.badge-blue,
.badge.info {
  background: color-mix(in srgb, var(--theme-accent-2) 12%, transparent);
  color: var(--theme-accent-2);
}

.badge-warn,
.badge.warn {
  background: color-mix(in srgb, var(--theme-warn) 12%, transparent);
  color: var(--theme-warn);
}

.badge-danger,
.badge.danger {
  background: color-mix(in srgb, var(--theme-danger) 12%, transparent);
  color: var(--theme-danger);
}

.empty,
.empty-state {
  padding: 48px;
  text-align: center;
  color: var(--theme-muted);
  font-size: 21px;
}

@media (max-width: 720px) {
  .header,
  .card-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions,
  .theme-toggle {
    width: 100%;
  }

  .theme-toggle {
    justify-content: space-between;
  }

  .theme-toggle select {
    width: 100%;
  }
}

/* ── Button Tooltips (shared, both apps) ───────────────────────── */
/* Add data-tooltip="..." to any button for a hover tooltip        */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  background: rgba(30, 30, 35, 0.92);
  color: #fff;
  font-size: 18px;
  font-weight: 400;
  line-height: 1.4;
  width: max-content;
  max-width: min(420px, calc(100vw - 32px));
  white-space: normal;
  padding: 10px 12px;
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 300;
  text-align: left;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* ── Click Help Tips / Popovers (shared) ────────────────────────── */
.help-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--theme-muted, #888);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  font-style: normal;
  cursor: pointer;
  margin-left: 6px;
  vertical-align: middle;
  flex-shrink: 0;
  user-select: none;
  position: relative;
  line-height: 1;
}

.help-tip:hover {
  background: var(--theme-accent, #2563eb);
}

.help-tip-popover {
  display: none;
  position: absolute;
  z-index: 300;
  top: calc(100% + 10px);
  left: 50%;
  width: min(460px, calc(100vw - 32px));
  transform: translateX(-50%);
  background: var(--theme-surface, #fff);
  border: 1px solid var(--theme-border, #ddd);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 18px;
  line-height: 1.45;
  color: var(--theme-text, #222);
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
  white-space: normal;
  font-weight: 400;
  font-style: normal;
  text-transform: none;
  letter-spacing: 0;
  cursor: default;
}

.help-tip-popover.is-open {
  display: block;
}

.help-tip.flip-left .help-tip-popover {
  left: auto;
  right: 0;
  transform: none;
}

.help-tip.flip-right .help-tip-popover {
  left: 0;
  right: auto;
  transform: none;
}

.help-tip.open-above .help-tip-popover {
  top: auto;
  bottom: calc(100% + 10px);
}
