﻿/* =============================================================
   Buttons — shared standard.

   The application's button standard is .app-btn / .app-btn-primary /
   .app-btn-outline / .app-btn-danger / .app-btn-ghost, defined in
   css/design-button.css. That file stays the source of truth for
   button geometry; this file does NOT introduce a second button
   system. It adds the states and icon rules that were missing or
   applied inconsistently per page, and gives Bootstrap's .btn the
   same interaction behaviour so the two never diverge visually.
   ============================================================= */

/* ---------- Focus visibility (accessibility) ----------
   Several pages removed focus outlines without replacing them.
   One consistent, visible focus ring for every button type. */
.btn:focus-visible,
.app-btn:focus-visible,
.btn-close:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* ---------- Disabled ---------- */
.btn:disabled,
.btn.disabled,
.app-btn:disabled,
.app-btn.disabled {
    opacity: .55;
    cursor: not-allowed;
    pointer-events: auto; /* keep the cursor affordance readable */
}

/* ---------- Icons inside buttons ----------
   Icons were sized ad hoc per page (14/16/18/20px, with and without
   vertical alignment). One size, centred, never shrinking. */
.btn > i,
.btn > svg,
.app-btn > i,
.app-btn > svg {
    width: var(--icon-size-sm);
    height: var(--icon-size-sm);
    font-size: var(--icon-size-sm);
    line-height: 1;
    flex-shrink: 0;
}

.btn {
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    white-space: nowrap;
}

.app-btn {
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}
@media (prefers-reduced-motion: reduce) {
    .btn, .app-btn { transition: none; }
}

/* ---------- Icon-only buttons ----------
   Square, same height as a text button, icon optically centred. */
.btn-icon,
.fg-btn-icon {
    width: var(--control-height);
    height: var(--control-height);
    min-height: var(--control-height);
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

/* ---------- Loading ----------
   A button that is working keeps its width so the layout does not
   jump, and stops accepting input. */
.btn.is-loading,
.app-btn.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.is-loading::after,
.app-btn.is-loading::after {
    content: "";
    position: absolute;
    width: var(--icon-size-sm);
    height: var(--icon-size-sm);
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: fg-btn-spin .6s linear infinite;
    color: var(--color-text);
}

.btn-primary.is-loading::after,
.app-btn-primary.is-loading::after,
.app-btn-danger.is-loading::after {
    color: #fff;
}

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

@media (prefers-reduced-motion: reduce) {
    .btn.is-loading::after,
    .app-btn.is-loading::after {
        animation-duration: 2s;
    }
}

/* ---------- Button groups / toolbars ----------
   Consistent gap wherever actions sit next to each other. */
.fg-btn-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

@media (max-width: 575.98px) {
    .fg-btn-row > .btn,
    .fg-btn-row > .app-btn {
        flex: 1 1 auto;
    }
}

/* ---------- Primary action in a dialog ----------
   Every modal's confirming action uses the one brand blue. Two classes had no
   working definition at all and rendered as a bare browser button: the
   Employees dialogs' .emp-btn-primary survives only inside a commented-out
   block in React.cshtml, and .rx-btn-submit on the job application dialog was
   never written. Defining them here keeps them with the rest of the button
   standard, where a stray comment cannot silently remove them again.

   Semantic actions are deliberately left alone: destructive buttons stay red
   and approve/reject keep their meaning. Only the neutral confirming actions
   are unified. */
.emp-btn-primary,
.rx-btn-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: 36px;
    min-height: 36px;
    padding: 0 var(--space-4);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-sm);
    background: var(--color-primary);
    color: #fff;
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
}

.emp-btn-primary:hover,
.emp-btn-primary:focus,
.rx-btn-submit:hover,
.rx-btn-submit:focus {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    color: #fff;
}

.emp-btn-primary:disabled,
.rx-btn-submit:disabled {
    opacity: .55;
    cursor: not-allowed;
}
