/* frontend.css */

/* Container Styling */
.ft-container {
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  align-items: flex-start;
  padding: 20px;
  flex-wrap: wrap;
  overflow: visible; /* So container won't clip tooltips */
}

/* Filter Section Styling */
.ft-filter-section {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  opacity: 0;
  transform: translateY(-20px);
  animation: ft-unfold 0.5s forwards;
}

@keyframes ft-unfold {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Stylized Select Dropdown */
.ft-filter-section select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: #ffc8df;
  border-color: #ffc8df;
  border-left: 10px solid #b8004c;
  padding: 10px;
  font-size: 1em;
  color: #000;
  border-radius: 20px;
  cursor: pointer;
  position: relative;
  min-width: 150px;
  transition: border-color 0.3s, background-color 0.3s, transform 0.3s;
}

.ft-filter-section select::after {
  content: "";
  position: absolute;
  right: 1em;
  top: 50%;
  transform: translateY(-50%);
  border: 0.3em solid #b8004c;
  border-color: #b8004c transparent transparent transparent;
  pointer-events: none;
  transition: transform 0.3s;
}

.ft-filter-section select::-ms-expand {
  display: none;
}

.ft-filter-section select:hover {
  border-color: #b8004c;
}

.ft-filter-section select:focus {
  outline: none;
  border-color: #b8004c;
  background-color: #ffc8df;
}

.ft-filter-section select:focus::after {
  transform: translateY(-50%) rotate(180deg);
}

/* Each Section (Income/Expense) */
.ft-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 45%;
  margin: 20px 0;
  padding: 20px;
  border-radius: 25px;
  border-left: 15px solid #b8004c;
  background-color: #ffedf3;
  overflow: visible; /* Ensure no clipping of external tooltip */
}

/* Chart Container */
.ft-section .ft-chart {
  width: 100%;
  max-width: 700px;
  height: 400px;
  margin: 0 auto 20px auto;
  position: relative;
  overflow: visible; /* So external tooltip is fully visible */
}

/* Canvas: fully responsive */
.ft-section .ft-chart canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Legend container: smaller squares, clickable */
.ft-legend-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  margin-top: 5px;
  font-size: 0.8em;
}

.ft-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 3px;
  cursor: pointer;
}

.ft-legend-item .color-box {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  padding: 5px;
  margin-right: 5px;
}

.ft-legend-item.inactive {
  opacity: 0.4;
}

/* List Styling */
.ft-section .ft-list {
  width: 100%;
  margin-top: 3em;
}

.ft-section .ft-list h3 {
  text-align: center;
  margin-bottom: 10px;
  font-weight: 700;
  font-family: Tahoma;
  font-size: 1.5em;
  color: #000;
}

.ft-section .ft-list ul {
  list-style-type: none;
  padding: 0;
}

.ft-section .ft-list li {
  background: #ffa9cd;
  margin: 5px 0;
  padding: 10px;
  border-radius: 15px;
  border-left: 10px solid #b8004c;
  transition: background 0.3s, transform 0.3s;
}

.ft-section .ft-list li:hover {
  background: #ffbad6;
  transform: translateY(-2px);
}

.ft-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ft-toggle-description {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2em;
  transition: transform 0.3s;
}

.ft-toggle-description .ft-arrow {
  display: inline-block;
  transition: transform 0.3s;
}

.ft-toggle-description.rotated .ft-arrow {
  transform: rotate(180deg);
}

.ft-description {
  display: none;
  padding: 10px 0;
  background-color: #ff87b9;
  color: #000;
  font-family: Tahoma;
  padding: 10px;
  border-radius: 15px;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  overflow: hidden;
}

/* Responsive Adjustments */
@media (max-width: 992px) {
  .ft-container {
    flex-direction: column;
    align-items: center;
  }

  .ft-section {
    width: 90%;
  }

  .ft-section .ft-chart {
    max-width: 100%;
    height: 350px;
  }
}

@media (max-width: 768px) {
  .ft-section .ft-list h3 {
    font-size: 1.3em;
  }

  .ft-section .ft-list li {
    padding: 8px;
  }

  .ft-filter-section {
    flex-direction: column;
    gap: 15px;
  }

  .ft-filter-section select {
    width: 100%;
    max-width: 250px;
  }

  .ft-filter-section.no-quarter {
    justify-content: center;
  }

  .ft-filter-section.no-quarter .ft-filter-group:nth-child(1) {
    width: 100%;
    max-width: 250px;
  }
}

/* Custom tooltip container (external Chart.js tooltip) */
.chartjs-tooltip {
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.85em;
  pointer-events: none;
  position: absolute;
  transform: translate(-50%, -100%);
  transition: opacity 0.2s ease;
  z-index: 9999;
  opacity: 0; /* hidden by default */
  border: 1px solid #fff;

  /* Let text wrap if needed */
  white-space: normal;
  word-wrap: break-word;
  max-width: 160px; /* Adjust as needed */
}

.chartjs-tooltip.show {
  opacity: 1;
}

.chartjs-tooltip .caret {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid rgba(0, 0, 0, 0.85);
  margin: 0 auto;
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
}
