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

$border-light: rgba(0, 0, 0, 0.06);
$text-muted: #6b6b6b;
$primary-light: rgba(122, 75, 32, 0.08);

/* ================= PAGE ================= */
.page {
  @include dashPageComponent;
  height: 100%;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;

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

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

/* ================= CONTENT ================= */
.content {
  padding: 1rem 2.5rem;

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

.statsTitle {
  @include sectionTitle;
}

.statsDesc {
  @include sectionDescription;
}

/* ================= TOP BAR ================= */
.topBar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}

.search {
  flex: 1;
  display: flex;
  justify-content: flex-end;

  @media (max-width: 768px) {
    justify-content: flex-start;
    margin-top: 0.8rem;
  }
}

/* ================= CHART ================= */
.chartSection {
  @include dashPageComponent;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;

  margin-bottom: 2rem;
  overflow: hidden;

  /* -------- TABS -------- */
  .chartTabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;

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

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

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

      color: $text-muted;

      transition: all 0.2s ease;

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

  /* 🔥 ACTIVE STATE FIX (important) */
  .activeChart {
    background: $primary-soft-strong !important;
    color: $primary !important;
    border-color: $primary-border !important;
  }
}

/* ================= VIEW TOGGLE ================= */
.viewTabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;

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

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

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

    color: $text-muted;

    transition: all 0.2s ease;

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

  .activeView {
    background: $primary-soft-strong !important;
    color: $primary !important;
    border-color: $primary-border !important;
  }
}

/* ================= TABLE ================= */
.tableHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;

  @media (max-width: 1000px) {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }
}

.tableCard {
  margin-top: 2rem;
  width: 100%;
  overflow: hidden;
}

.tableWrapper {
  width: 100%;
  overflow-x: auto;
  border-radius: 12px;
}

/* SCROLLBAR */
.tableWrapper::-webkit-scrollbar {
  height: 6px;
}

.tableWrapper::-webkit-scrollbar-thumb {
  background: rgba(122, 75, 32, 0.2);
  border-radius: 10px;
}

/* TABLE SAFETY */
.tableWrapper table {
  min-width: 800px;
}

/* ================= RESPONSIVE ================= */
@media (max-width: 768px) {
  .actionsOptions {
    grid-template-columns: 1fr;
  }

  .actionCard {
    padding: 0.8rem;
  }

  .actionLeft {
    height: 2.2rem;
    width: 2.2rem;
  }

  .actionContent {
    h1 {
      font-size: 0.85rem;
    }

    p {
      font-size: 0.75rem;
    }
  }
}


.page,
.content {
  transform: none !important;
}

/* ================= MODAL OVERLAY ================= */
.modalOverlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;

  width: 100vw !important;
  height: 100vh !important;

  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);

  z-index: 999999 !important;

  /* 🔥 NO FLEX (important) */
}

/* ================= MODAL ================= */
.modal {
  position: fixed !important;

  top: 50% !important;
  left: 50% !important;

  transform: translate(-50%, -50%) !important;

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

  background: #ffffff;
  border-radius: 16px;

  padding: 1.8rem 1.6rem;

  border: 1px solid $border-light;
  box-shadow: 0 25px 60px rgba(122, 75, 32, 0.18);

  text-align: center;

  z-index: 1000000 !important;

  animation: modalIn 0.25s ease;

  max-height: 90vh;
  overflow-y: auto;

  /* 🔥 CRITICAL: Prevent movement */
  will-change: auto;

  h3 {
    font-size: 1rem;
    font-weight: 600;
    color: $text-dark;
    margin-bottom: 0.6rem;
  }

  p {
    font-size: 0.85rem;
    color: $text-muted;
    line-height: 1.6;
    margin-bottom: 1.4rem;
  }

  button {
    background: linear-gradient(135deg, $primary, $primary-2);
    color: #fff;

    padding: 0.65rem 1.5rem;
    border-radius: 12px;
    border: none;

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

    cursor: pointer;

    transition: all 0.25s ease;

    &:hover {
      transform: translateY(-2px);
      box-shadow: 0 12px 28px rgba(122, 75, 32, 0.25);
    }

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

/* ================= ANIMATION ================= */
@keyframes modalIn {
  from {
    opacity: 0;
    transform: translate(-50%, -45%) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.filterBar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;

  background: #ffffff;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid #f0e9e4;

  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 4px 12px rgba(94, 56, 23, 0.04);

  transition: all 0.2s ease;

  &:hover {
    box-shadow:
      0 2px 6px rgba(0, 0, 0, 0.05),
      0 8px 20px rgba(94, 56, 23, 0.06);
  }

  select {
    appearance: none;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #e6dcd2;
    background: #faf8f6;
    font-size: 14px;
    color: #1a1a1a;

    min-width: 150px;

    transition: all 0.2s ease;

    &:hover {
      border-color: #d6c2aa;
      background: #fff;
    }

    &:focus {
      outline: none;
      border-color: #7a4b20;
      background: #fff;
      box-shadow: 0 0 0 3px rgba(122, 75, 32, 0.08);
    }
  }
}

/* 🔥 CLEAR BUTTON (NOW PREMIUM) */
.clearBtn {
  background: #faf8f6;
  border: 1px solid #e6dcd2;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;

  color: #5e3817;

  cursor: pointer;
  transition: all 0.2s ease;

  &:hover {
    background: #f3ebe5;
    border-color: #d6c2aa;
  }

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

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

/* 🔥 LOADING OVERLAY (IMPROVED) */
.loadingOverlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.75);

  backdrop-filter: blur(2px);

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

  font-size: 14px;
  font-weight: 600;
  color: #5e3817;

  z-index: 20;
}

/* 🔥 MOBILE (CLEAN STACKING) */
@media (max-width: 768px) {
  .filterBar {
    flex-direction: column;
    align-items: stretch;
    padding: 14px;

    select,
    button {
      width: 100%;
    }
  }
}


.filterChips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 1rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  background: #f3ebe5;
  border: 1px solid #e6dcd2;
  color: #5e3817;

  padding: 6px 10px;
  border-radius: 999px;

  font-size: 13px;
  font-weight: 500;

  transition: all 0.2s ease;

  &:hover {
    background: #efe4db;
  }

  button {
    background: transparent;
    border: none;
    font-size: 14px;
    cursor: pointer;
    color: #7a4b20;
    display: flex;
    align-items: center;

    &:hover {
      color: #000;
    }
  }
}