/* ==========================================================================
   components/buttons.css — every button variant of the project
   --------------------------------------------------------------------------
   Used by: all modules. HTML never styles a button directly — it only
   combines these classes: .btn + one variant (+ optional size/state).
   A new kind of button = a new class HERE, never inline styles.
   FLAT: depth via background/border change only, no shadows.
   ========================================================================== */

/* ----- Base — shared by every button ------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 44px;                    /* touch-friendly tap target */
    padding: 0 var(--space-4);
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
}

.btn:disabled,
.btn.is-loading {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ----- Primary — main action of a page (save, submit, continue) ----------- */
.btn-primary {
    background: var(--color-primary);
    color: var(--color-text-invert);
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-hover);
    color: var(--color-text-invert);
}

/* ----- Secondary — neutral action next to a primary (cancel, back) -------- */
.btn-secondary {
    background: var(--color-surface);
    border-color: var(--color-border-strong);
    color: var(--color-text);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-surface-alt);
    color: var(--color-text);
}

/* ----- Danger — destructive actions (delete, revoke, disable) ------------- */
.btn-danger {
    background: var(--color-danger);
    color: var(--color-text-invert);
}

.btn-danger:hover:not(:disabled) {
    background: #c0132f; /* one-off darker tint of --color-danger for hover */
    color: var(--color-text-invert);
}

/* ----- Ghost — low-emphasis action inside tables/toolbars ------------------ */
.btn-ghost {
    background: transparent;
    color: var(--color-primary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--color-primary-soft);
}

/* ----- Sizes ---------------------------------------------------------------- */
.btn-sm {
    min-height: 32px;
    padding: 0 var(--space-3);
    font-size: var(--font-size-sm);
}

/* Touch screens: small buttons grow to a comfortable tap size. */
@media (pointer: coarse) {
    .btn-sm {
        min-height: 40px;
    }
}

.btn-lg {
    min-height: 52px;
    padding: 0 var(--space-6);
    font-size: var(--font-size-md);
}

/* ----- Full width (mobile forms, slide-in footers) -------------------------- */
.btn-block {
    width: 100%;
}

/* ----- Loading state — pair with .is-loading on the button ------------------ */
.btn .btn-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: btn-spin 700ms linear infinite;
}

@keyframes btn-spin {
    to { transform: rotate(360deg); }
}
