/**
 * Button Component System
 * Unified button styles for the SEO application
 * WCAG 2.1 AA Compliant
 */

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ============================================
   PRIMARY BUTTON
   ============================================ */

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 6px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5568d3 0%, #6a4091 100%);
    box-shadow: 0 6px 12px rgba(102, 126, 234, 0.4);
}

.btn-primary:focus-visible {
    outline: 3px solid var(--color-brand-focus, #4F46E5);
    outline-offset: 3px;
}

/* ============================================
   SECONDARY BUTTON
   ============================================ */

.btn-secondary {
    background: white;
    color: var(--color-text-primary, #111827);
    border: 2px solid var(--color-border-alt, #D1D5DB);
}

.btn-secondary:hover {
    background: var(--color-bg-secondary, #F9FAFB);
    border-color: var(--color-text-secondary, #4B5563);
}

.btn-secondary:focus-visible {
    outline: 3px solid var(--color-brand-focus, #4F46E5);
    outline-offset: 2px;
}

/* ============================================
   SUCCESS BUTTON
   ============================================ */

.btn-success {
    background: var(--color-success, #10B981);
    color: white;
}

.btn-success:hover {
    background: var(--color-success-hover, #059669);
}

.btn-success:focus-visible {
    outline: 3px solid var(--color-success-dark, #065F46);
    outline-offset: 3px;
}

/* ============================================
   WARNING BUTTON
   ============================================ */

.btn-warning {
    background: var(--color-warning, #F59E0B);
    color: white;
}

.btn-warning:hover {
    background: var(--color-warning-alt, #EA580C);
}

.btn-warning:focus-visible {
    outline: 3px solid var(--color-warning-dark, #92400E);
    outline-offset: 3px;
}

/* ============================================
   DANGER/ERROR BUTTON
   ============================================ */

.btn-danger {
    background: var(--color-error, #EF4444);
    color: white;
}

.btn-danger:hover {
    background: var(--color-error-alt, #DC2626);
}

.btn-danger:focus-visible {
    outline: 3px solid var(--color-error-dark, #991B1B);
    outline-offset: 3px;
}

/* ============================================
   GHOST/OUTLINE BUTTON
   ============================================ */

.btn-ghost {
    background: transparent;
    color: var(--color-text-primary, #111827);
    border: 2px solid transparent;
}

.btn-ghost:hover {
    background: var(--color-bg-secondary, #F9FAFB);
}

.btn-ghost:focus-visible {
    outline: 3px solid var(--color-brand-focus, #4F46E5);
    outline-offset: 2px;
}

/* ============================================
   LINK BUTTON
   ============================================ */

.btn-link {
    background: none;
    color: var(--color-brand-primary, #4F46E5);
    padding: 0.5rem 1rem;
    box-shadow: none;
}

.btn-link:hover {
    background: none;
    color: var(--color-brand-primary-light, #6366F1);
    text-decoration: underline;
    transform: none;
    box-shadow: none;
}

.btn-link:focus-visible {
    outline: 3px solid var(--color-brand-focus, #4F46E5);
    outline-offset: 2px;
}

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

.btn-sm {
    padding: 0.375rem 0.875rem;
    font-size: 0.8125rem;
    line-height: 1.4;
}

.btn-lg {
    padding: 1rem 2.25rem;
    font-size: 1.125rem;
    line-height: 1.5;
}

.btn-xl {
    padding: 1.375rem 3rem;
    font-size: 1.375rem;
    line-height: 1.5;
    font-weight: 700;
}

/* ============================================
   BUTTON WIDTHS
   ============================================ */

.btn-block {
    width: 100%;
}

.btn-auto {
    width: auto;
}

/* ============================================
   BUTTON WITH ICON
   ============================================ */

.btn-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-icon-only {
    padding: 0.75rem;
    width: 3rem;
    height: 3rem;
}

/* ============================================
   BUTTON GROUPS
   ============================================ */

.btn-group {
    display: inline-flex;
    gap: 0.5rem;
}

.btn-group-vertical {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

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

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

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

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
    .btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.875rem;
    }

    .btn-sm {
        padding: 0.3125rem 0.75rem;
        font-size: 0.75rem;
    }

    .btn-lg {
        padding: 0.875rem 1.875rem;
        font-size: 1rem;
    }

    .btn-xl {
        padding: 1.125rem 2.25rem;
        font-size: 1.1875rem;
    }
}

/* ============================================
   ACCESSIBILITY ENHANCEMENTS
   ============================================ */

/* Ensure minimum touch target size (44x44px for mobile) */
@media (max-width: 768px) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
}

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

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

    .btn:hover {
        transform: none;
    }

    .btn-loading::after {
        animation: none;
    }
}
