/* General Styles */
body {
  font-family: "Arial", sans-serif;
  background-color: #f4f6f8;
  margin: 0;
  padding: 0;
  color: #333;
  line-height: 1.6;
}

h1,
h2,
h3 {
  margin: 0 0 1rem;
  font-weight: bold;
}

h3 {
  border-bottom: 2px solid #007bff;
  padding-bottom: 5px;
  margin-bottom: 15px;
  color: #333;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 4px;
  padding: 0.5rem 1rem;
  font-size: 1rem;
}

button:hover {
  opacity: 0.9;
}

/* Main Title */
.main-title {
  text-align: center;
  margin-top: 2rem;
  color: #1e88e5;
  font-size: 2.5rem;
}

/* Auth Forms */
#auth-forms {
  max-width: 500px;
  margin: 2rem auto;
  padding: 2rem;
  background: #fff;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  justify-content: center;
}

.auth-form {
  margin-bottom: 2rem;
  padding: 1rem;
  background: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 8px;
}

.auth-form h2 {
  text-align: center;
  margin-bottom: 1rem;
  color: #333;
}

.form-group {
  margin-bottom: 1rem;
  position: relative;
}

input {
  width: 100%;
  padding: 0.8rem;
  font-size: 1rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-sizing: border-box;
}

input::placeholder {
  color: #aaa;
  font-size: 1rem;
}

input:focus {
  outline: none;
  border-color: #1e88e5;
  box-shadow: 0 0 5px rgba(30, 136, 229, 0.5);
}

.auth-form input {
  border-radius: 8px;
  border: 1px solid #ddd;
  padding: 10px;
  font-size: 16px;
  width: 100%;
  margin-bottom: 15px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.auth-form button {
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.auth-form button:hover {
  background-color: #0056b3;
}

.auth-form button {
  width: 100%;
}

.btn {
  display: inline-block;
  color: #fff;
  background-color: #1e88e5;
  text-align: center;
  text-decoration: none;
  transition: all 0.3s ease;
}

.btn:hover {
  transform: scale(1.05);
}

.btn-danger {
  background-color: #e53935;
}

/* Dashboard */
#dashboard {
  max-width: 1200px;
  margin: 20px auto;
  padding: 20px;
  background-color: #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.add-item-section {
  margin-bottom: 2rem;
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row select {
  padding: 0.8rem;
  border: 1px solid #ddd;
  border-radius: 4px;
}

/* Summary */
.summary {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.summary-item {
  flex: 1;
  padding: 1rem;
  background: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 8px;
  text-align: center;
}

.summary-item .value {
  font-size: 1.5rem;
  font-weight: bold;
}

.summary-item .positive {
  color: #4caf50;
}

.summary-item .negative {
  color: #e53935;
}

.summary-item.total {
  background: #e3f2fd;
  border: 1px solid #1e88e5;
}

/* Items Section */
.items-section {
  margin-top: 2rem;
}

.items-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.items-filters .btn-small {
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
}

.items-filters .btn.active {
  background-color: #1e88e5;
  color: #fff;
}

.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 15px;
}

.items-grid .item {
  padding: 2rem 1rem 3rem; /* Increase height */
  background: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 8px;
  text-align: center;
  position: relative;
}

.items-grid .item .value {
  margin-bottom: 1rem;
}

.items-grid .item button {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%); /* Center the button horizontally */
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  background-color: #e53935;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.items-grid .item button:hover {
  background-color: #d32f2f;
}

.item-type {
  font-weight: bold;
  margin-top: 5px;
}

.item.asset .item-type {
  color: green;
}

.item.liability .item-type {
  color: red;
}

/* Item card */
.item {
  background-color: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  animation: fadeIn 0.5s ease;
}

.item:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.15);
}

/* Asset and liability colors */
.item.asset {
  border-left: 5px solid green;
}

.item.liability {
  border-left: 5px solid red;
}

/* Item details */
.item .item-details {
  margin-bottom: 10px;
}

.item .item-name {
  font-size: 18px;
  font-weight: bold;
}

.item .item-value {
  font-size: 16px;
  font-weight: bold;
}

/* Fade-in animation for items */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Footer */
.footer {
  text-align: center;
  margin-top: 2rem;
  padding: 1rem;
  background-color: #1e88e5;
  color: #fff;
  font-size: 0.9rem;
}

/* Messages */
.message {
  padding: 1rem;
  margin: 1rem 0;
  border-radius: var(--border-radius);
  text-align: center;
}

.success {
  background-color: #d4edda; /* Light green background */
  color: #155724; /* Dark green text */
  border: 1px solid #c3e6cb; /* Green border */
}

.error {
  background-color: #f8d7da; /* Light red background */
  color: #721c24; /* Dark red text */
  border: 1px solid #f5c6cb; /* Red border */
}

/* Make containers responsive */
#dashboard,
.auth-form,
.chart-section {
  max-width: 100%;
  box-sizing: border-box;
  padding: 10px;
}

/* Responsive grid for items */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 15px;
}

/* Make forms and buttons full width on small screens */
@media (max-width: 600px) {
  body {
    padding: 0;
    margin: 0;
    font-size: 16px;
  }
  #dashboard,
  .auth-form,
  .chart-section {
    max-width: 100vw;
    box-sizing: border-box;
    padding: 8px;
    margin: 0 0 16px 0;
  }
  .items-grid,
  .item-list,
  #itemsList {
    grid-template-columns: 1fr !important;
    display: block !important;
    width: 100vw;
    box-sizing: border-box;
    padding: 0;
  }
  .item {
    width: 100% !important;
    min-width: 0;
    box-sizing: border-box;
    margin: 0 0 12px 0;
    padding: 10px;
    font-size: 16px;
  }
  .auth-form input,
  .auth-form button,
  .auth-form select {
    width: 100% !important;
    font-size: 16px;
    box-sizing: border-box;
  }
  .btn,
  button {
    width: 100%;
    font-size: 16px;
    margin-bottom: 8px;
  }
  img,
  .img-responsive,
  .item img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
  }
  h1,
  h2,
  h3,
  h4 {
    font-size: 1.2em;
    word-break: break-word;
  }
  .item-details,
  .item-actions {
    flex-direction: column;
    align-items: flex-start;
  }
  .item-actions {
    width: 100%;
    margin-top: 8px;
  }
}

/* Extra mobile fixes for net worth and summary sections */
@media (max-width: 600px) {
  .summary,
  .summary-item,
  .networth-section,
  .networth,
  .net-worth-section {
    display: block !important;
    width: 100vw !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    padding: 8px !important;
    margin: 0 !important;
    overflow-x: auto !important;
  }
  .summary-item {
    margin-bottom: 10px !important;
    font-size: 1em !important;
    word-break: break-word !important;
  }
  .networth-section *,
  .summary *,
  .networth *,
  .net-worth-section * {
    word-break: break-word !important;
    white-space: normal !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }
}

/* Prevent horizontal scroll everywhere */
html,
body,
#dashboard,
.summary,
.networth-section,
.networth,
.net-worth-section {
  max-width: 100vw !important;
  overflow-x: hidden !important;
  box-sizing: border-box !important;
}
