/* Expense & Budget Visualizer — styles */

/* ============================================================
   CSS Custom Properties — Light theme (default)
   ============================================================ */
:root {
  --bg: #ffffff;
  --surface: #f5f5f5;
  --surface-alt: #e9e9e9;
  --text: #111111;
  --text-muted: #555555;
  --accent: #4a90e2;
  --accent-hover: #357abd;
  --danger: #e25555;
  --danger-hover: #c43c3c;
  --border: #d0d0d0;
  --shadow: rgba(0, 0, 0, 0.08);
  --radius: 8px;
  --transition: 0.2s ease;
}

/* ============================================================
   CSS Custom Properties — Dark theme overrides
   ============================================================ */
[data-theme="dark"] {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface-alt: #0f3460;
  --text: #e0e0e0;
  --text-muted: #a0a0b0;
  --accent: #7eb8f7;
  --accent-hover: #5aa0e8;
  --danger: #f07070;
  --danger-hover: #d95555;
  --border: #2e3a5a;
  --shadow: rgba(0, 0, 0, 0.3);
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  transition: background-color var(--transition), color var(--transition);
}

/* ============================================================
   Layout — single-column, centered, mobile-first
   ============================================================ */
header,
main {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px;
}

main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 32px;
}

/* ============================================================
   Header
   ============================================================ */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

#theme-toggle {
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text);
  transition: background-color var(--transition), border-color var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

#theme-toggle:hover {
  background: var(--surface-alt);
}

/* ============================================================
   Sections — shared card style
   ============================================================ */
section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 2px 6px var(--shadow);
  transition: background-color var(--transition), border-color var(--transition);
}

/* ============================================================
   Balance Section
   ============================================================ */
#balance-section {
  text-align: center;
}

#balance-section p {
  font-size: 1rem;
  color: var(--text-muted);
}

#balance-display {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  display: block;
  margin-top: 4px;
  transition: color var(--transition);
}

/* ============================================================
   Form Section
   ============================================================ */
#form-section h2 {
  /* font-size: 1rem; */
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

#transaction-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#transaction-form input,
#transaction-form select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color var(--transition), background-color var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

#transaction-form select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

#transaction-form input:focus,
#transaction-form select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

#transaction-form input::placeholder {
  color: var(--text-muted);
}

#form-error {
  font-size: 0.875rem;
  color: var(--danger);
  min-height: 1.25em;
}

#transaction-form button[type="submit"] {
  min-height: 44px;
  padding: 10px 16px;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background-color var(--transition);
}

#transaction-form button[type="submit"]:hover {
  background: var(--accent-hover);
}

#transaction-form button[type="submit"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   List Section
   ============================================================ */
#list-section h2 {
  /* font-size: 1rem; */
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

#sort-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

#sort-controls button {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 14px;
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  transition: background-color var(--transition), border-color var(--transition);
}

#sort-controls button:hover {
  background: var(--border);
}

#sort-controls button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#sort-controls button.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

#transaction-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 2px;
}

#transaction-list:empty::after {
  content: "No transactions yet.";
  display: block;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 16px 0;
}

/* Transaction list items */
#transaction-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background-color var(--transition), border-color var(--transition);
}

.transaction-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.transaction-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.transaction-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.transaction-amount {
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
}

.delete-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background-color var(--transition), border-color var(--transition);
}

.delete-btn:hover {
  background: var(--surface-alt);
  border-color: var(--danger);
}

.delete-btn:focus-visible {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
}

/* Scrollbar styling */
#transaction-list::-webkit-scrollbar {
  width: 6px;
}

#transaction-list::-webkit-scrollbar-track {
  background: transparent;
}

#transaction-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ============================================================
   Chart Section
   ============================================================ */
#chart-section h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

#chart-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#spending-chart {
  max-width: 100%;
  max-height: 280px;
}

#chart-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 16px 0;
}

/* ============================================================
   Responsive — wider screens
   ============================================================ */
@media (min-width: 480px) {
  header h1 {
    font-size: 1.4rem;
  }

  #balance-display {
    font-size: 2rem;
  }

  #transaction-list {
    max-height: 400px;
  }
}

@media (min-width: 600px) {
  header,
  main {
    padding-left: 24px;
    padding-right: 24px;
  }

  section {
    padding: 20px;
  }
}
