/* Transaction Controls Toolbar */
.transaction-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 20px;
  background: rgba(0, 0, 0, 0.2);
  padding: 15px;
  border-radius: 8px;
  align-items: flex-start; /* Changed from flex-end to align top for taller filters */
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.control-label {
  font-size: 0.85em;
  color: #f0ad4e;
  font-weight: bold;
  text-transform: uppercase;
}

.control-inputs {
  display: flex;
  gap: 10px;
}

.transaction-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-self: flex-start;
  margin-top: 22px;
  min-width: 220px;
}

.transaction-actions__primary,
.transaction-actions__secondary {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.transaction-actions__primary:empty {
  display: none;
}

.transaction-actions__primary .action-btn,
.transaction-actions__secondary .secondary-btn {
  width: 100%;
}

.transactions-filters-disclosure-mount {
  flex: 1 1 420px;
  min-width: 0;
}

.transactions-filters-disclosure {
  width: 100%;
}

.transactions-filter-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Tag Filters Section (Ported from Analysis) */
.tag-filters-container {
  display: flex; /* Changed from grid to flex for toolbar layout */
  gap: 15px;
}

.tag-filter-column {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 200px; /* Ensure enough width */
}

.tag-filter-header {
  font-size: 0.85em;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.tag-search-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  background-color: rgba(0, 0, 0, 0.2);
  color: #fff;
  font-size: 0.85em;
  box-sizing: border-box;
}

.tag-search-input:focus {
  outline: none;
  border-color: #f0ad4e;
}

.tag-selector {
  height: 150px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  background-color: #1a6b10;
  padding: 5px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.tag-checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.9em;
}

.tag-checkbox-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.tag-checkbox-item input[type="checkbox"] {
  accent-color: #f0ad4e;
  cursor: pointer;
}

.transactions-description-search {
  margin-bottom: 15px;
}

.transactions-description-search__input {
  width: 100%;
  padding: 12px;
  box-sizing: border-box;
  font-size: 1em;
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.2);
}

.transactions-mobile-list {
  display: none;
}

.transactions-mobile-selection-bar {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid rgba(240, 173, 78, 0.16);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.16);
}

.transactions-mobile-selection-bar__count {
  color: #f7d7a0;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.transactions-mobile-selection-bar__actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.transactions-mobile-selection-bar__actions .secondary-btn {
  width: 100%;
  min-height: 40px;
}

.transaction-mobile-card .mobile-data-card__detail-value {
  display: inline-flex;
  justify-content: flex-end;
  align-items: center;
}

.transaction-mobile-card .mobile-data-card__metrics {
  grid-template-columns: 1fr;
}

.transaction-mobile-card__amount-metric {
  background: rgba(0, 0, 0, 0.24);
}

.transaction-mobile-card__split-badge {
  background: rgba(91, 192, 222, 0.16);
  color: #9fe4f5;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.transaction-mobile-card__split-id {
  font-family: monospace;
  color: rgba(255, 255, 255, 0.78);
}

.transaction-mobile-card__checkbox {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.transaction-mobile-card__checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #f0ad4e;
}

.transaction-mobile-card--selected {
  border-color: rgba(240, 173, 78, 0.48);
  box-shadow: 0 0 0 1px rgba(240, 173, 78, 0.18);
}

.transaction-mobile-card__empty-value {
  color: rgba(255, 255, 255, 0.58);
  font-size: 0.9rem;
}

.transactions-mobile-empty-state {
  margin-top: 2px;
}

/* Theme Select Dropdown */
.theme-select {
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  background-color: #1a6b10;
  color: #fff;
  font-size: 0.9em;
  cursor: pointer;
  transition: border-color 0.3s ease;
  box-sizing: border-box;
  height: 38px;
}

.theme-select:focus {
  outline: none;
  border-color: #f0ad4e;
}

.theme-select.wide {
  min-width: 120px;
}

/* Theme Input (Matches Select) */
.theme-input {
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  background-color: rgba(0, 0, 0, 0.2);
  color: #fff;
  font-size: 0.9em;
  width: 100%;
  box-sizing: border-box;
  height: 38px;
}

.theme-input:focus {
  outline: none;
  border-color: #f0ad4e;
}

/* Form Group Spacing */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.9em;
  color: #ddd;
}

/* Specific override for Manual Transaction Type */
#manual-type {
  background-color: #f0ad4e;
  color: #000; /* Black text for better contrast on orange */
  border-color: #f0ad4e;
}

/* Bulk Actions Toolbar */
.bulk-actions-toolbar {
  display: none; /* Hidden by default */
  background: rgba(240, 173, 78, 0.15);
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
  border: 1px solid #f0ad4e;
}

.bulk-actions-content {
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap;
}

.bulk-label {
  color: #f0ad4e;
  font-weight: bold;
}

.selection-count {
  font-size: 0.9em;
  color: #ddd;
}

/* Custom Dropdown in Bulk Actions */
.custom-dropdown {
  position: relative;
  display: inline-block;
  min-width: 200px;
}

.dropdown-trigger {
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  background-color: #1a6b10;
  color: #fff;
  font-size: 0.9em;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-trigger:hover {
  border-color: #f0ad4e;
}

.dropdown-trigger::after {
  content: "▼";
  font-size: 0.7em;
  margin-left: 10px;
  color: rgba(255, 255, 255, 0.7);
}

.dropdown-content {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  min-width: 250px; /* Slightly wider for search */
  background-color: #2a4d25; /* Slightly different bg to pop out */
  border: 1px solid #f0ad4e;
  border-radius: 4px;
  padding: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  margin-top: 5px;
}

.dropdown-content .tag-selector {
  height: 200px;
  margin-top: 8px;
  background-color: rgba(0, 0, 0, 0.2);
}

.tag-item-option {
  display: block;
  padding: 6px 10px;
  cursor: pointer;
  color: #fff;
  border-radius: 3px;
  margin-bottom: 2px;
}

.tag-item-option:hover,
.tag-item-option.focused {
  background-color: rgba(255, 255, 255, 0.1);
}

.tag-item-option.selected {
  background-color: #f0ad4e;
  color: #000;
  font-weight: bold;
}

/* Table Selection */
.row-select {
  cursor: pointer;
  width: 16px;
  height: 16px;
}

#select-all-header {
  display: none; /* Hidden by default */
  width: 40px;
  text-align: center;
}

/* Disabled state for main controls */
.transaction-controls.disabled {
  opacity: 0.5;
  pointer-events: none;
}

@media (max-width: 768px) {
  .transaction-controls {
    gap: var(--mobile-control-gap, 12px);
    padding: var(--mobile-section-padding-y, 12px)
      var(--mobile-section-padding-x, 14px);
  }

  .transactions-filters-disclosure-mount,
  .transaction-actions {
    width: 100%;
    flex: 1 1 100%;
  }

  .transaction-actions {
    margin-top: 0;
    min-width: 0;
    gap: 8px;
  }

  .transaction-actions__primary .action-btn {
    min-height: var(--mobile-control-height, 38px);
  }

  .transaction-actions__secondary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .transaction-actions__secondary .secondary-btn {
    min-height: var(--mobile-control-height, 38px);
    padding: 8px 10px;
  }

  .transactions-filter-body {
    gap: var(--mobile-control-gap, 12px);
  }

  .tag-filters-container {
    flex-direction: column;
    gap: 12px;
  }

  .tag-filter-column {
    min-width: 0;
    gap: 4px;
  }

  .tag-filter-header {
    font-size: 0.78em;
    margin-bottom: 0;
  }

  .tag-search-input {
    padding: 5px 8px;
    font-size: 0.82em;
  }

  .tag-selector {
    height: 112px;
    padding: 4px;
  }

  .tag-checkbox-item {
    gap: 6px;
    padding: 3px 6px;
    font-size: 0.85em;
  }

  .transactions-description-search {
    margin-bottom: 12px;
  }

  .transactions-description-search__input {
    padding: 8px 10px;
    font-size: 0.9em;
  }

  #transactions-table-container {
    display: none;
  }

  .transactions-mobile-list {
    display: block;
  }

  .transactions-mobile-card-list {
    gap: 10px;
  }
}

/* Split History Grouping Styles */
.split-group-header {
  cursor: pointer;
  background-color: rgba(255, 255, 255, 0.05);
  transition: background-color 0.2s;
}
.split-group-header:hover {
  background-color: rgba(255, 255, 255, 0.1);
}
.split-group-expanded {
  background-color: rgba(240, 173, 78, 0.1);
  border-left: 4px solid #f0ad4e;
}
.split-group-details {
  display: none;
  background-color: rgba(0, 0, 0, 0.2);
}
.split-group-details.active {
  display: table-row;
}
.split-detail-table {
  width: 98%;
  margin: 10px auto;
  border-collapse: collapse;
  background-color: rgba(0, 0, 0, 0.1);
}
.split-detail-row {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.split-detail-row:last-child {
  border-bottom: none;
}
.split-toggle-icon {
  display: inline-block;
  width: 20px;
  text-align: center;
  transition: transform 0.2s;
}
.split-group-expanded .split-toggle-icon {
  transform: rotate(90deg);
}

/* Split History Modal Styles - CSP Compliant */
.split-history-empty {
  text-align: center;
  padding: 20px;
  color: #aaa;
}

.split-reverted-label {
  color: #aaa;
  font-size: 0.8em;
}

.split-detail-row.split-row-source {
  background: rgba(255, 0, 0, 0.1);
}

.split-detail-row.split-row-child {
  background: rgba(0, 255, 0, 0.05);
}

.split-detail-clickable {
  cursor: pointer;
}

.split-cell-padding {
  padding: 8px;
}

.split-header-toggle-cell {
  width: 40px;
  text-align: center;
}

.split-group-id {
  font-family: monospace;
  color: #888;
}

.split-details-container {
  padding: 0;
}

.split-details-wrapper {
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
}

.split-detail-header-row {
  color: #aaa;
  font-size: 0.85em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.split-detail-th {
  text-align: left;
  padding: 5px;
}

.modal-content.split-modal-content {
  width: 95%;
  max-width: 1200px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.split-modal-body {
  overflow-y: auto;
  padding: 0;
}

.split-section-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
}

/* Split Transaction Modal (Edit/Create) */
.split-modal-revert-btn {
  background-color: #d9534f;
  margin-right: auto;
}

.split-edit-container {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 15px;
}

.split-save-btn {
  transition: opacity 0.2s;
}

.split-save-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.split-summary-value {
  font-weight: bold;
}

.modal-content.split-edit-modal-content {
  width: 100%;
  max-width: 600px;
}

.split-source-info-box {
  background: rgba(255, 255, 255, 0.05);
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.split-source-label {
  font-size: 0.9em;
  color: #aaa;
}

.split-source-desc {
  font-size: 1.1em;
  font-weight: bold;
  margin-bottom: 5px;
}

.split-source-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.split-source-date {
  color: #ddd;
}

.split-source-amount {
  font-size: 1.2em;
}

.split-add-btn {
  width: 100%;
  margin-bottom: 15px;
}

.split-summary-total-row {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.split-summary-remaining-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 5px;
}

.split-summary-label {
  color: #aaa;
}

.split-edit-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  align-items: center;
}

.split-input-desc {
  flex: 2;
}

.split-input-amount {
  flex: 1;
}

.split-remove-btn {
  background: none;
  border: none;
  color: #d9534f;
  cursor: pointer;
  font-size: 1.2em;
}
