/* CSS Custom Properties for Light/Dark Mode */
:root {
  --bg-primary: white;
  --bg-secondary: #f9fafb;
  --text-primary: black;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border-color: #d1d5db;
  --accent-color: black;
  --accent-hover: #374151;
  --danger-color: #dc2626;
  --danger-hover: #b91c1c;
}

[data-theme="dark"] {
  --bg-primary: #111827;
  --bg-secondary: #1f2937;
  --text-primary: white;
  --text-secondary: #d1d5db;
  --text-muted: #9ca3af;
  --border-color: #374151;
  --accent-color: white;
  --accent-hover: #e5e7eb;
  --danger-color: #ef4444;
  --danger-hover: #dc2626;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    interpolate-size: allow-keywords;
  }
}

body {
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

input,
button,
textarea,
select {
  font: inherit;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

p {
  text-wrap: pretty;
}
h1,
h2,
h3,
h4,
h5,
h6 {
  text-wrap: balance;
}

#root,
#__next {
  isolation: isolate;
}

/* Dark Mode Toggle */
.dark-toggle {
  position: absolute;
  top: 2rem;
  right: 2rem;
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  background: var(--bg-primary);
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 0.25rem;
}

.dark-toggle:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

/* Layout */
main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4rem 1rem;
}

.page-container {
  text-align: center;
  max-width: 56rem;
  margin: 0 auto;
}

/* Typography */
.page-heading {
  font-size: 4rem;
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  letter-spacing: 0.1em;
}

.page-subtitle {
  font-size: 1.5rem;
  color: var(--text-secondary);
  margin-bottom: 4rem;
}

.section-heading {
  font-size: 2.5rem;
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 4rem;
  letter-spacing: 0.05em;
}

/* Form Elements */
input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 1rem 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-size: 1.125rem;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: all 0.3s ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--text-secondary);
  box-shadow: 0 0 0 2px rgba(107, 114, 128, 0.2);
}

textarea {
  resize: none;
  height: 8rem;
}

.form-group {
  margin-bottom: 3rem;
}

.form-label {
  display: block;
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.error-message {
  margin-top: 0.5rem;
  font-size: 1.125rem;
  color: var(--danger-color);
}

/* Buttons */
.btn-primary {
  background-color: var(--accent-color);
  color: var(--bg-primary);
  padding: 1rem 2rem;
  border-radius: 0.5rem;
  font-size: 1.125rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

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

.btn-secondary {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 1rem 2rem;
  border-radius: 0.5rem;
  font-size: 1.125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.btn-secondary:hover {
  background-color: var(--bg-secondary);
}

.btn-small {
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  border-radius: 0.5rem;
  font-weight: 500;
  text-decoration: none;
  display: inline-block;
  transition: background-color 0.2s;
}

.btn-view {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-view:hover {
  background-color: var(--bg-secondary);
}

.btn-delete {
  background-color: var(--accent-color);
  color: var(--bg-primary);
  border: none;
}

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

.btn-danger {
  background-color: var(--danger-color);
  color: white;
  padding: 1rem 2rem;
  border-radius: 0.5rem;
  font-size: 1.125rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  flex: 1;
}

.btn-danger:hover {
  background-color: var(--danger-hover);
}

/* Homepage */
.button-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Form Pages */
.expense-form-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 3rem;
  margin-bottom: 4rem;
  max-width: 56rem;
  margin-left: auto;
  margin-right: auto;
}

.expense-form {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.form-field {
  display: flex;
  flex-direction: column;
}

.field-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
}

.field-input,
.field-textarea {
  width: 100%;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-size: 1.125rem;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: all 0.3s ease;
}

.field-input:focus,
.field-textarea:focus {
  outline: none;
  border-color: var(--text-secondary);
  box-shadow: 0 0 0 2px rgba(107, 114, 128, 0.1);
}

.amount-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.currency-symbol {
  position: absolute;
  left: 1.5rem;
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--text-primary);
  z-index: 1;
}

.amount-input {
  padding-left: 3rem !important;
  font-size: 1.25rem;
  font-weight: 500;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.half-width {
  width: 100%;
}

.field-textarea {
  resize: none;
  height: 6rem;
  font-family: inherit;
}

.field-error {
  margin-top: 0.75rem;
  font-size: 1rem;
  color: var(--danger-color);
}

.form-actions {
  display: flex;
  gap: 1rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
}

.action-btn {
  flex: 1;
  text-align: center;
  padding: 1.25rem 2rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 1rem;
}

.form-content {
  text-align: left;
  max-width: 42rem;
  margin: 0 auto;
}

.submit-container {
  padding-top: 2rem;
  text-align: center;
}

/* Expense List */
.total-section {
  margin-bottom: 4rem;
}

.total-border {
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  padding: 3rem 0;
}

.total-heading {
  font-size: 2rem;
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  letter-spacing: 0.05em;
}

.total-amount {
  font-size: 5rem;
  font-weight: bold;
  color: var(--text-primary);
}

.history-section {
  margin-bottom: 4rem;
}

.history-heading {
  font-size: 2rem;
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 3rem;
  letter-spacing: 0.05em;
}

.expense-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.expense-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.3s ease;
  cursor: pointer;
}

.expense-card:hover {
  background-color: var(--bg-primary);
  border-color: var(--text-secondary);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.expense-details {
  text-align: left;
}

.expense-title {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.expense-date {
  font-size: 1.125rem;
  color: var(--text-secondary);
}

.expense-notes {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.expense-actions {
  text-align: right;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.expense-amount {
  font-size: 2rem;
  font-weight: bold;
  color: var(--text-primary);
}

.empty-state {
  text-align: center;
  padding: 4rem 0;
}

.empty-message {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

/* Detail and Delete Pages */
.expense-detail-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 3rem;
  margin-bottom: 4rem;
  max-width: 56rem;
  margin-left: auto;
  margin-right: auto;
  position: relative;
}

.expense-id-corner {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 500;
}

.expense-title-section {
  text-align: center;
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
}

.expense-detail-title {
  font-size: 2.5rem;
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  letter-spacing: 0.05em;
}

.expense-detail-amount {
  font-size: 4rem;
  font-weight: bold;
  color: var(--text-primary);
}

.expense-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
  padding: 2rem 0;
}

.meta-item {
  text-align: left;
}

.meta-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

.meta-value {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin: 0;
}

.expense-notes-section {
  margin-bottom: 2rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border-color);
}

.notes-content {
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  line-height: 1.6;
}

.expense-actions-section {
  display: flex;
  gap: 1rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
}

.detail-btn {
  flex: 1;
  text-align: center;
  padding: 1rem 2rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.expense-preview {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 3rem;
  text-align: left;
  margin-bottom: 3rem;
  transition: all 0.3s ease;
}

.expense-preview h3 {
  font-size: 2rem;
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.expense-preview p {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.expense-preview .amount {
  font-size: 3rem;
  font-weight: bold;
  color: var(--text-primary);
}

.notes-section h3 {
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.notes-section p {
  font-size: 1.125rem;
  color: var(--text-secondary);
}

.meta-info {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 4rem;
}

.form-actions {
  display: flex;
  gap: 1.5rem;
}

.warning-text {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 3rem;
}

/* Navigation */
.back-link {
  margin-top: 4rem;
  text-align: center;
}

.back-link a,
.nav-links a {
  font-family: monospace;
  letter-spacing: 0.5rem;
  font-size: 1.125rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.3s ease;
}

.back-link a:hover,
.nav-links a:hover {
  color: var(--text-primary);
}

.back-link::before {
  content: "←";
  margin-right: 0.5rem;
  position: relative;
  top: -1px;
}

.nav-links {
  margin-top: 4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Utility Classes */
.text-center {
  text-align: center;
}
.block {
  display: block;
}
.w-full {
  width: 100%;
}
.mx-auto {
  margin-left: auto;
  margin-right: auto;
}
.max-w-md {
  max-width: 28rem;
}
.max-w-2xl {
  max-width: 42rem;
}
.max-w-4xl {
  max-width: 56rem;
}
.content-section {
  margin-bottom: 4rem;
}

/* Responsive Design */
@media (max-width: 768px) {
  main {
    padding: 2rem 1rem;
  }

  .dark-toggle {
    top: 1rem;
    right: 1rem;
  }

  .page-heading {
    font-size: 2.5rem;
  }

  .page-subtitle {
    font-size: 1.25rem;
    margin-bottom: 3rem;
  }

  .section-heading {
    font-size: 2rem;
  }

  .total-amount {
    font-size: 3rem;
  }

  .expense-card {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }

  .expense-details,
  .expense-actions {
    text-align: center;
  }

  .expense-actions {
    flex-direction: column;
    width: 100%;
    gap: 1rem;
  }

  .expense-detail-amount {
    font-size: 3rem;
  }

  .expense-meta-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .expense-actions-section {
    flex-direction: column;
  }

  .detail-btn {
    width: 100%;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .form-actions {
    flex-direction: column;
  }

  .action-btn {
    width: 100%;
  }
}
