/* Button Component System
 * Consolidated from theme.css and inline styles
 * Requirements: 1.2, 2.1
 */

/* Base button styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    user-select: none;
    white-space: nowrap;
    min-height: 44px; /* Touch target accessibility */
    
    /* Prevent text selection */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    
    /* Focus styles for accessibility */
    &:focus {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }
    
    /* Disabled state */
    &:disabled,
    &.btn-disabled {
        opacity: 0.6;
        cursor: not-allowed;
        pointer-events: none;
    }
}

/* Button variants */
.btn-primary {
    background-color: var(--primary-color);
    color: #1f2937;
    border-color: var(--primary-color);
    
    &:hover:not(:disabled) {
        background-color: var(--primary-hover);
        border-color: var(--primary-hover);
        transform: translateY(-1px);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }
    
    &:active {
        transform: translateY(0);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
    
    &:hover:not(:disabled) {
        background-color: var(--secondary-hover);
        border-color: var(--secondary-hover);
        transform: translateY(-1px);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }
    
    &:active {
        transform: translateY(0);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
}

.btn-outline {
    background-color: transparent;
    color: var(--secondary-color);
    border-color: var(--secondary-color);
    
    &:hover:not(:disabled) {
        background-color: var(--secondary-color);
        color: white;
        transform: translateY(-1px);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }
    
    &:active {
        transform: translateY(0);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
}

.btn-ghost {
    background-color: transparent;
    color: var(--secondary-color);
    border-color: transparent;
    
    &:hover:not(:disabled) {
        background-color: rgba(58, 85, 180, 0.1);
        color: var(--secondary-hover);
    }
    
    &:active {
        background-color: rgba(58, 85, 180, 0.2);
    }
}

.btn-danger {
    background-color: #ef4444;
    color: white;
    border-color: #ef4444;
    
    &:hover:not(:disabled) {
        background-color: #dc2626;
        border-color: #dc2626;
        transform: translateY(-1px);
        box-shadow: 0 4px 8px rgba(239, 68, 68, 0.2);
    }
    
    &:active {
        transform: translateY(0);
        box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
    }
}

.btn-success {
    background-color: #10b981;
    color: white;
    border-color: #10b981;
    
    &:hover:not(:disabled) {
        background-color: #059669;
        border-color: #059669;
        transform: translateY(-1px);
        box-shadow: 0 4px 8px rgba(16, 185, 129, 0.2);
    }
    
    &:active {
        transform: translateY(0);
        box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
    }
}

/* Button sizes */
.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    min-height: 36px;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
    min-height: 52px;
}

.btn-xl {
    padding: 1.25rem 2.5rem;
    font-size: 1.25rem;
    min-height: 60px;
}

/* Button with icons */
.btn-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    
    .icon {
        width: 1rem;
        height: 1rem;
        flex-shrink: 0;
    }
}

.btn-icon-only {
    padding: 0.75rem;
    width: 44px;
    height: 44px;
    
    &.btn-sm {
        padding: 0.5rem;
        width: 36px;
        height: 36px;
    }
    
    &.btn-lg {
        padding: 1rem;
        width: 52px;
        height: 52px;
    }
}

/* Loading state */
.btn-loading {
    position: relative;
    color: transparent !important;
    
    &::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 1rem;
        height: 1rem;
        border: 2px solid currentColor;
        border-top-color: transparent;
        border-radius: 50%;
        animation: btn-spin 0.8s linear infinite;
    }
}

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

/* Button groups */
.btn-group {
    display: inline-flex;
    
    .btn {
        border-radius: 0;
        margin-left: -1px;
        
        &:first-child {
            border-top-left-radius: 0.5rem;
            border-bottom-left-radius: 0.5rem;
            margin-left: 0;
        }
        
        &:last-child {
            border-top-right-radius: 0.5rem;
            border-bottom-right-radius: 0.5rem;
        }
        
        &:hover {
            z-index: 1;
        }
    }
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .btn {
        min-height: 44px;
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 0.75rem 1.25rem;
    }
    
    .btn-sm {
        min-height: 40px;
        font-size: 14px;
        padding: 0.625rem 1rem;
    }
    
    .btn-lg {
        min-height: 48px;
        font-size: 18px;
        padding: 0.875rem 1.75rem;
    }
    
    .btn-xl {
        min-height: 52px;
        font-size: 20px;
        padding: 1rem 2rem;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .btn {
        transition: none;
        
        &:hover {
            transform: none;
        }
        
        &:active {
            transform: none;
        }
    }
    
    .btn-loading::after {
        animation: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn {
        border-width: 2px;
    }
    
    .btn-ghost {
        border-color: currentColor;
    }
}