/**
 * Ice Arena Design System - Buttons v2
 * Modern button system with gradients, glows, and micro-interactions
 *
 * Version: 2.0
 * Date: November 2025
 */

/* =========================================
   BASE BUTTON
   ========================================= */

.btn {
    /* Layout */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);

    /* Sizing */
    padding: var(--space-3) var(--space-5);
    min-height: 44px;

    /* Typography */
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    text-decoration: none;
    text-align: center;
    white-space: nowrap;

    /* Appearance */
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;

    /* Transitions */
    transition:
        transform var(--duration-base) var(--ease-spring),
        box-shadow var(--duration-base) var(--ease-out),
        background-color var(--duration-fast) var(--ease-out),
        border-color var(--duration-fast) var(--ease-out);

    /* Stacking context for pseudo-elements */
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

/* Shine overlay effect */
.btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.2) 0%,
        rgba(255, 255, 255, 0.05) 40%,
        transparent 50%
    );
    opacity: 0;
    transition: opacity var(--duration-fast) var(--ease-out);
    pointer-events: none;
    z-index: 1;
}

.btn:hover::before {
    opacity: 1;
}

/* Focus state */
.btn:focus-visible {
    outline: none;
    box-shadow: var(--state-focus-ring-primary);
}

/* Active/pressed state */
.btn:active:not(:disabled) {
    transform: scale(0.97);
}

/* Disabled state */
.btn:disabled,
.btn.disabled {
    opacity: var(--state-disabled-opacity);
    cursor: not-allowed;
    pointer-events: none;
}

/* Icon inside button */
.btn i,
.btn svg {
    flex-shrink: 0;
    font-size: 1em;
    line-height: 1;
}

/* =========================================
   PRIMARY BUTTON
   Goal-red gradient with glow
   ========================================= */

.btn-primary {
    background: var(--gradient-primary);
    color: var(--text-inverse);
    box-shadow: var(--shadow-glow-red-sm);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.02);
    box-shadow: var(--shadow-glow-red-lg);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
    box-shadow: var(--shadow-glow-red-sm);
}

.btn-primary:focus-visible {
    box-shadow: var(--shadow-glow-red-sm), var(--state-focus-ring-primary);
}

/* =========================================
   SECONDARY BUTTON
   Clean white with subtle border
   ========================================= */

.btn-secondary {
    background: var(--surface-ice);
    color: var(--rink-700);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--ice-50);
    border-color: var(--ice-300);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary:active:not(:disabled) {
    background: var(--ice-100);
    transform: translateY(0) scale(0.98);
}

.btn-secondary:focus-visible {
    border-color: var(--ice-500);
    box-shadow: var(--shadow-sm), var(--state-focus-ring-info);
}

/* =========================================
   GHOST BUTTON
   Transparent with hover fill
   ========================================= */

.btn-ghost {
    background: transparent;
    color: var(--rink-600);
    border: none;
}

.btn-ghost::before {
    display: none;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--ice-100);
    color: var(--ice-700);
}

.btn-ghost:active:not(:disabled) {
    background: var(--ice-200);
}

.btn-ghost:focus-visible {
    box-shadow: var(--state-focus-ring-info);
}

/* =========================================
   OUTLINE BUTTON
   Border only with fill on hover
   ========================================= */

.btn-outline {
    background: transparent;
    color: var(--goal-red);
    border: 2px solid var(--goal-red);
}

.btn-outline:hover:not(:disabled) {
    background: var(--goal-red);
    color: var(--text-inverse);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow-red-sm);
}

.btn-outline:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

/* Outline variants */
.btn-outline-secondary {
    color: var(--rink-600);
    border-color: var(--rink-300);
}

.btn-outline-secondary:hover:not(:disabled) {
    background: var(--rink-600);
    border-color: var(--rink-600);
    color: var(--text-inverse);
    box-shadow: var(--shadow-md);
}

/* =========================================
   SUCCESS BUTTON
   Save-green for positive actions
   ========================================= */

.btn-success {
    background: var(--gradient-green);
    color: var(--text-inverse);
    box-shadow: var(--shadow-glow-green-sm);
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 25px var(--save-green-glow);
}

.btn-success:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

/* =========================================
   WARNING BUTTON
   Power-gold for caution actions
   ========================================= */

.btn-warning {
    background: var(--gradient-gold);
    color: var(--rink-900);
    box-shadow: var(--shadow-glow-gold-sm);
}

.btn-warning:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 25px var(--power-gold-glow);
}

.btn-warning:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

/* =========================================
   DANGER BUTTON
   Goal-red for destructive actions
   ========================================= */

.btn-danger {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: var(--text-inverse);
    box-shadow: 0 4px 14px rgba(185, 28, 28, 0.4);
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 25px rgba(185, 28, 28, 0.5);
}

/* =========================================
   INFO BUTTON
   Assist-cyan for informational actions
   ========================================= */

.btn-info {
    background: var(--gradient-cyan);
    color: var(--text-inverse);
    box-shadow: var(--shadow-glow-cyan-sm);
}

.btn-info:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 25px var(--assist-cyan-glow);
}

/* =========================================
   DARK BUTTON
   Arena dark for subtle actions
   ========================================= */

.btn-dark {
    background: linear-gradient(135deg, var(--rink-800) 0%, var(--rink-900) 100%);
    color: var(--text-inverse);
    box-shadow: var(--shadow-md);
}

.btn-dark:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

/* =========================================
   LIGHT BUTTON
   Ice white for light backgrounds
   ========================================= */

.btn-light {
    background: var(--surface-ice);
    color: var(--rink-700);
    box-shadow: var(--shadow-sm);
}

.btn-light:hover:not(:disabled) {
    background: var(--ice-50);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* =========================================
   LINK BUTTON
   Styled as text link
   ========================================= */

.btn-link {
    background: transparent;
    color: var(--text-link);
    padding: 0;
    min-height: auto;
    text-transform: none;
    letter-spacing: normal;
    font-family: var(--font-body);
    font-weight: var(--font-medium);
}

.btn-link:hover:not(:disabled) {
    color: var(--text-link-hover);
    text-decoration: underline;
}

.btn-link:focus-visible {
    box-shadow: none;
    text-decoration: underline;
}

/* =========================================
   BUTTON SIZES
   ========================================= */

/* Extra Small */
.btn-xs {
    padding: var(--space-1) var(--space-2);
    min-height: 28px;
    font-size: var(--text-xs);
    border-radius: var(--radius-md);
    gap: var(--space-1);
}

/* Small */
.btn-sm {
    padding: var(--space-2) var(--space-4);
    min-height: 36px;
    font-size: var(--text-xs);
    border-radius: var(--radius-md);
}

/* Medium (default) - already defined in base */

/* Large */
.btn-lg {
    padding: var(--space-4) var(--space-8);
    min-height: 52px;
    font-size: var(--text-base);
    border-radius: var(--radius-xl);
    gap: var(--space-3);
}

/* Extra Large */
.btn-xl {
    padding: var(--space-5) var(--space-10);
    min-height: 60px;
    font-size: var(--text-lg);
    border-radius: var(--radius-xl);
    gap: var(--space-3);
}

/* =========================================
   ICON BUTTONS
   Square buttons for icons only
   ========================================= */

.btn-icon {
    padding: 0;
    width: 44px;
    height: 44px;
    min-height: auto;
}

.btn-icon.btn-xs {
    width: 28px;
    height: 28px;
}

.btn-icon.btn-sm {
    width: 36px;
    height: 36px;
}

.btn-icon.btn-lg {
    width: 52px;
    height: 52px;
}

.btn-icon.btn-xl {
    width: 60px;
    height: 60px;
}

/* Circular icon button */
.btn-icon-circle {
    border-radius: var(--radius-full);
}

/* =========================================
   BUTTON WITH ICON
   Proper spacing for icon + text
   ========================================= */

.btn-icon-left {
    flex-direction: row;
}

.btn-icon-right {
    flex-direction: row-reverse;
}

/* =========================================
   FULL WIDTH BUTTON
   ========================================= */

.btn-block,
.btn-full {
    width: 100%;
}

/* =========================================
   BUTTON GROUP
   ========================================= */

.btn-group {
    display: inline-flex;
    vertical-align: middle;
}

.btn-group > .btn {
    border-radius: 0;
    position: relative;
}

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

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

.btn-group > .btn:not(:last-child) {
    border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-group > .btn:hover,
.btn-group > .btn:focus {
    z-index: 1;
}

.btn-group > .btn.active {
    z-index: 2;
}

/* Vertical button group */
.btn-group-vertical {
    flex-direction: column;
}

.btn-group-vertical > .btn {
    border-radius: 0;
}

.btn-group-vertical > .btn:first-child {
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    border-bottom-left-radius: 0;
}

.btn-group-vertical > .btn:last-child {
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
    border-top-right-radius: 0;
}

.btn-group-vertical > .btn:not(:last-child) {
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

/* =========================================
   LOADING STATE
   ========================================= */

.btn.loading {
    pointer-events: none;
}

.btn.loading .btn-text {
    opacity: 0;
}

.btn.loading .btn-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Spinner animation */
.btn-spinner {
    width: 1.25em;
    height: 1.25em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: var(--radius-full);
    animation: btn-spin 0.75s linear infinite;
}

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

/* =========================================
   GLASS BUTTON
   Frosted glass effect for dark backgrounds
   ========================================= */

.btn-glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: var(--border-glass);
    color: var(--text-inverse);
}

.btn-glass:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.btn-glass:active:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
}

/* =========================================
   PILL BUTTON
   Fully rounded ends
   ========================================= */

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

/* =========================================
   ELEVATED BUTTON
   Extra shadow depth
   ========================================= */

.btn-elevated {
    box-shadow: var(--shadow-lg);
}

.btn-elevated:hover:not(:disabled) {
    box-shadow: var(--shadow-xl);
    transform: translateY(-3px);
}

/* =========================================
   FLOATING ACTION BUTTON (FAB)
   ========================================= */

.btn-fab {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    width: 56px;
    height: 56px;
    padding: 0;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-xl);
    z-index: var(--z-fixed);
}

.btn-fab:hover:not(:disabled) {
    transform: scale(1.1);
}

/* Mini FAB */
.btn-fab-mini {
    width: 40px;
    height: 40px;
}

/* Extended FAB with text */
.btn-fab-extended {
    width: auto;
    padding: 0 var(--space-6);
    border-radius: var(--radius-full);
}

/* =========================================
   CLOSE BUTTON
   ========================================= */

.btn-close {
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-fast) var(--ease-out);
}

.btn-close:hover {
    background: var(--ice-100);
    color: var(--text-primary);
}

.btn-close:focus-visible {
    outline: none;
    box-shadow: var(--state-focus-ring-info);
}

/* Close button on dark background */
.btn-close-light {
    color: rgba(255, 255, 255, 0.7);
}

.btn-close-light:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-inverse);
}

/* =========================================
   TOGGLE BUTTON
   ========================================= */

.btn-toggle {
    background: var(--rink-200);
    color: var(--rink-600);
}

.btn-toggle.active,
.btn-toggle[aria-pressed="true"] {
    background: var(--gradient-primary);
    color: var(--text-inverse);
    box-shadow: var(--shadow-glow-red-sm);
}

.btn-toggle:hover:not(:disabled):not(.active) {
    background: var(--rink-300);
}

/* =========================================
   SPLIT BUTTON
   ========================================= */

.btn-split {
    display: inline-flex;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.btn-split > .btn {
    border-radius: 0;
}

.btn-split > .btn:first-child {
    border-top-left-radius: var(--radius-lg);
    border-bottom-left-radius: var(--radius-lg);
}

.btn-split > .btn-split-toggle {
    border-top-right-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
    padding: 0 var(--space-3);
    border-left: 1px solid rgba(255, 255, 255, 0.2);
}

/* =========================================
   RESPONSIVE ADJUSTMENTS (Mobile-First)
   ========================================= */

/* Mobile: Ensure touch targets and full-width option */
.btn {
    min-height: var(--touch-target-min, 44px);
}

.btn-icon {
    min-width: var(--touch-target-min, 44px);
    min-height: var(--touch-target-min, 44px);
}

/* Full-width button on mobile */
.btn-block-mobile {
    width: 100%;
    justify-content: center;
}

/* Stack button groups on mobile */
.btn-group-responsive {
    flex-direction: column;
    width: 100%;
}

.btn-group-responsive > .btn {
    border-radius: 0;
    width: 100%;
}

.btn-group-responsive > .btn:first-child {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.btn-group-responsive > .btn:last-child {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Small screens and up (640px+) */
@media (min-width: 640px) {
    .btn-block-mobile {
        width: auto;
    }

    .btn-group-responsive {
        flex-direction: row;
        width: auto;
    }

    .btn-group-responsive > .btn {
        width: auto;
    }

    .btn-group-responsive > .btn:first-child {
        border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    }

    .btn-group-responsive > .btn:last-child {
        border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    }
}

/* Tablet and up (768px+) */
@media (min-width: 768px) {
    .btn {
        min-height: auto;
    }

    .btn-icon {
        min-width: auto;
        min-height: auto;
    }
}

/* Very small screens - compact buttons */
@media (max-width: 374px) {
    .btn {
        padding: var(--space-2-5) var(--space-3);
        font-size: var(--text-xs);
    }

    .btn-lg {
        padding: var(--space-3) var(--space-5);
        font-size: var(--text-sm);
    }
}

/* =========================================
   PRINT STYLES
   ========================================= */

@media print {
    .btn {
        box-shadow: none !important;
        text-decoration: underline;
    }

    .btn-primary,
    .btn-secondary,
    .btn-success,
    .btn-danger,
    .btn-warning,
    .btn-info {
        background: transparent !important;
        color: #000 !important;
        border: 1px solid #000 !important;
    }
}

/* =========================================
   REDUCED MOTION
   ========================================= */

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

    .btn:hover:not(:disabled) {
        transform: none;
    }

    .btn:active:not(:disabled) {
        transform: none;
    }

    .btn-spinner {
        animation: none;
    }
}

/* =========================================
   HIGH CONTRAST MODE
   ========================================= */

@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }

    .btn:focus-visible {
        outline: 3px solid currentColor;
        outline-offset: 2px;
    }
}
