/* SPDX-License-Identifier: GPL-3.0-only
 * Copyright (c) 2026 AethelisDEV / Aeon Platform. All rights reserved.
 *
 * Component layer — buttons, cards, badges, form controls, metric tiles, segmented controls,
 * chips, menus and alerts.
 *
 * Every component is a single block class with modifiers. Nothing here reaches into another
 * component's internals, so a card can be dropped into a panel, a sheet or a grid unchanged.
 */

/* =============================================================================================
 * Buttons
 * =========================================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-s);
  font-size: var(--text-subhead);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-body);
  line-height: 1.25;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
  transition: background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}

.btn:active {
  transform: translateY(1px);
}

/* Opt-in rounding, for tabs and avatar-adjacent controls where a pill still reads correctly. */
.btn--pill {
  border-radius: var(--radius-pill);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.4;
  pointer-events: none;
}

.btn--primary {
  background-color: var(--brand);
  color: var(--brand-contrast);
}

.btn--primary:hover {
  background-color: var(--brand-hover);
}

.btn--secondary {
  background-color: var(--surface-raised);
  color: var(--label);
  border-color: var(--separator-strong);
}

.btn--secondary:hover {
  border-color: var(--brand);
  color: var(--accent-text);
}

/* Navy fill — the counterweight to the orange, used for secondary calls to action on a
 * white or periwinkle band where a bordered button would disappear. */
.btn--ink {
  background-color: var(--ink);
  color: var(--on-ink);
}

.btn--ink:hover {
  background-color: var(--ink-soft);
}

/* Outlined orange — "Read more" inside a navy panel, and quiet secondary actions. */
.btn--outline {
  background-color: transparent;
  color: var(--accent-text);
  border-color: var(--brand);
}

.btn--outline:hover {
  background-color: var(--brand);
  color: var(--brand-contrast);
}

.btn--ghost {
  background-color: transparent;
  color: var(--accent-text);
}

.btn--ghost:hover {
  background-color: var(--accent-soft);
}

.btn--tinted {
  background-color: var(--accent-soft);
  color: var(--accent);
}

.btn--tinted:hover {
  background-color: color-mix(in srgb, var(--accent) 18%, transparent);
}

.btn--critical {
  background-color: var(--critical);
  color: #fff;
}

.btn--on-media {
  background-color: rgba(255, 255, 255, 0.16);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  backdrop-filter: saturate(160%) blur(12px);
}

.btn--on-media:hover {
  background-color: rgba(255, 255, 255, 0.26);
}

.btn--large {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-body);
}

.btn--small {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-footnote);
}

.btn--block {
  inline-size: 100%;
}

.btn--icon {
  padding: var(--space-2);
  inline-size: 38px;
  block-size: 38px;
}

.btn__icon {
  inline-size: 1.1em;
  block-size: 1.1em;
  flex: none;
}

/* Directional icons (arrows, chevrons) mirror in Arabic. */
[dir="rtl"] .btn__icon--directional {
  transform: scaleX(-1);
}

/* =============================================================================================
 * Cards
 * =========================================================================================== */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background-color: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--separator);
  overflow: hidden;
  transition: transform var(--duration-base) var(--ease-out),
    box-shadow var(--duration-base) var(--ease-out),
    border-color var(--duration-base) var(--ease-out);
}

.card--interactive:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-m);
  border-color: transparent;
}

.card--flat {
  border-radius: var(--radius-l);
  box-shadow: none;
}

.card--raised {
  border-color: transparent;
  box-shadow: var(--shadow-s);
}

.card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5);
}

.card__title {
  font-size: var(--text-title-3);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-title);
}

.card__meta {
  font-size: var(--text-footnote);
  color: var(--label-tertiary);
}

/* A whole card is clickable via a stretched pseudo-element, which keeps the accessible name on
 * the real link instead of wrapping the entire card in an anchor. */
.card__link::after {
  content: "";
  position: absolute;
  inset: 0;
}

/* =============================================================================================
 * Panels — used by the owner and admin dashboards.
 * =========================================================================================== */
.panel {
  background-color: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
  border-block-end: 1px solid var(--separator);
}

.panel__title {
  font-size: var(--text-title-3);
  font-weight: var(--weight-semibold);
}

.panel__body {
  padding: var(--space-6);
}

/* =============================================================================================
 * Glass surface — the frosted material used by floating panels and overlay bars.
 * =========================================================================================== */
.glass {
  background-color: var(--material-thick);
  border: 1px solid var(--separator);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-l);
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass {
    background-color: var(--material-regular);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    backdrop-filter: saturate(180%) blur(24px);
  }
}

/* =============================================================================================
 * Badges
 * =========================================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.25rem var(--space-2);
  border-radius: var(--radius-xs);
  font-size: var(--text-caption-1);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide);
  line-height: 1.5;
  white-space: nowrap;
}

/* Solid orange — the year chip on a listing tile, and anything that must be seen first. */
.badge--brand {
  background-color: var(--brand);
  color: var(--brand-contrast);
}

/* The quiet slate chip that sits beside it. */
.badge--slate {
  background-color: rgba(255, 255, 255, 0.14);
  color: var(--on-ink);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.badge--neutral {
  background-color: var(--surface-sunken);
  color: var(--label-secondary);
}

.badge--accent {
  background-color: var(--accent-soft);
  color: var(--accent-text);
}

.badge--positive {
  background-color: var(--positive-soft);
  color: var(--positive);
}

.badge--notice {
  background-color: var(--notice-soft);
  color: var(--notice);
}

.badge--critical {
  background-color: var(--critical-soft);
  color: var(--critical);
}

.badge--muted {
  background-color: var(--surface-sunken);
  color: var(--label-tertiary);
}

.badge--on-media {
  background-color: rgba(21, 27, 37, 0.72);
  color: #fff;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

/* =============================================================================================
 * Metric tiles — large numeral, quiet caption. Used for platform stats and dashboard counters.
 * =========================================================================================== */
.metric {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-5);
  border-radius: var(--radius-l);
  background-color: var(--surface);
  border: 1px solid var(--separator);
}

.metric--bare {
  padding: 0;
  background: none;
  border: 0;
}

.metric__value {
  font-size: clamp(1.75rem, 1.2rem + 1.8vw, 2.5rem);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-display);
  line-height: var(--leading-tight);
  font-variant-numeric: tabular-nums;
}

.metric__label {
  font-size: var(--text-footnote);
  color: var(--label-secondary);
}

.metric__delta {
  font-size: var(--text-caption-1);
  font-weight: var(--weight-medium);
}

.metric__delta--up {
  color: var(--positive);
}

.metric__delta--down {
  color: var(--critical);
}

/* =============================================================================================
 * Segmented control — the iOS pill switch used for Buy/Rent and Residential/Commercial.
 *
 * Built from radio inputs so it works with no JavaScript, is keyboard-navigable by default and
 * submits with the surrounding form.
 * =========================================================================================== */
.segmented {
  display: inline-flex;
  gap: var(--space-2);
}

.segmented__option {
  position: relative;
  display: inline-flex;
}

.segmented__input {
  position: absolute;
  opacity: 0;
  inline-size: 100%;
  block-size: 100%;
  margin: 0;
  cursor: pointer;
}

.segmented__label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-s);
  border: 1px solid transparent;
  background-color: var(--surface-sunken);
  font-size: var(--text-subhead);
  font-weight: var(--weight-bold);
  color: var(--label-secondary);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.segmented__label:hover {
  color: var(--label);
}

/* The selected face is the *outlined* one, matching how the reference marks an active filter:
 * white ground, orange hairline, orange label. */
.segmented__input:checked + .segmented__label {
  background-color: var(--surface);
  border-color: var(--brand);
  color: var(--accent-text);
}

.segmented__input:focus-visible + .segmented__label {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------------------------------
 * Tab variant — flat text with an orange underline, used over the hero photograph.
 * ------------------------------------------------------------------------------------------- */
.segmented--tabs {
  gap: var(--space-6);
}

.segmented--tabs .segmented__label {
  padding: var(--space-2) 0;
  border: 0;
  border-block-end: 2px solid transparent;
  border-radius: 0;
  background: none;
  color: rgba(255, 255, 255, 0.72);
  font-size: var(--text-subhead);
  letter-spacing: var(--tracking-wide);
}

.segmented--tabs .segmented__label:hover {
  color: #fff;
}

.segmented--tabs .segmented__input:checked + .segmented__label {
  background: none;
  border-block-end-color: var(--brand);
  color: #fff;
}

/* =============================================================================================
 * Chips — removable filter tokens and quick links.
 * =========================================================================================== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  background-color: var(--surface);
  border: 1px solid var(--separator);
  font-size: var(--text-footnote);
  font-weight: var(--weight-medium);
  color: var(--label-secondary);
  transition: border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out);
}

.chip:hover {
  color: var(--label);
  border-color: var(--label-quaternary);
}

.chip--active {
  background-color: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}

/* =============================================================================================
 * Form controls
 * =========================================================================================== */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field__label {
  font-size: var(--text-footnote);
  font-weight: var(--weight-medium);
  color: var(--label-secondary);
}

.field__hint {
  font-size: var(--text-caption-1);
  color: var(--label-tertiary);
}

.field__error {
  font-size: var(--text-caption-1);
  font-weight: var(--weight-medium);
  color: var(--critical);
}

.input,
.select,
.textarea {
  inline-size: 100%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-m);
  border: 1px solid var(--border-field);
  background-color: var(--surface);
  color: var(--label);
  font-size: var(--text-subhead);
  transition: border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
  /* 16px minimum prevents iOS Safari from zooming the viewport on focus. */
  font-size: max(var(--text-subhead), 16px);
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--label-quaternary);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}

.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--critical);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--label-quaternary);
}

.textarea {
  min-block-size: 8rem;
  resize: vertical;
  line-height: var(--leading-normal);
}

.select {
  appearance: none;
  padding-inline-end: var(--space-10);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236e6e73' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5 8 10.5 12 6.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  background-size: 16px;
}

[dir="rtl"] .select {
  background-position: left var(--space-4) center;
}

/* Checkbox and radio built as accessible custom controls. */
.check {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--space-3);
  cursor: pointer;
  font-size: var(--text-subhead);
}

.check__input {
  flex: none;
  appearance: none;
  inline-size: 20px;
  block-size: 20px;
  margin-block-start: 2px;
  border: 1.5px solid var(--border-field);
  border-radius: var(--radius-xs);
  background-color: var(--surface);
  transition: background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}

.check__input[type="radio"] {
  border-radius: 50%;
}

.check__input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5 6.5 11.5 12.5 4.5'/%3E%3C/svg%3E");
  background-size: 14px;
  background-position: center;
  background-repeat: no-repeat;
}

.check__input[type="radio"]:checked {
  background-image: none;
  box-shadow: inset 0 0 0 4px var(--surface);
}

.check__input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Switch — iOS style toggle for boolean settings. */
.switch {
  position: relative;
  display: inline-flex;
  flex: none;
  inline-size: 51px;
  block-size: 31px;
}

.switch__input {
  position: absolute;
  opacity: 0;
  inline-size: 100%;
  block-size: 100%;
  margin: 0;
  cursor: pointer;
}

.switch__track {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-pill);
  background-color: var(--surface-sunken);
  border: 1px solid var(--separator);
  transition: background-color var(--duration-base) var(--ease-out);
  pointer-events: none;
}

.switch__thumb {
  position: absolute;
  inset-block-start: 2px;
  inset-inline-start: 2px;
  inline-size: 27px;
  block-size: 27px;
  border-radius: 50%;
  background-color: #fff;
  box-shadow: var(--shadow-s);
  transition: transform var(--duration-base) var(--ease-out);
  pointer-events: none;
}

.switch__input:checked ~ .switch__track {
  background-color: var(--positive);
  border-color: transparent;
}

.switch__input:checked ~ .switch__thumb {
  transform: translateX(20px);
}

[dir="rtl"] .switch__input:checked ~ .switch__thumb {
  transform: translateX(-20px);
}

.switch__input:focus-visible ~ .switch__track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* =============================================================================================
 * Alerts — flash messages after a redirect.
 * =========================================================================================== */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-l);
  font-size: var(--text-subhead);
  border: 1px solid transparent;
}

.alert--success {
  background-color: var(--positive-soft);
  color: var(--positive);
  border-color: color-mix(in srgb, var(--positive) 24%, transparent);
}

.alert--error {
  background-color: var(--critical-soft);
  color: var(--critical);
  border-color: color-mix(in srgb, var(--critical) 24%, transparent);
}

.alert--info {
  background-color: var(--accent-soft);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 24%, transparent);
}

.alert--warning {
  background-color: var(--notice-soft);
  color: var(--notice);
  border-color: color-mix(in srgb, var(--notice) 24%, transparent);
}

/* =============================================================================================
 * Menu — the popover used by the language, currency and account switchers.
 *
 * Implemented with <details>/<summary> so it opens, closes and traps focus correctly with no
 * JavaScript at all.
 * =========================================================================================== */
.menu {
  position: relative;
}

.menu > summary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--text-footnote);
  font-weight: var(--weight-medium);
  color: var(--label-secondary);
  cursor: pointer;
  list-style: none;
  transition: background-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu > summary:hover {
  background-color: var(--accent-soft);
  color: var(--label);
}

.menu[open] > summary {
  background-color: var(--accent-soft);
  color: var(--label);
}

.menu__panel {
  position: absolute;
  inset-block-start: calc(100% + var(--space-2));
  inset-inline-end: 0;
  z-index: 120;
  min-inline-size: 200px;
  max-block-size: min(60vh, 420px);
  overflow-y: auto;
  padding: var(--space-2);
  border-radius: var(--radius-l);
  background-color: var(--material-thick);
  border: 1px solid var(--separator);
  box-shadow: var(--shadow-l);
  animation: menu-in var(--duration-fast) var(--ease-out);
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .menu__panel {
    background-color: var(--material-regular);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    backdrop-filter: saturate(180%) blur(24px);
  }
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-s);
  font-size: var(--text-subhead);
  color: var(--label);
  transition: background-color var(--duration-fast) var(--ease-out);
}

.menu__item:hover {
  background-color: var(--accent-soft);
}

.menu__item[aria-current="true"] {
  font-weight: var(--weight-semibold);
  color: var(--accent);
}

.menu__separator {
  block-size: 1px;
  margin: var(--space-2) var(--space-1);
  background-color: var(--separator);
}

/* =============================================================================================
 * Empty state
 * =========================================================================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-16) var(--space-6);
  text-align: center;
  color: var(--label-secondary);
}

.empty-state__title {
  font-size: var(--text-title-2);
  font-weight: var(--weight-semibold);
  color: var(--label);
}

/* =============================================================================================
 * Pagination
 * =========================================================================================== */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-block-start: var(--space-16);
}

.pagination__item {
  display: inline-grid;
  place-items: center;
  min-inline-size: 44px;
  block-size: 44px;
  padding-inline: var(--space-3);
  border-radius: 50%;
  font-size: var(--text-subhead);
  font-weight: var(--weight-bold);
  color: var(--label-secondary);
  border: 1px solid transparent;
  font-variant-numeric: tabular-nums;
  transition: background-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.pagination__item:hover {
  background-color: var(--surface-sunken);
  color: var(--label);
}

/* The current page is a tinted disc rather than a solid one: a row of numbers is navigation, and a
 * solid orange button in the middle of it reads as the primary action on the page. */
.pagination__item[aria-current="page"] {
  background-color: var(--accent-soft);
  color: var(--accent-text);
}
