/* ============================================================
   history.css — Expense History Section
   Personal Expense Tracker
   ============================================================ */

/* ── History Section ───────────────────────────────────────── */
#history-section {
  padding: 3rem 0;
  background: var(--bg-page);
}

/* ── History Header ────────────────────────────────────────── */
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

/* ── Search + Filter Bar ───────────────────────────────────── */
.history-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-wrap .search-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.85rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: white;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.6rem 1rem 0.6rem 2.4rem;
  font-size: 0.875rem;
  font-family: var(--font-body);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast),
              box-shadow var(--transition-fast);
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.12);
}

.search-input::placeholder {
  color: var(--text-light);
}

/* ── Category Filter Select ────────────────────────────────── */
.filter-select {
  background: white;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.6rem 2rem 0.6rem 0.9rem;
  font-size: 0.85rem;
  font-family: var(--font-body);
  color: var(--text-secondary);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-fast);
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%239BA5BF' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 14px;
}

.filter-select:focus {
  border-color: var(--primary);
}

/* ── Date Group ────────────────────────────────────────────── */
.date-group {
  margin-bottom: 1.75rem;
}

.date-group-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.date-group-label-text {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  white-space: nowrap;
}

.date-group-line {
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

.date-group-badge {
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-full);
  padding: 0.15rem 0.65rem;
  font-size: 0.7rem;
  font-weight: 700;
}

/* ── Expense Item Card ─────────────────────────────────────── */
.expense-item {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 0.65rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-xs);
  transition: transform var(--transition-fast),
              box-shadow var(--transition-fast),
              border-color var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.expense-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  border-color: var(--border-muted);
}

/* Left accent line */
.expense-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.expense-item:hover::before {
  opacity: 1;
}

/* ── Category Icon ─────────────────────────────────────────── */
.expense-cat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

/* Category-specific background colors */
.cat-bg-food          { background: #FFF3EE; }
.cat-bg-fuel          { background: #FFFBEB; }
.cat-bg-transport     { background: #EFF6FF; }
.cat-bg-shopping      { background: #FDF2F8; }
.cat-bg-bills         { background: #F5F3FF; }
.cat-bg-health        { background: #ECFDF5; }
.cat-bg-entertainment { background: #FFF7ED; }
.cat-bg-other         { background: var(--bg-soft); }

/* ── Expense Info ──────────────────────────────────────────── */
.expense-info {
  flex: 1;
  min-width: 0;
}

.expense-title {
  font-size: 0.93rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.2rem;
}

.expense-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.expense-category-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.1rem 0.55rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Badge variants */
.badge-food          { background: #FFF3EE; color: #FF6B35; }
.badge-fuel          { background: #FFFBEB; color: #D97706; }
.badge-transport     { background: #EFF6FF; color: #3B82F6; }
.badge-shopping      { background: #FDF2F8; color: #EC4899; }
.badge-bills         { background: #F5F3FF; color: #8B5CF6; }
.badge-health        { background: #ECFDF5; color: #10B981; }
.badge-entertainment { background: #FFF7ED; color: #F97316; }
.badge-other         { background: var(--bg-soft); color: var(--text-muted); }

.expense-time {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ── Expense Amount ────────────────────────────────────────── */
.expense-amount {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Expense Actions ───────────────────────────────────────── */
.expense-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.expense-item:hover .expense-actions {
  opacity: 1;
}

.btn-action {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  transition: all var(--transition-fast);
}

.btn-edit-expense {
  background: var(--primary-light);
  color: var(--primary);
}

.btn-edit-expense:hover {
  background: var(--primary);
  color: white;
}

.btn-delete-expense {
  background: var(--accent-coral-light);
  color: var(--accent-coral);
}

.btn-delete-expense:hover {
  background: var(--accent-coral);
  color: white;
}

/* ── No Results ────────────────────────────────────────────── */
.no-results-wrap {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}

.no-results-wrap .icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  display: block;
}

.no-results-wrap p {
  font-size: 0.9rem;
}

/* ── Empty State ───────────────────────────────────────────── */
#empty-state {
  text-align: center;
  padding: 3rem 2rem;
}

#empty-state img {
  width: 240px;
  max-width: 100%;
  margin-bottom: 1.5rem;
  border-radius: var(--radius-lg);
  opacity: 0.92;
}

.empty-state-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.empty-state-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 340px;
  margin: 0 auto 1.5rem;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 575.98px) {
  .expense-actions {
    opacity: 1;
  }

  .expense-item {
    padding: 0.85rem 1rem;
    gap: 0.75rem;
  }

  .expense-cat-icon {
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
  }

  .history-controls {
    flex-direction: column;
    align-items: stretch;
  }

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