/*
================================================================================
  ML Software, LLC
  Copyright 2026. All rights reserved.

  IQ Platform - _app/assets/css/components.css

  Platform: 0.1.1
  Version: 0.1.2
  Created: 2026-04-27
  Updated: 2026-04-27

  Description: Visual styles for every class views-core.js produces.
  This file is the visual contract for IQ.core, IQ.tooltip, and the
  shared component vocabulary.

  Components covered:
    - Modal (.iq-modal-*, body.iq-modal-open)
    - Toast (.iq-toast, .iq-toast--*)
    - Inline confirm strip (.iq-inline-confirm)
    - Confirm dialog actions (.iq-confirm-*)
    - Danger zone (.iq-danger-zone)
    - Table (.iq-table, .iq-table-wrap, tr.clickable)
    - Loading / empty / error blocks (.iq-loading, .iq-empty, .iq-error-block)
    - Spinner (.spinner)
    - Badges (.badge, .badge--*)
    - Buttons (.btn, .btn-primary, .btn-danger, .btn-ghost, .btn-block, .btn-sm)
    - Tooltip system (.iq-tip-icon, .iq-tooltip-bubble)

  Load order: tokens.css -> base.css -> shell.css -> components.css.

  Version History:
    0.1.2 - 2026-04-27 - Burgundy color migration. Per the kickoff
                         §5.8 locked decision (which the Session 3
                         CSS port missed), the destructive color is
                         burgundy not coral. Every hardcoded
                         rgba(255, 100, 80, ...) reference was
                         removed and replaced with a token from the
                         new red companion set in tokens.css 0.1.2:
                         --red, --red-hover, --red-text, --red-dim,
                         --red-bord. Affected: .badge--red,
                         .iq-error-block, .iq-toast--error,
                         .iq-inline-confirm--danger, .iq-danger-zone,
                         .iq-danger-zone-header, .btn-danger:hover.
                         Also corrected several `color: var(--red)`
                         uses to `var(--red-text)` -- burgundy at
                         #7a1f24 is unreadable as foreground text on
                         dark surfaces.
    0.1.1 - 2026-04-27 - Session 3 cont'd. Readability and
                         touch-target floor pass:
                         - .badge font-size 11px -> 12px
                         - .iq-table th font-size 11px -> 12px
                         - .iq-danger-zone-description 13px -> 14px
                         - .iq-tooltip-bubble 13px -> 14px
                         - .iq-modal-close grew from ~34px hit area
                           to 40px desktop / 44px touch
                         Touch-coarse override bumps badge,
                         table-th, and other display small caps
                         from 12px -> 13px on phones and tablets
                         where letter-spacing alone is not enough
                         for field readability.
    0.1.0 - 2026-04-27 - Session 3 initial. Modal extracted from JQiq
                         1.9.5 (the most recent and cleanest modal
                         block in the source apps). Toast pattern
                         from JQiq with the click-to-dismiss error
                         variant from DZIQ 3.22.8. Tables, badges,
                         buttons reconciled across all three apps
                         (the patterns were nearly identical;
                         standardized on the JQiq form). Inline
                         confirm and danger zone are NEW (no source
                         in the legacy apps -- designed to match
                         the RIQ permit-detail inline-delete pattern
                         in the screenshot reviewed during Session 2).
                         Tooltip styles ported verbatim from JQiq
                         lines 1405-1444.
================================================================================
*/

/* ============================================================================
   Buttons
   .btn is the base; .btn-primary, .btn-danger, .btn-ghost are variants.
   Used by every component (modal actions, danger zone, inline confirm)
   so it lives near the top of the file.
   ============================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  min-height: var(--touch-target-min);
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--t-fast),
              color var(--t-fast),
              border-color var(--t-fast),
              opacity var(--t-fast);
  text-decoration: none;
  white-space: nowrap;
  background: var(--bg-raised);
  color: var(--text-primary);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-light);
  border-color: var(--accent-light);
}

.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.btn-danger:hover:not(:disabled) {
  background: var(--red-hover);
  border-color: var(--red-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-light);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--border);
  background: var(--bg-raised);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 13px;
}

@media (pointer: coarse) {
  .btn { min-height: var(--touch-target-touch); padding: 12px 18px; }
  .btn-sm { min-height: var(--touch-target-min); padding: 8px 12px; }
}


/* ============================================================================
   Badges
   Soft-fill colored pills. Used by IQ.core.statusBadge() and any
   product code that needs a status indicator.
   ============================================================================ */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge--blue   { background: var(--accent-dim);                color: var(--accent);        }
.badge--green  { background: rgba(76,  255, 145, 0.12);        color: var(--green);         }
.badge--yellow { background: rgba(255, 200,  50, 0.12);        color: var(--yellow);        }
.badge--red    { background: var(--red-dim);                   color: var(--red-text);      }
.badge--orange { background: rgba(255, 156,  58, 0.12);        color: var(--orange);        }
.badge--purple { background: rgba(180, 100, 255, 0.12);        color: var(--purple);        }
.badge--gray   { background: rgba(144, 144, 168, 0.12);        color: var(--text-secondary); }


/* ============================================================================
   Tables
   IQ.core.buildTable() produces this markup.
   ============================================================================ */

.iq-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}

.iq-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.iq-table thead tr {
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
}

.iq-table th {
  text-align: left;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 12px 16px;
  white-space: nowrap;
}

.iq-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

.iq-table tbody tr:last-child td {
  border-bottom: none;
}

.iq-table tbody tr:hover {
  background: var(--bg-raised);
}

.iq-table tbody tr.clickable {
  cursor: pointer;
}


/* ============================================================================
   Loading / empty / error blocks
   IQ.core.loading(), IQ.core.empty(), IQ.core.errorBlock()
   ============================================================================ */

.iq-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: iqSpin 0.8s linear infinite;
}

@keyframes iqSpin {
  to { transform: rotate(360deg); }
}

.iq-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}

.iq-empty p {
  margin: 0;
  font-size: 14px;
}

.iq-error-block {
  padding: 16px 20px;
  background: var(--red-dim);
  border: 1px solid var(--red-bord);
  border-radius: var(--radius);
  color: var(--red-text);
}

.iq-error-block p {
  margin: 0;
  font-size: 14px;
}


/* ============================================================================
   Modal
   IQ.core.openModal() produces the overlay + modal markup.
   body gets .iq-modal-open while a modal is mounted (locks scroll).
   ============================================================================ */

body.iq-modal-open {
  overflow: hidden;
}

.iq-modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: var(--z-modal);
  animation: iqModalFade var(--t-fast) ease-out;
}

@keyframes iqModalFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.iq-modal {
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  animation: iqModalSlide var(--t-medium) ease-out;
}

@keyframes iqModalSlide {
  from { transform: translateY(8px); opacity: 0.6; }
  to   { transform: translateY(0);   opacity: 1; }
}

.iq-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.iq-modal-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0;
}

.iq-modal-close {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  width: var(--touch-target-min);
  height: var(--touch-target-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: color var(--t-fast), background var(--t-fast);
}

@media (pointer: coarse) {
  .iq-modal-close {
    width: var(--touch-target-touch);
    height: var(--touch-target-touch);
  }
}

.iq-modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-raised);
}

.iq-modal-body {
  padding: 22px;
  overflow-y: auto;
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.55;
}

.iq-modal-body p {
  margin: 0 0 14px 0;
}

.iq-modal-body p:last-child {
  margin-bottom: 0;
}

/* Confirm dialog action row (rendered inside .iq-modal-body by IQ.core.confirm) */
.iq-confirm-message {
  font-size: 15px;
  color: var(--text-primary);
  margin: 0 0 18px 0;
}

.iq-confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 6px;
}

@media (max-width: 480px) {
  .iq-modal {
    max-width: calc(100vw - 24px);
  }
  .iq-confirm-actions {
    flex-direction: column-reverse;
  }
  .iq-confirm-actions .btn {
    width: 100%;
  }
}


/* ============================================================================
   Inline confirm strip
   IQ.core.inlineConfirm() inserts this as a sibling of the anchor
   element. Designed to match the RIQ permit-detail inline-delete
   pattern: subtle dark surface for normal use, red-tinted surface
   when .iq-inline-confirm--danger.
   ============================================================================ */

.iq-inline-confirm {
  margin: 12px 0;
  padding: 16px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  animation: iqInlineFade var(--t-fast) ease-out;
}

.iq-inline-confirm--danger {
  background: var(--red-dim);
  border-color: var(--red-bord);
}

@keyframes iqInlineFade {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0);    }
}

.iq-inline-confirm-message {
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.iq-inline-confirm-actions {
  display: flex;
  gap: 10px;
}

.iq-inline-confirm-actions .btn {
  flex: 1;
}

@media (min-width: 640px) {
  .iq-inline-confirm-actions .btn {
    flex: 0 0 auto;
    min-width: 140px;
  }
}


/* ============================================================================
   Danger zone
   IQ.core.dangerZone() produces this. GitHub-style settings block
   for irreversible actions.
   ============================================================================ */

.iq-danger-zone {
  border: 1px solid var(--red-bord);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  overflow: hidden;
}

.iq-danger-zone-header {
  padding: 12px 18px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--red-text);
  background: var(--red-dim);
  border-bottom: 1px solid var(--red-bord);
}

.iq-danger-zone-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.iq-danger-zone-row:last-child {
  border-bottom: none;
}

.iq-danger-zone-text {
  flex: 1;
  min-width: 0;
}

.iq-danger-zone-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.iq-danger-zone-description {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.iq-danger-zone-action {
  flex-shrink: 0;
}

.iq-danger-zone-btn {
  white-space: nowrap;
}

@media (max-width: 480px) {
  .iq-danger-zone-row {
    flex-direction: column;
    align-items: stretch;
  }
  .iq-danger-zone-action .btn {
    width: 100%;
  }
}


/* ============================================================================
   Toast notifications
   IQ.core.toast() produces this. Single bottom-screen element,
   click-to-dismiss for error toasts.
   ============================================================================ */

.iq-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  min-width: 240px;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-toast);
  opacity: 0;
  transition: opacity var(--t-medium), transform var(--t-medium);
  pointer-events: none;
  z-index: var(--z-toast);
}

.iq-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.iq-toast--success {
  background: var(--green);
  color: #0a1a10;
}

.iq-toast--info {
  background: var(--bg-overlay);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

/* Error toasts: brighter, click-to-dismiss, longer-duration. */
.iq-toast--error {
  background: var(--bg-base);
  color: var(--red-text);
  border: 1px solid var(--red-text);
  box-shadow: 0 0 0 1px var(--red-bord) inset, var(--shadow-toast);
  cursor: pointer;
  pointer-events: auto;
}

.iq-toast--error.iq-toast--visible {
  pointer-events: auto;
}


/* ============================================================================
   Tooltip system
   IQ.tooltip.icon() emits .iq-tip-icon; the shared bubble is
   #iq-tooltip-bubble (also styled with .iq-tooltip-bubble).
   ============================================================================ */

.iq-tip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  color: var(--text-dim);
  cursor: help;
  vertical-align: middle;
  margin-left: 4px;
  border-radius: 50%;
  transition: color var(--t-fast);
}

.iq-tip-icon:hover,
.iq-tip-icon:focus-visible {
  color: var(--accent);
  outline: none;
}

.iq-tooltip-bubble {
  position: absolute;
  display: none;
  max-width: 280px;
  padding: 10px 12px;
  background: var(--bg-overlay);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.45;
  box-shadow: var(--shadow-pop);
  pointer-events: none;
  z-index: var(--z-tooltip);
  opacity: 0;
  transition: opacity var(--t-fast);
}

/* When the bubble is positioned above an iq-tip-icon, allow it to
   receive pointer events (so users can hover the bubble itself
   without it disappearing). The JS toggles this. */
.iq-tooltip-bubble.iq-tooltip--pinned {
  pointer-events: auto;
}


/* ============================================================================
   Touch override (coarse pointer)
   On phones and tablets, display-font small caps need a notch up
   despite their letter-spacing. This block bumps the floor for
   small-caps elements and tooltip body text.
   ============================================================================ */

@media (pointer: coarse) {

  .badge {
    font-size: 13px;  /* up from 12 */
  }

  .iq-table th {
    font-size: 13px;  /* up from 12 */
  }

  .iq-danger-zone-description {
    font-size: 15px;  /* up from 14 */
  }

  .iq-tooltip-bubble {
    font-size: 15px;  /* up from 14 */
    max-width: 320px;
  }

  .iq-confirm-message {
    font-size: 16px;  /* up from 15 -- modal body text */
  }

  .iq-inline-confirm-message {
    font-size: 15px;  /* up from 14 -- inline confirm body */
  }

}