/* ============================================================
   Atelier — Components

   Drop-in classes for the recurring UI vocabulary of the system.
   In React/JSX you'd compose with the tokens directly; in static
   markup these classes are enough.

   Naming: a- prefix (atelier).
   ============================================================ */

/* tokens.css est chargé séparément par index.html — pas besoin de l'importer ici. */

/* ============================================================
   TYPOGRAPHY HELPERS — semantic classes
   Hierarchy comes from weight + size + tracking. ONE family.
   ============================================================ */

.a-display {
    font-family: var(--font-sans);
    font-size: var(--fs-3xl);
    font-weight: var(--weight-semibold);
    line-height: var(--lh-tight);
    letter-spacing: var(--tracking-tight);
    color: var(--ink);
}
.a-h1 {
    font-size: var(--fs-2xl);
    font-weight: var(--weight-semibold);
    line-height: var(--lh-tight);
    letter-spacing: var(--tracking-h);
    color: var(--ink);
    margin: 0;
}
.a-h2 {
    font-size: var(--fs-xl);
    font-weight: var(--weight-semibold);
    line-height: var(--lh-snug);
    letter-spacing: var(--tracking-h);
    color: var(--ink);
    margin: 0;
}
.a-h3 {
    font-size: var(--fs-lg);
    font-weight: var(--weight-semibold);
    line-height: var(--lh-snug);
    color: var(--ink);
    margin: 0;
}
.a-body  { font-size: var(--fs-base); color: var(--ink-2); }
.a-text  { font-size: var(--fs-md);   color: var(--ink-2); }
.a-small { font-size: var(--fs-sm);   color: var(--ink-3); }
.a-tiny  { font-size: var(--fs-xs);   color: var(--ink-4); }

.a-label {
    font-size: var(--fs-2xs);
    font-weight: var(--weight-medium);
    color: var(--ink-3);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
}

.a-mono {
    font-family: var(--font-mono);
    font-size: 0.92em;
    color: var(--ink-3);
    font-feature-settings: "calt" 0;
}

.a-link {
    color: var(--primary);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: color var(--dur-fast) var(--ease);
}
.a-link:hover { color: var(--primary-hover); }

/* Muted helpers */
.a-muted    { color: var(--ink-3); }
.a-quiet    { color: var(--ink-4); }

/* ============================================================
   BUTTONS — five variants
   default = secondary (most common), primary used sparingly.
   No floating gradient pills. No glow.
   ============================================================ */

.a-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: var(--control-h);
    padding: 0 var(--space-3);
    font-family: var(--font-sans);
    font-size: var(--fs-md);
    font-weight: var(--weight-medium);
    line-height: 1;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-sm);
    cursor: pointer;
    user-select: none;
    transition: background-color var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease);
    white-space: nowrap;
}
.a-btn:hover  { background: var(--surface-hover); border-color: var(--rule-strong); }
.a-btn:active { background: var(--surface-press); }
.a-btn:disabled,
.a-btn[aria-disabled="true"] { color: var(--ink-5); background: var(--surface); cursor: not-allowed; }

/* Primary — the per-tenant accent. Use ONCE per panel, max. */
.a-btn-primary {
    background: var(--primary);
    color: var(--primary-ink);
    border-color: var(--primary);
}
.a-btn-primary:hover  { background: var(--primary-hover); border-color: var(--primary-hover); }
.a-btn-primary:active { background: var(--primary-press); border-color: var(--primary-press); }
.a-btn-primary:disabled { background: var(--ink-5); border-color: var(--ink-5); }

/* Ghost — toolbar actions, icon buttons in lists. No border. */
.a-btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--ink-2);
}
.a-btn-ghost:hover  { background: var(--surface-hover); color: var(--ink); }
.a-btn-ghost:active { background: var(--surface-press); }

/* Danger — destructive ghost. Only red text + red bg on hover. */
.a-btn-danger {
    background: transparent;
    border-color: transparent;
    color: var(--danger);
}
.a-btn-danger:hover  { background: var(--danger-bg); }

/* Subtle — tinted with primary, used for "second action" near the primary */
.a-btn-subtle {
    background: var(--primary-soft);
    color: var(--primary-deep);
    border-color: transparent;
}
.a-btn-subtle:hover  { background: var(--primary-tint); }

/* Sizes */
.a-btn-sm { height: var(--control-h-sm); padding: 0 var(--space-2_5, 10px); font-size: var(--fs-sm); }
.a-btn-lg { height: var(--control-h-lg); padding: 0 var(--space-4); font-size: var(--fs-base); }

/* Icon-only square button */
.a-btn-icon {
    width: var(--control-h);
    height: var(--control-h);
    padding: 0;
    flex: 0 0 auto;
}
.a-btn-icon.a-btn-sm { width: var(--control-h-sm); height: var(--control-h-sm); }

/* Icon inside a button */
.a-btn svg { width: 14px; height: 14px; flex-shrink: 0; stroke-width: 1.6; }
.a-btn-lg svg { width: 16px; height: 16px; }

/* Group of buttons — segmented or split */
.a-btn-group {
    display: inline-flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.a-btn-group > .a-btn {
    border: 0;
    border-radius: 0;
    border-right: 1px solid var(--rule);
    background: transparent;
}
.a-btn-group > .a-btn:last-child { border-right: 0; }
.a-btn-group > .a-btn[aria-pressed="true"] {
    background: var(--surface-press);
    color: var(--ink);
}

/* ============================================================
   INPUTS — uniform 32px height, hairline border, primary focus
   ============================================================ */

.a-input,
.a-select,
.a-textarea {
    display: block;
    width: 100%;
    height: var(--control-h);
    padding: 0 var(--space-3);
    font-family: var(--font-sans);
    font-size: var(--fs-md);
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-sm);
    box-sizing: border-box;
    transition: border-color var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease);
}
.a-input::placeholder,
.a-textarea::placeholder { color: var(--ink-4); }

.a-input:hover,
.a-select:hover,
.a-textarea:hover { border-color: var(--rule-strong); }

.a-input:focus,
.a-select:focus,
.a-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary) 22%, transparent);
}

.a-textarea { height: auto; padding: var(--space-2) var(--space-3); line-height: var(--lh-base); resize: vertical; }

.a-input-sm { height: var(--control-h-sm); padding: 0 var(--space-2); font-size: var(--fs-sm); }

/* Search input with icon */
.a-search {
    position: relative;
    display: inline-block;
    width: 220px;
}
.a-search > .a-input { padding-left: 28px; }
.a-search > svg {
    position: absolute;
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--ink-4);
    stroke-width: 1.6;
    pointer-events: none;
}

/* Field — input + label + helper */
.a-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.a-field-label {
    font-size: var(--fs-xs);
    font-weight: var(--weight-medium);
    color: var(--ink-3);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
}
.a-field-help { font-size: var(--fs-xs); color: var(--ink-4); }
.a-field-error { font-size: var(--fs-xs); color: var(--danger); }

/* ============================================================
   PIP / TAG / BADGE
   ============================================================ */

.a-pip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 20px;
    padding: 0 8px;
    border-radius: var(--radius-pill);
    font-size: var(--fs-2xs);
    font-weight: var(--weight-medium);
    letter-spacing: 0.02em;
    line-height: 1;
}
.a-pip::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.a-pip-success { background: var(--success-bg); color: var(--success); }
.a-pip-warning { background: var(--warning-bg); color: var(--warning); }
.a-pip-danger  { background: var(--danger-bg);  color: var(--danger); }
.a-pip-info    { background: var(--info-bg);    color: var(--info); }
.a-pip-neutral { background: var(--surface-soft); color: var(--ink-3); }

/* Tag — inline category chip, no dot */
.a-tag {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 8px;
    background: var(--surface-soft);
    color: var(--ink-2);
    border-radius: var(--radius-xs);
    font-size: var(--fs-xs);
    font-weight: var(--weight-medium);
    letter-spacing: 0.01em;
}
.a-tag-primary { background: var(--primary-soft); color: var(--primary-deep); }

/* Count — discreet number after a label */
.a-count {
    font-size: var(--fs-xs);
    font-weight: var(--weight-medium);
    color: var(--ink-4);
    margin-left: 6px;
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   CARD / PANEL — the primary surface
   ============================================================ */

.a-card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-1);
}
.a-card-body { padding: var(--space-4); }
.a-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--toolbar-h);
    padding: 0 var(--space-3) 0 var(--space-4);
    border-bottom: 1px solid var(--rule);
    color: var(--ink);
    font-size: var(--fs-md);
    font-weight: var(--weight-semibold);
}

/* Panel — card with explicit toolbar + body areas */
.a-panel { /* alias of .a-card with stricter chrome */ }

/* ============================================================
   TABLE — Excel-rigor. Sticky header, hairline column rules,
   tabular nums, hover-revealed row actions.
   ============================================================ */

.a-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--fs-sm);
    color: var(--ink-2);
}
.a-table th,
.a-table td {
    height: var(--row-h);
    padding: 0 var(--space-3);
    text-align: left;
    border-bottom: 1px solid var(--rule);
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.a-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface);
    color: var(--ink-3);
    font-size: var(--fs-2xs);
    font-weight: var(--weight-medium);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    border-bottom: 1px solid var(--rule-strong);
    user-select: none;
}
.a-table th[aria-sort] {
    cursor: pointer;
}
.a-table th[aria-sort="ascending"]::after,
.a-table th[aria-sort="descending"]::after {
    content: '↑';
    margin-left: 4px;
    color: var(--primary);
}
.a-table th[aria-sort="descending"]::after { content: '↓'; }

.a-table tbody tr { transition: background-color var(--dur-fast) var(--ease); }
.a-table tbody tr:hover { background: var(--surface-hover); }
.a-table tr[aria-selected="true"] { background: var(--primary-soft); }
.a-table tr[aria-selected="true"]:hover { background: var(--primary-tint); }

.a-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.a-table td.id  { font-family: var(--font-mono); color: var(--ink-3); font-size: 11px; }

/* Row actions — hidden until hover */
.a-row-actions {
    display: inline-flex;
    gap: 2px;
    opacity: 0;
    transition: opacity var(--dur-fast) var(--ease);
}
.a-table tbody tr:hover .a-row-actions,
.a-table tbody tr:focus-within .a-row-actions { opacity: 1; }

/* Filter row — sits below header */
.a-table-filters th {
    height: var(--control-h-sm);
    background: var(--paper-sunk);
    border-bottom: 1px solid var(--rule);
    text-transform: none;
    letter-spacing: 0;
    padding: 0 6px;
}
.a-table-filters .a-input { height: 22px; font-size: var(--fs-xs); padding: 0 6px; background: transparent; border-color: transparent; }
.a-table-filters .a-input:focus { background: var(--surface); border-color: var(--primary); }

/* ============================================================
   MENU / DROPDOWN — contextual actions live here, not in floating buttons
   ============================================================ */

.a-menu {
    min-width: 200px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-3);
    z-index: var(--z-popover);
}
.a-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    height: 28px;
    padding: 0 8px;
    border-radius: var(--radius-xs);
    font-size: var(--fs-md);
    color: var(--ink-2);
    cursor: pointer;
    user-select: none;
}
.a-menu-item:hover { background: var(--surface-hover); color: var(--ink); }
.a-menu-item svg { width: 14px; height: 14px; color: var(--ink-3); stroke-width: 1.6; flex-shrink: 0; }
.a-menu-item:hover svg { color: var(--ink-2); }
.a-menu-item-danger { color: var(--danger); }
.a-menu-item-danger:hover { background: var(--danger-bg); color: var(--danger); }
.a-menu-item-danger svg { color: var(--danger); }

.a-menu-sep {
    height: 1px;
    background: var(--rule);
    margin: 6px 4px;
}
.a-menu-label {
    padding: 6px 8px 4px;
    font-size: var(--fs-2xs);
    font-weight: var(--weight-medium);
    color: var(--ink-4);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
}

/* Shortcut hint inside a menu item */
.a-menu-shortcut {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-4);
}

/* ============================================================
   TABS — segment switcher (e.g. table / cards / map view)
   ============================================================ */

.a-tabs {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    border-bottom: 1px solid var(--rule);
    padding: 0;
}
.a-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: var(--toolbar-h);
    padding: 0 var(--space-3);
    margin-bottom: -1px;
    font-size: var(--fs-md);
    font-weight: var(--weight-medium);
    color: var(--ink-3);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.a-tab:hover { color: var(--ink); }
.a-tab[aria-selected="true"] {
    color: var(--ink);
    border-bottom-color: var(--primary);
}
.a-tab svg { width: 14px; height: 14px; stroke-width: 1.6; }

/* ============================================================
   MODAL
   ============================================================ */

.a-modal-scrim {
    position: fixed;
    inset: 0;
    background: var(--scrim);
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
}
.a-modal {
    width: min(520px, 92vw);
    max-height: 86vh;
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.a-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--rule);
}
.a-modal-title { font-size: var(--fs-lg); font-weight: var(--weight-semibold); color: var(--ink); }
.a-modal-body { padding: var(--space-5); overflow: auto; }
.a-modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border-top: 1px solid var(--rule);
    background: var(--paper-sunk);
}

/* ============================================================
   BANNER — inline notice (success / warning / danger / info)
   ============================================================ */

.a-banner {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
    font-size: var(--fs-md);
    line-height: var(--lh-snug);
    border: 1px solid;
}
.a-banner-success { background: var(--success-bg); border-color: var(--success-rule); color: var(--ink); }
.a-banner-warning { background: var(--warning-bg); border-color: var(--warning-rule); color: var(--ink); }
.a-banner-danger  { background: var(--danger-bg);  border-color: var(--danger-rule);  color: var(--ink); }
.a-banner-info    { background: var(--info-bg);    border-color: var(--info-rule);    color: var(--ink); }
.a-banner svg { flex-shrink: 0; width: 16px; height: 16px; margin-top: 1px; stroke-width: 1.6; }
.a-banner-success svg { color: var(--success); }
.a-banner-warning svg { color: var(--warning); }
.a-banner-danger  svg { color: var(--danger); }
.a-banner-info    svg { color: var(--info); }

/* ============================================================
   KBD — keyboard hint
   ============================================================ */

.a-kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--ink-3);
    background: var(--surface);
    border: 1px solid var(--rule);
    border-bottom-width: 2px;
    border-radius: 4px;
    line-height: 1;
}

/* ============================================================
   DIVIDER
   ============================================================ */

.a-divider {
    height: 1px;
    background: var(--rule);
    border: 0;
    margin: var(--space-4) 0;
}
