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

/* ================= GLOBAL ================= */

$control-height: 42px;

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

.analytics {
  @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 ================= */

.content {
  padding: 1rem 2.5rem;

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

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

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

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ================= FILTERS ================= */

.filters {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: flex-end;
}

/* ================= DATE ================= */

.dateGroup {
  display: flex;
  gap: 0.4rem;
  position: relative; /* 🔥 needed for dropdown */
}

.dateBox {
  height: $control-height;
  min-width: 140px;

  background: #fff;
  border: 1px solid $border;
  border-radius: 12px;

  padding: 0.35rem 0.7rem;

  cursor: pointer;

  display: flex;
  flex-direction: column;
  justify-content: center;

  transition: all 0.2s ease;

  span {
    font-size: 0.65rem;
    color: $text-light;
  }

  p {
    font-size: 0.8rem;
    font-weight: 600;
    color: $text-dark;
  }

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

/* ================= DATE PICKER DROPDOWN ================= */

.datePickerDropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;

  z-index: 999;

  width: 100%;
  max-width: 320px;

  animation: fadeIn 0.2s ease;
}

/* ================= CALENDAR ================= */

.calendar {
  width: 100%;
  background: #fff;

  border-radius: 14px;
  border: 1px solid $border;

  padding: 0.9rem;

  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.12),
    0 6px 14px rgba(0, 0, 0, 0.06);
}

/* ================= CALENDAR HEADER ================= */

.calendarHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;

  margin-bottom: 0.6rem;

  h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: $text-dark;
  }

  button {
    border: none;
    background: $primary-soft;
    color: $primary;

    border-radius: 8px;
    padding: 0.3rem 0.55rem;

    cursor: pointer;

    transition: all 0.2s ease;

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

/* ================= CALENDAR GRID ================= */

.calendarGrid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25rem;

  span {
    font-size: 0.65rem;
    text-align: center;
    color: $text-light;
  }

  button {
    height: 34px;
    border-radius: 8px;
    border: none;

    font-size: 0.75rem;
    font-weight: 500;

    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    transition: all 0.2s ease;

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

    &:active {
      transform: scale(0.92);
    }

    &:disabled {
      opacity: 0;
      pointer-events: none;
    }
  }
}

/* ================= SELECT ================= */

.selectWrap {
  height: $control-height;
  min-width: 150px;

  select {
    height: 100%;
    width: 100%;

    padding: 0 0.7rem;

    border-radius: 10px;
    border: 1px solid $border;

    font-size: 0.8rem;

    &:focus {
      outline: none;
      border-color: $primary;
    }
  }
}

/* ================= ACTIONS ================= */

.actions {
  display: flex;
  gap: 0.4rem;
}

.actions button {
  height: $control-height;
  padding: 0 0.85rem;
  cursor: pointer;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 500;

  display: flex;
  align-items: center;
  justify-content: center;

  white-space: nowrap;
}

/* BUTTON VARIANTS */

.apply {
  background: $primary;
  color: #fff;
  border: none;
}

.clear {
  border: 1px solid $border;
  background: #fff;
  color: $text-light;
}

.export {
  background: $primary-soft;
  color: $primary;
  border: none;
}

/* ================= TABS ================= */

.tabs {
  display: flex;
  gap: 0.3rem;
  margin-top: 1.5rem;

  overflow-x: auto;

  padding: 0.3rem;

  border-radius: 14px;
  border: 1px solid $border;
  background: #fff;

  width: 100%;

  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs button {
  flex: 0 0 auto;
  cursor: pointer;

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

  font-size: 0.85rem;
  font-weight: 600;

  color: $text-light;

  white-space: nowrap;

  transition: all 0.2s ease;
}

.tabs button:hover {
  color: $primary;
}

.tabs .active {
  background: $primary-soft;
  color: $primary;
}

/* ================= CONTENT ================= */

.tabContent {
  margin-top: 1.5rem;
}

.slideRight {
  animation: slideRight 0.3s ease;
}

.slideLeft {
  animation: slideLeft 0.3s ease;
}

@keyframes slideRight {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
}

@keyframes slideLeft {
  from {
    opacity: 0;
    transform: translateX(-40px);
  }
}

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

.chartSection {
  @include dashPageComponent;
  padding: 1.2rem;

  transition: all 0.25s ease;

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

  h2 {
    font-size: 1rem;
    font-weight: 600;
  }
}

/* ================= ANIMATION ================= */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

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

@media (max-width: 1024px) {
  .filters {
    justify-content: flex-start;
  }
}

@media (max-width: 768px) {
  .header {
    flex-direction: column;
  }

  .filters {
    flex-direction: column;
    align-items: stretch;
  }

  .dateGroup {
    width: 100%;
  }

  .selectWrap {
    width: 100%;
  }

  .actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .actions button {
    width: 100%;
  }
}

/* ================= MOBILE CALENDAR ================= */

@media (max-width: 500px) {
  .datePickerDropdown {
    position: fixed;

    left: 50%;
    transform: translateX(-50%);

    bottom: 0;
    top: auto;

    width: 100%;
    max-width: 420px;

    padding: 0.8rem;
  }

  .calendar {
    border-radius: 16px 16px 0 0;
  }
}