/**
 * TXL Gen4 Design System - Buttons
 * 
 * Système de boutons avec variants et tailles
 */

/* ============================================
   BOUTON BASE
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-2);
    padding: var(--spacing-3) var(--spacing-6);
    font-family: var(--font-family-sans);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    line-height: var(--line-height-tight);
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.btn:hover {
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn:focus-visible {
    outline: 2px solid var(--color-primary-500);
    outline-offset: 2px;
}

.btn:disabled,
.btn.disabled {
    opacity: var(--opacity-50);
    cursor: not-allowed;
    pointer-events: none;
}

/* ============================================
   VARIANTS DE COULEURS
   ============================================ */

/* Primary */
.btn-primary {
    color: var(--color-neutral-0);
    background-color: var(--color-primary-500);
    border-color: var(--color-primary-500);
}

.btn-primary:hover {
    background-color: var(--color-primary-600);
    border-color: var(--color-primary-600);
}

.btn-primary:active {
    background-color: var(--color-primary-700);
    border-color: var(--color-primary-700);
}

/* Secondary */
.btn-secondary {
    color: var(--color-neutral-0);
    background-color: var(--color-secondary-500);
    border-color: var(--color-secondary-500);
}

.btn-secondary:hover {
    background-color: var(--color-secondary-600);
    border-color: var(--color-secondary-600);
}

/* Success */
.btn-success {
    color: var(--color-neutral-0);
    background-color: var(--color-success-500);
    border-color: var(--color-success-500);
}

.btn-success:hover {
    background-color: var(--color-success-600);
    border-color: var(--color-success-600);
}

/* Warning */
.btn-warning {
    color: var(--color-neutral-900);
    background-color: var(--color-warning-500);
    border-color: var(--color-warning-500);
}

.btn-warning:hover {
    background-color: var(--color-warning-600);
    border-color: var(--color-warning-600);
}

/* Error */
.btn-error {
    color: var(--color-neutral-0);
    background-color: var(--color-error-500);
    border-color: var(--color-error-500);
}

.btn-error:hover {
    background-color: var(--color-error-600);
    border-color: var(--color-error-600);
}

/* Info */
.btn-info {
    color: var(--color-neutral-0);
    background-color: var(--color-info-500);
    border-color: var(--color-info-500);
}

.btn-info:hover {
    background-color: var(--color-info-600);
    border-color: var(--color-info-600);
}

/* ============================================
   VARIANTS OUTLINE
   ============================================ */

.btn-outline-primary {
    color: var(--color-primary-600);
    background-color: transparent;
    border-color: var(--color-primary-500);
}

.btn-outline-primary:hover {
    color: var(--color-neutral-0);
    background-color: var(--color-primary-500);
}

.btn-outline-secondary {
    color: var(--color-secondary-600);
    background-color: transparent;
    border-color: var(--color-secondary-500);
}

.btn-outline-secondary:hover {
    color: var(--color-neutral-0);
    background-color: var(--color-secondary-500);
}

.btn-outline-success {
    color: var(--color-success-600);
    background-color: transparent;
    border-color: var(--color-success-500);
}

.btn-outline-success:hover {
    color: var(--color-neutral-0);
    background-color: var(--color-success-500);
}

.btn-outline-error {
    color: var(--color-error-600);
    background-color: transparent;
    border-color: var(--color-error-500);
}

.btn-outline-error:hover {
    color: var(--color-neutral-0);
    background-color: var(--color-error-500);
}

/* ============================================
   VARIANTS GHOST
   ============================================ */

.btn-ghost {
    color: var(--color-text-primary);
    background-color: transparent;
    border-color: transparent;
}

.btn-ghost:hover {
    background-color: var(--color-neutral-100);
    transform: none;
    box-shadow: none;
}

.btn-ghost-primary {
    color: var(--color-primary-600);
}

.btn-ghost-primary:hover {
    background-color: var(--color-primary-50);
}

/* ============================================
   TAILLES
   ============================================ */

.btn-xs {
    padding: var(--spacing-1) var(--spacing-3);
    font-size: var(--font-size-xs);
    border-radius: var(--radius-sm);
}

.btn-sm {
    padding: var(--spacing-2) var(--spacing-4);
    font-size: var(--font-size-sm);
    border-radius: var(--radius-base);
}

.btn-lg {
    padding: var(--spacing-4) var(--spacing-8);
    font-size: var(--font-size-lg);
    border-radius: var(--radius-lg);
}

.btn-xl {
    padding: var(--spacing-5) var(--spacing-10);
    font-size: var(--font-size-xl);
    border-radius: var(--radius-xl);
}

/* ============================================
   MODIFIEURS
   ============================================ */

.btn-block {
    display: flex;
    width: 100%;
}

.btn-rounded {
    border-radius: var(--radius-full);
}

.btn-square {
    padding: var(--spacing-3);
    aspect-ratio: 1;
}

.btn-icon {
    padding: var(--spacing-3);
    aspect-ratio: 1;
    border-radius: var(--radius-md);
}

.btn-icon.btn-sm {
    padding: var(--spacing-2);
}

.btn-icon.btn-lg {
    padding: var(--spacing-4);
}

/* ============================================
   GROUPES DE BOUTONS
   ============================================ */

.btn-group {
    display: inline-flex;
    gap: var(--spacing-2);
}

.btn-group .btn {
    flex: 0 1 auto;
}

.btn-group-vertical {
    display: inline-flex;
    flex-direction: column;
    gap: var(--spacing-2);
}

.btn-group-vertical .btn {
    width: 100%;
}

/* Boutons attachés */
.btn-group-attached {
    display: inline-flex;
    gap: 0;
}

.btn-group-attached .btn {
    border-radius: 0;
}

.btn-group-attached .btn:first-child {
    border-top-left-radius: var(--radius-md);
    border-bottom-left-radius: var(--radius-md);
}

.btn-group-attached .btn:last-child {
    border-top-right-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
}

.btn-group-attached .btn:not(:last-child) {
    border-right: none;
}

/* ============================================
   ÉTATS DE CHARGEMENT
   ============================================ */

.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 1em;
    height: 1em;
    top: 50%;
    left: 50%;
    margin-left: -0.5em;
    margin-top: -0.5em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
}

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

/* ============================================
   BOUTONS AVEC ICÔNES
   ============================================ */

.btn .icon {
    width: 1.25em;
    height: 1.25em;
    flex-shrink: 0;
}

.btn .icon-left {
    margin-right: var(--spacing-2);
}

.btn .icon-right {
    margin-left: var(--spacing-2);
}

/* ============================================
   BOUTONS DROPDOWN
   ============================================ */

.btn-dropdown {
    position: relative;
}

.btn-dropdown-toggle::after {
    content: "";
    display: inline-block;
    margin-left: var(--spacing-2);
    vertical-align: middle;
    border-top: 0.3em solid;
    border-right: 0.3em solid transparent;
    border-left: 0.3em solid transparent;
}

.btn-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: var(--z-dropdown);
    display: none;
    min-width: 10rem;
    padding: var(--spacing-2) 0;
    margin: var(--spacing-1) 0 0;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.btn-dropdown.active .btn-dropdown-menu {
    display: block;
}

.btn-dropdown-item {
    display: block;
    width: 100%;
    padding: var(--spacing-2) var(--spacing-4);
    text-align: left;
    color: var(--color-text-primary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.btn-dropdown-item:hover {
    background-color: var(--color-surface-hover);
    text-decoration: none;
}

.btn-dropdown-divider {
    height: 1px;
    margin: var(--spacing-2) 0;
    background-color: var(--color-border);
}
