/**
 * Tieu Hao Pro button components.
 *
 * Scope: reusable action controls. Values come from component-tokens.css.
 */

.thp-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--thp-space-2);
    min-height: var(--thp-control-height-md);
    padding-inline: var(--thp-control-padding-inline);
    border: 1px solid var(--thp-button-border);
    border-radius: var(--thp-control-radius);
    background: var(--thp-button-bg);
    color: var(--thp-button-text);
    box-shadow: var(--thp-button-shadow);
    font: inherit;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition:
        background-color var(--thp-duration-fast) var(--thp-ease-standard),
        color var(--thp-duration-fast) var(--thp-ease-standard),
        border-color var(--thp-duration-fast) var(--thp-ease-standard),
        box-shadow var(--thp-duration-fast) var(--thp-ease-standard),
        transform var(--thp-duration-fast) var(--thp-ease-standard);
}

.thp-button:hover {
    background: var(--thp-button-bg-hover);
}

.thp-button:active {
    transform: translateY(1px);
}

.thp-button--secondary {
    --thp-button-bg: var(--thp-color-surface);
    --thp-button-bg-hover: var(--thp-color-brand-soft);
    --thp-button-text: var(--thp-color-brand-deep);
    --thp-button-border: var(--thp-color-border);
}

.thp-button--outline {
    --thp-button-bg: transparent;
    --thp-button-bg-hover: var(--thp-color-brand-soft);
    --thp-button-text: var(--thp-color-brand-deep);
    --thp-button-border: var(--thp-color-brand);
    --thp-button-shadow: none;
}

.thp-button--text {
    --thp-button-bg: transparent;
    --thp-button-bg-hover: var(--thp-color-brand-soft);
    --thp-button-text: var(--thp-color-brand-deep);
    --thp-button-border: transparent;
    --thp-button-shadow: none;

    padding-inline: var(--thp-space-2);
}

.thp-button--sm {
    min-height: var(--thp-control-height-sm);
    padding-inline: var(--thp-space-4);
    font-size: var(--thp-font-size-sm);
}

.thp-button--lg {
    min-height: var(--thp-control-height-lg);
}

.thp-button--full {
    width: 100%;
}

.thp-button[disabled],
.thp-button[aria-disabled="true"] {
    opacity: 0.55;
    pointer-events: none;
}

.thp-button__icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 1.25em;
    height: 1.25em;
}

.thp-button__icon > svg {
    width: 100%;
    height: 100%;
}

.thp-button.is-loading {
    pointer-events: none;
}

.thp-button.is-loading .thp-button__label {
    visibility: hidden;
}

.thp-button.is-loading::after {
    width: 1em;
    height: 1em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    content: "";
    animation: thp-button-spin 700ms linear infinite;
}

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

@media (max-width: 767px) {
    .thp-button {
        min-height: max(var(--thp-control-height-md), 44px);
    }

    .thp-button--lg {
        min-height: max(var(--thp-control-height-lg), 48px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .thp-button {
        transition: none;
    }

    .thp-button:active {
        transform: none;
    }

    .thp-button.is-loading::after {
        animation-duration: 1.5s;
    }
}
