/* =========================================================
   BUTTON SYSTEM — ENHANCED & PROFESSIONAL
   ========================================================= */

/* Base button styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s var(--ease);
    position: relative;
    overflow: hidden;
    text-decoration: none;
    user-select: none;
    
    /* Accessibility */
    min-width: 44px;
    min-height: 44px;
    
    /* Smooth transition for all properties */
    --transition-duration: 0.2s;
}

/* Remove focus outline by default, will add via :focus-visible */
.btn:focus {
    outline: none;
}

/* =========================================================
   BUTTON VARIANTS
   ========================================================= */

/* Primary Button */
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #1348d8 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(26, 86, 219, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, #0f3db5 100%);
    box-shadow: 0 6px 16px rgba(26, 86, 219, 0.35);
    transform: translateY(-1px);
}

.btn-primary:active {
    box-shadow: 0 2px 8px rgba(26, 86, 219, 0.2);
    transform: translateY(0);
}

.btn-primary:disabled {
    background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
    color: rgba(255, 255, 255, 0.6);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Secondary Button */
.btn-secondary {
    background: rgba(26, 86, 219, 0.08);
    color: var(--primary);
    border: 1px solid rgba(26, 86, 219, 0.2);
}

.btn-secondary:hover {
    background: rgba(26, 86, 219, 0.15);
    border-color: rgba(26, 86, 219, 0.35);
    box-shadow: 0 4px 12px rgba(26, 86, 219, 0.1);
}

.btn-secondary:active {
    background: rgba(26, 86, 219, 0.2);
    transform: scale(0.98);
}

.btn-secondary:disabled {
    background: rgba(0, 0, 0, 0.04);
    color: rgba(0, 0, 0, 0.3);
    border-color: rgba(0, 0, 0, 0.1);
    cursor: not-allowed;
}

/* Tertiary Button (Ghost) */
.btn-tertiary {
    background: transparent;
    color: var(--primary);
    border: 1px solid transparent;
}

.btn-tertiary:hover {
    background: rgba(26, 86, 219, 0.06);
    border-color: rgba(26, 86, 219, 0.15);
}

.btn-tertiary:active {
    background: rgba(26, 86, 219, 0.12);
}

.btn-tertiary:disabled {
    color: rgba(0, 0, 0, 0.3);
    cursor: not-allowed;
}

/* Success Button */
.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #047857 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-success:hover {
    box-shadow: 0 6px 16px rgba(5, 150, 105, 0.35);
    transform: translateY(-1px);
}

.btn-success:active {
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.2);
}

/* Danger Button */
.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #b91c1c 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-danger:hover {
    box-shadow: 0 6px 16px rgba(220, 38, 38, 0.35);
    transform: translateY(-1px);
}

.btn-danger:active {
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.2);
}

/* Warning Button */
.btn-warning {
    background: linear-gradient(135deg, var(--warning) 0%, #c59500 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-warning:hover {
    box-shadow: 0 6px 16px rgba(217, 119, 6, 0.35);
    transform: translateY(-1px);
}

/* =========================================================
   SIZE VARIANTS
   ========================================================= */

/* Small */
.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    min-width: 40px;
    min-height: 40px;
}

/* Medium (default) */
.btn-md {
    padding: 10px 16px;
    font-size: 14px;
}

/* Large */
.btn-lg {
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 600;
    min-width: 48px;
    min-height: 48px;
}

/* Extra Large */
.btn-xl {
    padding: 16px 32px;
    font-size: 16px;
    font-weight: 600;
    min-width: 52px;
    min-height: 52px;
}

/* =========================================================
   ICON BUTTONS
   ========================================================= */

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    min-width: 44px;
    min-height: 44px;
}

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

.btn-icon svg {
    width: 20px;
    height: 20px;
    display: block;
}

/* =========================================================
   SPECIAL STATES
   ========================================================= */

/* Loading state */
.btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.btn.loading::after {
    content: '';
    display: inline-block;
    width: 4px;
    height: 4px;
    background: currentColor;
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
    margin-left: 4px;
}

/* Group buttons */
.btn-group {
    display: flex;
    gap: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-group .btn {
    border-radius: 0;
    flex: 1;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 0;
}

.btn-group .btn:last-child {
    border-right: none;
}

.btn-group .btn.active {
    background: linear-gradient(135deg, var(--primary) 0%, #1348d8 100%);
    color: white;
}

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

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

/* High contrast mode support */
@media (prefers-contrast: more) {
    .btn-primary {
        border-width: 2px;
    }
    
    .btn-secondary {
        border-width: 2px;
    }
}

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

/* =========================================================
   DARK MODE
   ========================================================= */

[data-theme="dark"] .btn-secondary {
    background: rgba(56, 189, 248, 0.08);
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.2);
}

[data-theme="dark"] .btn-secondary:hover {
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.35);
}

[data-theme="dark"] .btn-tertiary {
    color: #38bdf8;
}

[data-theme="dark"] .btn-tertiary:hover {
    background: rgba(56, 189, 248, 0.06);
    border-color: rgba(56, 189, 248, 0.15);
}

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

@media (max-width: 768px) {
    .btn {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .btn-lg {
        padding: 12px 20px;
        font-size: 14px;
    }
}

/* Touch-optimized sizes on mobile */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 48px;
        min-width: 48px;
    }
}
