@use 'variables' as v;

// ── Filter badge on the button ────────────────────────────────────────────

.filter-badge {
  margin-left: v.rhythm(0.5);
  font-weight: var(--font-weight-semi-bold);
}

// ── Backdrop (same pattern as side-panel-backdrop) ────────────────────────

.filter-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
}

// ── Sidebar panel ─────────────────────────────────────────────────────────

.filter-sidebar {
  position: fixed;
  top: var(--app-topbar-height, 0);
  right: 0;
  bottom: 0;
  width: 640px;
  max-width: 90vw;
  background: var(--color-neutral-lightest, #fff);
  border-left: 1px solid v.$color-neutral-lighter;
  z-index: 101;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.08);
  transition: width 0.2s ease;

  &.expanded {
    width: 65vw;
  }
}

.filter-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: v.rhythm(2) v.rhythm(3);
  border-bottom: 1px solid v.$color-neutral-lighter;
  position: sticky;
  top: 0;
  background: inherit;
  z-index: 1;

  h2 {
    margin: 0;
    line-height: 1;
  }

  .filter-sidebar-header-actions {
    display: flex;
    align-items: center;
    gap: v.rhythm(0.5);
  }
}

.filter-sidebar-body {
  padding: v.rhythm(2) v.rhythm(3);
  flex: 1;
  overflow-y: auto;
}

// ── Filter sections ───────────────────────────────────────────────────────

.filter-section {
  display: flex;
  flex-direction: column;
  gap: v.rhythm(1);
}

.section-title {
  margin-bottom: v.rhythm(1.5);
  color: var(--color-neutral-dark);
}

.filter-checkboxes,
.filter-radios {
  display: flex;
  flex-direction: column;
  gap: v.rhythm(1);
}

.separator-line {
  margin: v.rhythm(2) 0;
}

// ── Numeric condition builder ─────────────────────────────────────────────

.conditions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.condition-row {
  display: flex;
  gap: v.rhythm(1);
  align-items: center;
  margin-bottom: v.rhythm(1);
}

.condition-select {
  min-width: 0;
}

.condition-select:not(.condition-op):not(.condition-bool) {
  flex: 1;
}

.condition-op {
  flex: 1;
}

.condition-date-op {
  flex: 1;
}

.condition-bool {
  flex: 1;
}

.condition-value-input {
  width: v.rhythm(13);
  flex-shrink: 0;
}

.condition-input {
  width: v.rhythm(10);
  flex-shrink: 0;
  padding: v.rhythm(1) v.rhythm(1);
  border: 1px solid var(--color-neutral-light);
  border-radius: v.$border-radius-default;
  font-size: var(--font-size-s, 13px);
  background: var(--color-light-stronger);
  color: inherit;

  &:hover {
    border-color: var(--color-neutral-regular);
  }

  &:focus {
    border-color: var(--color-primary-regular);
  }
}

.condition-date-input {
  width: v.rhythm(16);
  flex-shrink: 0;
}

.condition-date-picker {
  min-width: v.rhythm(19);
  flex: 1;
}

.condition-time-input {
  width: v.rhythm(13);
  flex-shrink: 0;
}

.no-conditions {
  color: var(--color-neutral-regular);
  margin: v.rhythm(1) 0;
}

// ── Sticky footer ─────────────────────────────────────────────────────────

.filter-sidebar-footer {
  display: flex;
  gap: v.rhythm(1);
  padding: v.rhythm(2) v.rhythm(3);
  border-top: 1px solid v.$color-neutral-lighter;
  background: inherit;

  pa-button {
    flex: 1;

    // TODO: ::ng-deep is deprecated — replace when pa-button supports a fullWidth input
    // or when the host element styling approach is viable across all browsers.
    ::ng-deep .pa-button {
      width: 100%;
    }
  }
}

.disabled-hint {
  color: var(--color-neutral-regular);
  font-style: italic;
  margin: 0 0 v.rhythm(0.5);
}

// ── Date mode picker (text-tab style) ─────────────────────────────────────

.date-mode-selector {
  display: flex;
  align-items: center;
  gap: v.rhythm(0.5);
}

.date-mode-tab {
  background: none;
  border: none;
  padding: 0 v.rhythm(0.5);
  font-size: var(--font-size-s, 13px);
  color: var(--color-primary-regular);
  cursor: pointer;
  text-decoration: underline;
  line-height: 1.4;

  &:hover {
    color: var(--color-primary-dark);
  }
}

.date-mode-sep {
  color: var(--color-neutral-regular);
  font-size: var(--font-size-s, 13px);
  user-select: none;
}
