html {
  overflow-y: hidden;
}

/* Safari and Firefox appearence reset*/
input,
select,
button {
  font-family: inherit;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f4f6f8;
  color: #333;
  min-height: 100dvh;
}

/* App Layout */
.app-container {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* sidebar */
.sidebar {
  background-color: #1f2937;
  color: #fff;
  width: 250px;
  min-width: 250px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
}

.sidebar h1 {
  font-size: 1.5rem;
  margin-bottom: 2rem;
}

#filters {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
  flex-grow: 1;
}

.sidebar button {
  background-color: #374151;
  color: #fff;
  border: none;
  padding: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  border-radius: 5px;
  transition: background 0.2s ease;
}

.sidebar button:hover, #load-more-btn:hover {
  background-color: #4b5563;
}

.sidebar button.active {
  background-color: #2563eb; /* Blue for active */
  color: #fff;
  font-weight: 600;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.5); /* subtle glow */
}


#load-more-btn {
  background-color: #374151;
  color: #fff;
  border: none;
  padding: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  border-radius: 5px;
  transition: background 0.2s ease;
}

.sidebar footer {
  font-size: 0.8rem;
  text-align: center;
  margin-top: 2rem;
  color: #ccc;
}

/* Main Content */
.main-content {
  flex-grow: 1;
  overflow-y: scroll;
  padding: 30px 60px;
  background-color: #f6f4f4;
}

/* Summary */
#summary {
  background-color: #dddee1;
  padding: 20px;
  border-radius: 10px;
  margin-bottom: 20px;
}

#summary h2 {
  margin-bottom: 10px;
}

#summary .totals p {
  margin-top: 5px;
}

/* Summary Cards */
.card-container {
  display: flex;
  gap: 20px;
  justify-content: space-between;
  flex-wrap: wrap;
}

.card {
  flex: 1;
  min-width: 150px;
  background-color: #f8f9fa;
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.balance-card-hidden {
  background-color:#fdecea;
}

.balance-card-hidden p {
  color: #c0392b;
}

.balance-card-hidden h3 {
  color: #c0392b !important;
}

.card h3 {
  margin-bottom: 10px;
  color: #333;
  font-weight: 400;
}

.card p {
  font-size: 1.5rem;
  font-weight: bold;
}



/* Form Section */
/* Animate show/hide form */
.form-collapse {
  max-height: 1000px;
  overflow: hidden;
  transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-collapse.collapsed {
  max-height: 0;
  overflow: hidden;
}

.transaction-title-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 10px;
  transition: margin-bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.transaction-title-container.collapsed {
  margin-bottom: 0;
}

#toggle-form-btn {
  color: white;
  border: none;
  padding: 10px 12px;
  border-radius: 5px;
  cursor: pointer;
  width: 170px;
  font-size: 1rem;
  transition: background-color 0.3s ease-in-out;
}

/* Blue (Open / Collapse) State */
.btn-blue {
  background-color: #374151;
}

.btn-blue:hover {
  background-color: #4b5563;
}

/* Green (Closed / Add Transaction) State */
.btn-green {
  background-color: #10b981;
}

.btn-green:hover {
  background-color: #059669;
}

#transaction-form {
  background-color: #fff;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  max-width: 850px;
  margin: 0 auto 30px auto;
}

#form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

#form input,
#form select {
  padding: 12px 15px;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  transition: border-color 0.3s, box-shadow 0.3s;
}

#form input:focus,
#form select:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
  outline: none;
}

/*helper warning focus input red*/
#type-category.max-reached:focus {
  border-color: #e1430f;
  box-shadow: 0 0 0 3px rgba(225, 67, 15, 0.2);
}

/*helper warning focus input red*/
#description.max-reached:focus {
  border-color: #e1430f;
  box-shadow: 0 0 0 3px rgba(225, 67, 15, 0.2);
}


#form button {
  background-color: #10b981;
  color: white;
  padding: 12px;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.3s, transform 0.1s;
}

#form button:hover {
  background-color: #059669;
}

#form button:active {
  transform: scale(0.98);
}

/* Helper message style */
.helper-message {
  color: #ef4444;
  font-size: 0.9rem;
  margin-top: 5px;
  margin-bottom: 0;
}

/* Transactions Table */
.title-container {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  margin-bottom: 10px;
  height: 37.6px;
}

#transactions h3 {
  margin-top: 10px;
}

#transaction-table {
  border-collapse: separate;
  border-spacing: 0 8px; /* space between rows for modern look */
  margin-bottom: 20px;
  font-family: Arial, sans-serif;
  table-layout: fixed;
  width: 100%;
  max-width: 1200px;
}

#transaction-table thead tr {
  background-color: #e1e1e1;
  color: #374151;
}

#transaction-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
}

#transaction-table tbody tr {
  background-color: #ffffff;
  box-shadow: 0px 0px 6px -4px rgba(0,0,0,0.62);

  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

#transaction-table tbody tr:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 8px rgba(0,0,0,0.08);
}

#transaction-table td {
  padding: 12px 16px;
  border-bottom: 2px solid #e5e7eb; /* subtle separator for fallback if border-spacing fails */
  font-size: 14px;
  color: #374151;
  cursor: default;
}

#transaction-table thead th:first-child {
  border-top-left-radius: 12px;
  border-bottom-left-radius: 12px;
}

#transaction-table thead th:last-child {
  border-top-right-radius: 12px;
  border-bottom-right-radius: 12px;
}

#transaction-table tbody tr td:first-child {
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
}
#transaction-table tbody tr td:last-child {
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
}

#transaction-table th:nth-child(2),
#transaction-table td:nth-child(2) {
  width: 250px;
}

#transaction-table th,
#transaction-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#delete-all-btn, #empty-bin-btn {
  background-color: #ef4444;
  color: white;
  border: none;
  padding: 10px;
  border-radius: 5px;
  cursor: pointer;
}

.delete-btn {
  background-color: #ef4444;
  color: white;
  border: none;
  padding: 10px 14px;
  border-radius: 5px;
  cursor: pointer;
}

#delete-all-btn:hover, .delete-btn:hover, #empty-bin-btn:hover {
  background-color: #dc2626;
}

.restore-btn {
  background-color: #374151;
  color: #fff;
  border: none;
  padding: 10px;
  cursor: pointer;
  border-radius: 5px;
  transition: background 0.2s ease;
}

.restore-btn:hover{
  background-color: #4b5563;
}

/* Base label styling */
.label {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 9999px;
  min-width: 85px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: background-color 0.2s ease, color 0.2s ease;
  cursor: default;
}

/* Individual category colors */
.label-food {
  background-color: #ffedd5; /* light orange background */
  color: #c2410c; /* darker orange text */
}

.label-rent {
  background-color: #ede9fe; /* light indigo background */
  color: #6b21a8; /* darker indigo text */
}

.label-salary {
  background-color: #dcfce7; /* light green background */
  color: #15803d; /* darker green text */
}

.label-transport {
  background-color: #dbeafe; /* light blue background */
  color: #1e40af; /* darker blue text */
}

.label-utilities {
  background-color: #ffe4e6; /* Light Rose */
  color: #be123c; /* Darker Rose */
}

.label-health {
  background-color: #fefce8; /* Light Yellow */
  color: #a16207; /* Darker Yellow/Brown */
}

.label-shopping { /* For the first 'Shopping' */
  background-color: #fdf2f8; /* Light Pink */
  color: #9d174d; /* Darker Pink/Maroon */
}

.label-entertainment {
  background-color: #f0f9ff; /* Very Light Cyan/Azure */
  color: #075985; /* Darker Cyan/Blue */
}

.label-pet {
  background-color: #f3e8ff; /* Light Lavender/Periwinkle */
  color: #7e22ce; /* Darker Purple */
}

.label-education {
  background-color: #eef2ff; /* Very Light Violet */
  color: #4338ca; /* Darker Violet/Blue */
}

.label-travel {
  background-color: #e0f2f7; /* Light Teal */
  color: #0d9488; /* Darker Teal */
}

.label-family {
  background-color: #fff7ed; /* Creamy Orange/Peach */
  color: #b45309; /* Darker Orange/Brown */
}

.label-default {
  background-color: #f3f4f6; /* light grey background */
  color: #4b5563;           /* darker grey text */
}

/* Hover effect (optional) */
.label:hover {
  opacity: 0.85;
}



/*Delete all confirm modal*/
/* Modal background */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

/* Hide modal by default */
.hidden {
  display: none;
}

/* Modal content box */
.modal-content {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: #fff;
  padding: 1.3rem;
  width: 100%;
  max-width: 500px;
  height: 100%;
  max-height: 155px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  position: relative;
  text-align: left;
}

/* Confirmation text */
.modal-content p {
  margin: 0 0 1.5rem;
  font-size: 1.1rem;
  color: #333;
}

/* Button container */
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Buttons */
.btn {
  padding: 0.5rem 1rem;
  border: none;
  font-size: 0.95rem;
  border-radius: 4px;
  cursor: pointer;
}

.btn.cancel {
  background-color: #f0f0f0;
  color: #333;
}

.btn.cancel:hover {
  background-color: #ddd;
}

.btn.delete {
  background-color: #e74c3c;
  color: white;
}

.btn.delete:hover {
  background-color: #c0392b;
}

/* Toast delete/restore message */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  width: 250px;
  text-align: center;
  transform: translateX(-50%);
  background: #1f2937; /* dark grey */
  color: #fff;
  padding: 1em 1.5em;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  font-size: 0.95rem;
  font-weight: 500;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* When visible */
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* Hidden state */
.toast.hidden {
  display: none;
}

/* Responsive Layout */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
  }

  .sidebar section,
  .sidebar footer {
    display: none;
  }

  .main-content {
    padding: 15px;
  }
}

/*responsive card summary*/
@media (max-width: 600px) {
  .card-container {
    flex-direction: row;
  }

  .balance-card {
    flex-basis: 100%;
  }

  .card p {
  font-size: 1.3rem;
  }
}

/* change table layout to card layout for mobile */
@media (max-width: 600px) {
  #transactions h3 {
    margin-top: 6px;
  }

  #transaction-table, 
  #transaction-table thead, 
  #transaction-table tbody, 
  #transaction-table th, 
  #transaction-table td, 
  #transaction-table tr {
    display: block;
    width: 100%;
  }

  #transaction-table thead {
    display: none; /* Hide table header on mobile */
  }

  #transaction-table tr {
    border: 1px solid #ddd;
    margin-bottom: 10px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 10px;
    background-color: #fff;
  }

  #transaction-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border: none;
    border-bottom: 1px solid #eee;
  }

  #transaction-table td.empty-message-cell {
    display: flex;
    justify-content: center;
  }

  #transaction-table td p {
    display: flex;
    justify-content: center;
  }

  #transaction-table td:nth-child(2) {
    width: 100% !important;
  }

  #transaction-table td:last-child {
    border-bottom: none;
  }

  #transaction-table td::before {
    content: attr(data-label);
    font-weight: bold;
    color: #374151;
    margin-right: 10px;
  }
}

/*mobile expandable sidebar*/
/* On desktop, sidebar is always visible */
@media (min-width: 768px) {
  #sidebar-toggle {
    display: none; /* hide toggle button */
  }
  .sidebar {
    max-height: none; /* fully visible */
  }
}

/* On mobile, hide sidebar by default, max-height 0 (collapsed) */
@media (max-width: 767px) {
  .sidebar h1 {
    margin-bottom: 0px;
  }

  #filters {
    width: 100%;
    max-width: 90%;
  }

  .sidebar {
    width: 100%; /* full width on mobile */
    max-height: 80px; /* collapsed */
    transition: max-height 0.5s ease;
    box-shadow: 2px 0 5px rgba(0,0,0,0.3);
  }

  .sidebar.open {
    max-height: 100dvh; /* expanded */
  }

  #sidebar-toggle {
    margin-bottom: 0px;
  }

  .sidebar-title-container{
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
  }
}

@media (max-width: 767px) {
  .modal-content {
  padding: 1rem;
  width: 90%;
  height: auto;
  max-height: none;
  
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  position: relative;
  text-align: left;
}

.modal-content p {
  margin: 0 0 1.5rem;
  font-size: 1rem;
  color: #333;
}
}