/**
 * AHMED / NESMA — Phase 1 shared UI foundation
 * Buttons, inputs, badges, tables, filters, focus, motion — visual only.
 */

/* ========== Focus ========== */
:focus-visible {
  outline: 2px solid var(--focus-ring-color, var(--primary));
  outline-offset: 2px;
}

.q-btn:focus-visible,
.ag-nav-link:focus-visible,
a.ag-cc-more:focus-visible {
  outline: 2px solid var(--focus-ring-color, var(--primary));
  outline-offset: 2px;
}

/* ========== Button hierarchy ========== */
.ag-btn-primary,
.q-btn.ag-btn-primary {
  background: var(--interactive-primary, var(--primary)) !important;
  color: var(--text-on-primary, var(--text-inverse)) !important;
  border: 1px solid transparent !important;
  font-weight: 600 !important;
  letter-spacing: 0.01em;
  transition:
    background var(--motion-fast) var(--ag-ease),
    border-color var(--motion-fast) var(--ag-ease),
    transform var(--motion-fast) var(--ag-ease);
}

.ag-btn-primary:hover,
.q-btn.ag-btn-primary:hover {
  background: var(--interactive-primary-hover, var(--primary-hover)) !important;
}

.ag-btn-secondary,
.q-btn.ag-btn-secondary {
  background: var(--surface-primary) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-default) !important;
  font-weight: 500 !important;
  min-height: var(--ag-control-h) !important;
  text-transform: none !important;
  box-shadow: none !important;
}

.ag-btn-secondary:hover,
.q-btn.ag-btn-secondary:hover {
  background: var(--surface-hover) !important;
  border-color: var(--border-strong) !important;
}

.ag-btn-ghost,
.q-btn.ag-btn-ghost {
  font-weight: 500 !important;
  transition: background var(--motion-fast) var(--ag-ease), border-color var(--motion-fast) var(--ag-ease);
}

.ag-btn-danger,
.q-btn.ag-btn-danger {
  background: transparent !important;
  color: var(--status-critical-text) !important;
  border: 1px solid color-mix(in srgb, var(--status-critical-text) 35%, transparent) !important;
  font-weight: 500 !important;
  text-transform: none !important;
}

.ag-btn-danger:hover,
.q-btn.ag-btn-danger:hover {
  background: color-mix(in srgb, var(--status-critical-bg) 55%, transparent) !important;
}

/* ========== Badges ========== */
.ag-badge,
[class^="ag-badge-"] {
  min-height: 1.375rem;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: var(--type-xs, 0.8125rem);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* ========== Tables (baseline) ========== */
.ag-table-wrap .q-table thead tr,
.ag-table-wrap .q-table th {
  font-size: var(--type-xs, 0.8125rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
}

.ag-table-wrap .q-table td {
  font-size: var(--type-sm, 0.875rem);
  vertical-align: middle;
}

.ag-table-wrap .q-table tbody tr {
  transition: background var(--motion-fast) var(--ag-ease);
}

/* ========== Filter baseline ========== */
.ag-actions-filter-trigger,
.ag-cc-filter-btn,
.ag-mail-btn--ghost {
  min-height: var(--ag-control-h);
  padding: 0 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--surface-primary);
  color: var(--text-secondary);
  font-size: var(--type-sm);
  font-weight: 500;
  transition:
    background var(--motion-fast) var(--ag-ease),
    border-color var(--motion-fast) var(--ag-ease),
    color var(--motion-fast) var(--ag-ease);
}

.ag-actions-filter-trigger:hover,
.ag-cc-filter-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.ag-actions-filter-trigger--active,
.ag-cc-filter-btn.is-active {
  background: var(--surface-selected);
  border-color: var(--border-strong);
  color: var(--text-primary);
  box-shadow: inset var(--brand-progress-marker-w) 0 0 0 var(--brand-progress-marker);
}

.ag-actions-filter-popover,
.ag-mail-filter-pop,
.ag-header-menu {
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-elevated) !important;
}

/* ========== Sidebar institutional treatment ========== */
.ag-sidebar {
  background: linear-gradient(
    180deg,
    var(--sidebar-bg-secondary) 0%,
    var(--sidebar-bg) 100%
  );
}

.ag-nav-link {
  transition:
    background var(--motion-fast) var(--ag-ease),
    color var(--motion-fast) var(--ag-ease),
    border-color var(--motion-fast) var(--ag-ease);
}

.ag-nav-link.active {
  background: var(--sidebar-active);
  border-left-width: var(--brand-progress-marker-w);
  border-left-color: var(--sidebar-rail, var(--brand-progress-marker));
}

.ag-brand-mark {
  border-radius: var(--radius-md);
  background: linear-gradient(
    165deg,
    color-mix(in srgb, var(--brand-teal) 88%, white),
    var(--brand-dark-teal)
  );
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

/* ========== Top bar ========== */
.ag-header {
  min-height: var(--layout-header-h);
  backdrop-filter: blur(10px);
}

.ag-header-actions .q-btn:not(.ag-user-trigger) {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: background var(--motion-fast) var(--ag-ease), color var(--motion-fast) var(--ag-ease);
}

.ag-header-actions .q-btn:not(.ag-user-trigger):hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

/* ========== Page header typography ========== */
.ag-page-header h1 {
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

.ag-page-header p {
  font-size: var(--type-sm);
  color: var(--text-secondary);
  line-height: 1.45;
}

/* ========== Empty states (compact) ========== */
.ag-empty {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  background: var(--surface-secondary);
  border: 1px solid var(--border-subtle);
  font-size: var(--type-sm);
  color: var(--text-secondary);
}

/* ========== Dialogs / menus — restrained elevation ========== */
.q-dialog__inner > .q-card,
.q-dialog__inner > .ag-card,
.q-dialog__inner > .ag-dialog {
  border-radius: var(--radius-xl) !important;
  box-shadow: var(--shadow-elevated);
}

.q-menu {
  border-radius: var(--radius-lg) !important;
}

/* ========== Reduced motion ========== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .ag-btn-primary:hover,
  .q-btn.ag-btn-primary:hover {
    transform: none !important;
  }
}
