/* =============================================================================
   BASE & RESET STYLES
   Global HTML element defaults: box model, typography, links, and body settings.
   ============================================================================= */

* {
  box-sizing: border-box;
}

/* The hidden attribute always wins over component display rules (A20): views
   show and hide elements by toggling .hidden instead of writing style.display */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 0 0 0.5rem 0;
}

/* Tabular Numbers Enforcement */
table,
.tabular-nums,
.stat-value,
.badge-number,
.metric-figure,
time,
.number-cell {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* Uppercase tracking fix */
.uppercase-label,
.badge-label,
th {
  letter-spacing: 0.05em;
}

/* Interactive Element Press Physics & Micro-Interactions */
button,
.btn,
.clickable {
  font-family: var(--font-sans);
  cursor: pointer;
  border: none;
  background: none;
  position: relative;
  transition: scale var(--duration-fast) var(--ease-out),
              background-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}

button:active,
.btn:active,
.clickable:active {
  scale: 0.97 !important;
}

/* 44px Minimum Touch Hit Target Overlay */
.icon-btn,
button.icon-only {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn::before,
button.icon-only::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: max(100%, 44px);
  height: max(100%, 44px);
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

/* Tooltip System for Icon Buttons */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--tooltip-bg);
  color: var(--tooltip-ink);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out),
              visibility var(--duration-fast);
  z-index: 1000;
  box-shadow: var(--shadow-md);
}

[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

input,
select,
textarea {
  font-family: var(--font-sans);
}

code,
pre,
kbd,
samp {
  font-family: var(--font-mono);
}

a {
  color: inherit;
  text-decoration: none;
}


/* ---------- Keyboard focus ----------
   One visible ring for every focusable element (skill 9). Text inputs keep their own
   border + glow focus style; everything else gets this outline. */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Sidebar entries are real links now: keep the nav look */
a.nav-item {
  text-decoration: none;
}

/* ---------- Lucide icon sizes for controls that used to hold text symbols (A16) ---------- */
.drawer-close svg { width: 20px; height: 20px; }
.crumb-sep { width: 14px; height: 14px; vertical-align: -2px; opacity: 0.7; }
.pager button svg { width: 16px; height: 16px; }
.btn-entra-chev svg,
.btn-signin svg { width: 16px; height: 16px; vertical-align: -3px; }
.mobile-nav-toggle svg { width: 22px; height: 22px; }
.modal-head h2 svg { width: 20px; height: 20px; flex-shrink: 0; }
.drawer-header svg,
#closeActivityDrawerBtn svg,
#inspCloseBtn svg { width: 16px; height: 16px; }

/* Remove-tag button (e.g. revoke table access) */
.tag-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: var(--space-1);
  padding: 0;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--err);
  cursor: pointer;
}
.tag-remove:hover { background: var(--err-soft); }
.tag-remove svg { width: 14px; height: 14px; }


/* ---------- Icon sizes (A20) ----------
   Lucide copies the <i>'s classes onto the <svg> it draws. The size classes are
   doubled (.ic.ic-16) so they beat container rules such as ".btn > svg", the way
   the inline width/height they replace used to. */
.ic { flex-shrink: 0; }
.ic.ic-11 { width: 11px; height: 11px; }
.ic.ic-12 { width: 12px; height: 12px; }
.ic.ic-14 { width: 14px; height: 14px; }
.ic.ic-16 { width: 16px; height: 16px; }
.ic.ic-18 { width: 18px; height: 18px; }
.ic.ic-20 { width: 20px; height: 20px; }
.ic.ic-22 { width: 22px; height: 22px; }
.ic.ic-32 { width: 32px; height: 32px; }
.ic-inline { vertical-align: -2px; }          /* sits on the text baseline */
.ic-spin { animation: spinIcon 1s linear infinite; }
.ic-accent { color: var(--accent); }

/* ---------- Small shared layout helpers (A20) ---------- */
/* Icon + text (or a few controls) side by side */
.inline-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Accent-coloured icon beside a dialog or panel title */
.title-icon {
  display: inline-flex;
  color: var(--accent);
}

.text-muted { color: var(--muted); }

/* Compact button text inside dense panels (import dialog, filters) */
.btn.btn-xs { font-size: 0.78rem; }

/* ---------- Reduced motion (A7) ----------
   People who ask their OS for less motion get no slides, scales, blurs or
   shimmer: transitions and one-shot animations finish instantly, so drawers
   and dialogs simply appear. Spinners keep turning because they are the only
   sign that slow work is still running. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }

  button:active,
  .btn:active,
  .clickable:active {
    scale: none;
  }

  .skeleton-bar {
    animation: none !important;
  }

  .btn.refresh-btn.spinning .icon,
  .menu-item.spinning .icon,
  .ic-spin {
    animation-duration: 1.2s !important;
    animation-iteration-count: infinite !important;
  }
}

/* ---------- Screen-reader-only text ----------
   Read by assistive technology, invisible on screen (e.g. an icon-only column's header). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
