/* ============================================================
   SISTEMA DE BOTONES UNIFICADO
   Inventario TX
   ============================================================
   Define 3 familias de botones:
   1. .btn-confirmar → Esmeralda (confirmar, guardar)
   2. .btn-cancelar  → Rubi    (cancelar, eliminar)
   3. .btn-proceder  → Primario con animacion de salto
   ============================================================ */

/* ── BASE COMUN DE BOTONES ───────────────────────────── */
.btn-confirmar,
.btn-cancelar,
.btn-proceder {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: 0.625rem 1.25rem;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: 600;
    line-height: 1.5;
    text-decoration: none;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    overflow: hidden;
    transition:
        transform var(--transition-fast),
        box-shadow var(--transition-fast),
        background var(--transition-normal),
        filter var(--transition-fast),
        color var(--transition-fast);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 44px;
    white-space: nowrap;
}

/* Ripple effect container */
.btn-confirmar .ripple,
.btn-cancelar .ripple,
.btn-proceder .ripple {
    position: absolute;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0);
    animation: ripple 0.6s ease-out;
    pointer-events: none;
}

.btn-confirmar:active,
.btn-cancelar:active,
.btn-proceder:active {
    transform: scale(0.96);
}

.btn-confirmar:disabled,
.btn-cancelar:disabled,
.btn-proceder:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ── BOTON CONFIRMAR (ESMERALDA) ──────────────────────── */
.btn-confirmar {
    color: #ffffff;
    background: var(--gradient-confirmar);
    box-shadow: 0 2px 6px rgba(5, 150, 105, 0.3);
}

.btn-confirmar:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(5, 150, 105, 0.4);
    filter: brightness(1.08);
}

.btn-confirmar:focus-visible {
    outline: 3px solid var(--color-esmeralda-light);
    outline-offset: 2px;
}

.btn-confirmar:hover:not(:disabled) i {
    transform: scale(1.1);
    transition: transform var(--transition-fast);
}

/* Variante outline */
.btn-confirmar-outline {
    background: transparent;
    color: var(--color-esmeralda);
    border: 2px solid var(--color-esmeralda);
    box-shadow: none;
}

.btn-confirmar-outline:hover:not(:disabled) {
    background: var(--color-esmeralda-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    border-color: var(--color-esmeralda);
}

/* ── BOTON CANCELAR (RUBI) ────────────────────────────── */
.btn-cancelar {
    color: #ffffff;
    background: var(--gradient-cancelar);
    box-shadow: 0 2px 6px rgba(225, 29, 72, 0.3);
}

.btn-cancelar:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(225, 29, 72, 0.4);
    filter: brightness(1.08);
}

.btn-cancelar:focus-visible {
    outline: 3px solid var(--color-rubi-light);
    outline-offset: 2px;
}

.btn-cancelar:hover:not(:disabled) i {
    transform: scale(1.1);
    transition: transform var(--transition-fast);
}

/* Variante outline */
.btn-cancelar-outline {
    background: transparent;
    color: var(--color-rubi);
    border: 2px solid var(--color-rubi);
    box-shadow: none;
}

.btn-cancelar-outline:hover:not(:disabled) {
    background: var(--color-rubi-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    border-color: var(--color-rubi);
}

/* ── BOTON PROCEDER (CON ANIMACION DE SALTO) ──────────── */
.btn-proceder {
    color: #ffffff;
    background: var(--gradient-primary);
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

.btn-proceder:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
    filter: brightness(1.08);
}

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

.btn-proceder:hover:not(:disabled) i {
    transform: scale(1.1);
    transition: transform var(--transition-fast);
}

/* Animacion de salto: se activa via clase .saltando */
.btn-proceder.saltando,
.btn-confirmar.saltando {
    animation: salto 0.6s ease;
}

.btn-proceder.saltando i:last-child:not(:first-child),
.btn-confirmar.saltando i:last-child:not(:first-child) {
    animation: rebotar 0.6s ease;
}

/* ── ICONOS EN BOTONES ─────────────────────────────────── */
.btn-confirmar i,
.btn-cancelar i,
.btn-proceder i {
    transition: transform var(--transition-fast);
}

.btn-icono i {
    font-size: 1.1rem;
}

/* Icono a la izquierda con ligero movimiento */
.btn-icon-left i:first-child {
    margin-right: 0.25rem;
}

.btn-icon-left:hover i:first-child {
    transform: translateX(-2px);
}

/* Icono a la derecha con movimiento */
.btn-icon-right i:last-child {
    margin-left: 0.25rem;
}

.btn-icon-right:hover i:last-child {
    transform: translateX(3px);
}

/* ── TAMANOS ─────────────────────────────────────────── */
.btn-sm {
    padding: 0.375rem 0.875rem;
    font-size: var(--font-size-sm);
    min-height: 36px;
}

.btn-lg {
    padding: 0.75rem 1.75rem;
    font-size: var(--font-size-lg);
    min-height: 52px;
    border-radius: var(--radius-lg);
}

.btn-xl {
    padding: 1rem 2.5rem;
    font-size: var(--font-size-xl);
    min-height: 60px;
}

.btn-block {
    width: 100%;
}

/* ── BOTON ICONO CIRCULAR ─────────────────────────────── */
.btn-icono {
    width: 44px;
    height: 44px;
    min-height: unset;
    padding: 0;
    border-radius: var(--radius-full);
    font-size: var(--font-size-lg);
}

.btn-icono.btn-sm {
    width: 36px;
    height: 36px;
    min-height: unset;
    font-size: var(--font-size-base);
}

.btn-icono:hover {
    transform: translateY(-2px) rotate(5deg);
}

.btn-icono:active {
    transform: scale(0.92);
}

/* ── BOTON LIMPIAR / NEUTRO ───────────────────────────── */
.btn-limpiar {
    background: transparent;
    color: var(--color-muted);
    border: 1px solid var(--color-border);
    box-shadow: none;
}

.btn-limpiar:hover:not(:disabled) {
    background: var(--color-bg);
    color: var(--color-text);
    border-color: var(--color-muted);
    transform: translateY(-1px);
}

.btn-limpiar i {
    transition: transform var(--transition-fast);
}

.btn-limpiar:hover i {
    transform: rotate(-20deg);
}

/* ── BOTON GHOST (transparente con borde) ─────────────── */
.btn-ghost {
    background: transparent;
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
    box-shadow: none;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--color-primary-light);
    transform: translateY(-1px);
}

/* ── BOTON GRADIENT HOVER ─────────────────────────────── */
/* Brillo de izquierda a derecha al hover */
.btn-shimmer::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: left 0.5s ease;
}

.btn-shimmer:hover::before {
    left: 100%;
}

/* ── BOTON SUCCESS / AGREGAR ────────────────────────────── */
.btn-agregar {
    color: #ffffff;
    background: var(--gradient-confirmar);
    box-shadow: 0 2px 6px rgba(5, 150, 105, 0.3);
}

.btn-agregar:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(5, 150, 105, 0.4);
}

.btn-agregar i {
    animation: pulso 1.5s ease-in-out infinite;
}

.btn-agregar:hover i {
    animation: none;
    transform: scale(1.2);
}

/* ── BOTON ELIMINAR / REMOVER ─────────────────────────── */
.btn-eliminar {
    color: #ffffff;
    background: var(--gradient-cancelar);
    box-shadow: 0 2px 6px rgba(225, 29, 72, 0.3);
}

.btn-eliminar:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(225, 29, 72, 0.4);
}

.btn-eliminar i {
    transition: transform var(--transition-fast);
}

.btn-eliminar:hover i {
    transform: scale(1.2);
}

/* ── GROUP BOTONES ──────────────────────────────────────── */
.btn-group-custom {
    display: inline-flex;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.btn-group-custom .btn-confirmar,
.btn-group-custom .btn-cancelar,
.btn-group-custom .btn-proceder,
.btn-group-custom .btn-limpiar {
    border-radius: 0;
    border: none;
    box-shadow: none;
}

.btn-group-custom .btn-confirmar:hover,
.btn-group-custom .btn-cancelar:hover,
.btn-group-custom .btn-proceder:hover,
.btn-group-custom .btn-limpiar:hover {
    transform: none;
}

.btn-group-custom .btn-confirmar:not(:last-child),
.btn-group-custom .btn-cancelar:not(:last-child),
.btn-group-custom .btn-proceder:not(:last-child),
.btn-group-custom .btn-limpiar:not(:last-child) {
    border-right: 1px solid rgba(255, 255, 255, 0.2);
}

/* ── RIPPLE EFFECT ──────────────────────────────────────── */
/* Necesita el span.ripple en el HTML para funcionar */
.btn-with-ripple {
    position: relative;
    overflow: hidden;
}

.btn-with-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

.btn-with-ripple:active::after {
    width: 200%;
    height: 200%;
    opacity: 0;
    transition: width 0s, height 0s;
}

/* ── BOTON CON SPINNER INTERNO ─────────────────────────── */
.btn-spinner {
    position: relative;
    pointer-events: none;
}

.btn-spinner::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: girar 0.7s linear infinite;
}

.btn-spinner span {
    opacity: 0;
}

.btn-spinner.btn-confirmar::after {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: white;
}

.btn-spinner.btn-cancelar::after {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: white;
}

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 576px) {
    .btn-confirmar,
    .btn-cancelar,
    .btn-proceder {
        padding: 0.5rem 1rem;
        font-size: var(--font-size-sm);
    }

    .btn-lg {
        padding: 0.625rem 1.25rem;
        font-size: var(--font-size-base);
    }

    .btn-block-xs {
        width: 100%;
    }
}