@use "../../../styles/abstracts/variables" as *;
@use "../../../styles/abstracts/mixins" as *;

/* ================= PAGE ================= */

.branches {
  @include dashPageComponent;
  height: 100%;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;

  background: $bg-soft;
  border: 1px solid $border;

  @media (max-width: 1000px) {
    margin-top: 5rem;
  }
}

.content {
  padding: 1rem 2.5rem;

  @media (max-width: 1000px) {
    padding: 1.5rem .3rem;
  }
}


/* ================= TITLES ================= */

.statsTitle {
  @include sectionTitle;
}

.statsDesc {
  @include sectionDescription;
}

/* ================= CHART SECTION ================= */

.chartSection {
  @include dashPageComponent;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;

  margin-bottom: 2rem;
  margin-top: 1.8rem;

  overflow: hidden;
}

/* ================= TOGGLE ================= */

.toggle {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;

  button {
    padding: 0.45rem 0.9rem;
    border-radius: 999px;

    border: 1px solid $border;
    background: #ffffff;

    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;

    color: $text-light;

    transition: all 0.2s ease;

    &:hover {
      background: $primary-soft;
      border-color: $primary-border;
      color: $primary;
    }

    &.active {
      background: $primary-soft-strong;
      color: $primary;
      border-color: $primary-border;
    }
  }
}

/* ================= CHART GRID ================= */

.chartGrid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 1.5rem;
  align-items: center;
}

/* ================= LEGEND ================= */

.legend {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.legendItem {
  display: flex;
  align-items: center;
  gap: 0.6rem;

  padding: 0.45rem 0.6rem;
  border-radius: 10px;

  transition: all 0.2s ease;
  cursor: pointer;
  min-width: 0;

  &:hover {
    background: $primary-soft;
  }

  .text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.2;
    min-width: 0;
  }

  p {
    font-size: 0.9rem;
    font-weight: 600;
    color: $text-dark;
    margin: 0;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  small {
    font-size: 0.8rem;
    color: $text-light;
    font-weight: 500;
  }
}

/* ================= DOT ================= */

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ================= TABLE SECTION ================= */

.tableSection {
  background: #ffffff;
  border-radius: 16px;
  padding: 1.3rem;

  border: 1px solid $border;

  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.04);
}

/* ================= TABLE HEADER ================= */

.tableHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;

  flex-wrap: wrap;
  margin-bottom: .5rem;

  h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: $text-dark;
    margin: 0;
  }

  p {
    font-size: 0.85rem;
    color: $text-light;
    margin-top: 2px;
  }
}

/* ================= PAGINATION ================= */

.paginate {
  margin-top: 1.2rem;
  display: flex;
  justify-content: flex-end;
}

/* ================= HOVER INTERACTIONS ================= */

.chartSection,
.tableSection {
  transition: all 0.25s ease;

  &:hover {
    border-color: $primary-border;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.06);
  }
}

/* ================= RESPONSIVE ================= */

@media (max-width: 1024px) {
  .chartGrid {
    grid-template-columns: 1fr;
  }

  .legend {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .legendItem {
    flex: 1 1 48%;
  }
}

@media (max-width: 768px) {
  .content {
    gap: 1.5rem;
  }

  .chartSection {
    padding: 1.2rem;
  }

  .tableSection {
    padding: 1rem;
  }

  .toggle {
    width: 100%;

    button {
      flex: 1;
      text-align: center;
    }
  }

  .tableHeader {
    flex-direction: column;
    align-items: flex-start;

    h2 {
      font-size: 1rem;
    }

    p {
      font-size: 0.8rem;
    }
  }

  .paginate {
    justify-content: center;
  }
}

@media (max-width: 500px) {
  .chartSection {
    padding: 1rem;
  }

  .legendItem {
    flex: 1 1 100%;
  }
}

@media (max-width: 480px) {
  .branches {
    padding: 1rem;
  }

  .statsTitle {
    font-size: 1.1rem;
  }

  .statsDesc {
    font-size: 0.8rem;
  }

  .toggle button {
    font-size: 0.75rem;
    padding: 0.4rem 0.7rem;
  }
}