/*
 * Buttons Component Styles
 * Responsive button styles with consistent sizing and states
 * Breakpoints: mobile (default), sm (640px), md (768px), lg (1024px)
 */

/* Base button styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.btn:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

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

/* Button sizes */
.btn-xs {
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    line-height: 1.25;
    border-radius: 0.25rem;
}

.btn-sm {
    padding: 0.375rem 0.875rem;
    font-size: 0.875rem;
    line-height: 1.5;
    border-radius: 0.3125rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    line-height: 1.5;
    border-radius: 0.5rem;
}

.btn-xl {
    padding: 0.875rem 1.75rem;
    font-size: 1.125rem;
    line-height: 1.75;
    border-radius: 0.5rem;
}

/* Button variants */
.btn-primary {
    color: white;
    background-color: var(--primary-color, #3b82f6);
    border-color: var(--primary-color, #3b82f6);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-dark, #2563eb);
    border-color: var(--primary-dark, #2563eb);
}

.btn-primary:active:not(:disabled) {
    background-color: #1d4ed8;
    border-color: #1d4ed8;
}

.btn-primary:disabled {
    background-color: #9ca3af;
    border-color: #9ca3af;
}

.btn-secondary {
    color: var(--text-primary, #374151);
    background-color: var(--bg-secondary, #f3f4f6);
    border-color: var(--border-color, #d1d5db);
}

.btn-secondary:hover:not(:disabled) {
    background-color: #e5e7eb;
    border-color: #9ca3af;
}

.btn-secondary:active:not(:disabled) {
    background-color: #d1d5db;
}

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

.btn-success:hover:not(:disabled) {
    background-color: #059669;
    border-color: #059669;
}

.btn-success:active:not(:disabled) {
    background-color: #047857;
}

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

.btn-danger:hover:not(:disabled) {
    background-color: #dc2626;
    border-color: #dc2626;
}

.btn-danger:active:not(:disabled) {
    background-color: #b91c1c;
}

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

.btn-warning:hover:not(:disabled) {
    background-color: #d97706;
    border-color: #d97706;
}

.btn-warning:active:not(:disabled) {
    background-color: #b45309;
}

.btn-info {
    color: white;
    background-color: var(--info-color, #06b6d4);
    border-color: var(--info-color, #06b6d4);
}

.btn-info:hover:not(:disabled) {
    background-color: #0891b2;
    border-color: #0891b2;
}

.btn-info:active:not(:disabled) {
    background-color: #0e7490;
}

/* Outline buttons */
.btn-outline-primary {
    color: var(--primary-color, #3b82f6);
    background-color: transparent;
    border-color: var(--primary-color, #3b82f6);
}

.btn-outline-primary:hover:not(:disabled) {
    color: white;
    background-color: var(--primary-color, #3b82f6);
}

.btn-outline-secondary {
    color: var(--text-primary, #374151);
    background-color: transparent;
    border-color: var(--border-color, #d1d5db);
}

.btn-outline-secondary:hover:not(:disabled) {
    background-color: var(--bg-secondary, #f3f4f6);
    border-color: #9ca3af;
}

.btn-outline-danger {
    color: var(--danger-color, #ef4444);
    background-color: transparent;
    border-color: var(--danger-color, #ef4444);
}

.btn-outline-danger:hover:not(:disabled) {
    color: white;
    background-color: var(--danger-color, #ef4444);
}

/* Ghost buttons (no border) */
.btn-ghost {
    color: var(--text-primary, #374151);
    background-color: transparent;
    border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
    background-color: var(--bg-hover, #f9fafb);
}

.btn-ghost:active:not(:disabled) {
    background-color: #f3f4f6;
}

/* Link style button */
.btn-link {
    color: var(--primary-color, #3b82f6);
    background-color: transparent;
    border-color: transparent;
    text-decoration: underline;
    padding: 0;
}

.btn-link:hover:not(:disabled) {
    color: var(--primary-dark, #2563eb);
    text-decoration: none;
}

/* Icon buttons */
.btn-icon {
    padding: 0.625rem;
    aspect-ratio: 1;
}

.btn-icon.btn-sm {
    padding: 0.375rem;
}

.btn-icon.btn-lg {
    padding: 0.75rem;
}

/* Full width button */
.btn-block {
    display: flex;
    width: 100%;
}

/* Button groups */
.btn-group {
    display: inline-flex;
    align-items: center;
    gap: 0;
}

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

.btn-group .btn:first-child {
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}

.btn-group .btn:last-child {
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

.btn-group .btn:not(:first-child) {
    margin-left: -1px;
}

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

/* Loading state */
.btn-loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    color: white;
}

.btn-outline-primary.btn-loading::after,
.btn-outline-secondary.btn-loading::after,
.btn-outline-danger.btn-loading::after,
.btn-ghost.btn-loading::after,
.btn-link.btn-loading::after {
    color: var(--primary-color, #3b82f6);
}

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

/* Responsive adjustments */
@media (max-width: 639px) {
    /* Make buttons slightly larger on mobile for touch */
    .btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.9375rem;
        min-height: 44px; /* Minimum touch target */
    }

    .btn-sm {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
        min-height: 40px;
    }

    .btn-xs {
        padding: 0.375rem 0.75rem;
        font-size: 0.8125rem;
        min-height: 36px;
    }

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

    .btn-group-responsive .btn {
        width: 100%;
        border-radius: 0.375rem;
        margin-left: 0;
        margin-top: -1px;
    }

    .btn-group-responsive .btn:first-child {
        margin-top: 0;
    }

    /* Full width buttons on mobile */
    .btn-mobile-block {
        display: flex;
        width: 100%;
    }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }

    .btn-sm {
        min-height: 40px;
        min-width: 40px;
    }

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

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

/* Button with badge */
.btn .badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.375rem;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1;
    border-radius: 9999px;
    background-color: rgba(255, 255, 255, 0.9);
    color: var(--primary-color, #3b82f6);
}

.btn-primary .badge {
    background-color: rgba(255, 255, 255, 0.9);
    color: var(--primary-color, #3b82f6);
}

.btn-outline-primary .badge,
.btn-secondary .badge {
    background-color: var(--primary-color, #3b82f6);
    color: white;
}

/* Floating action button */
.btn-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 3.5rem;
    height: 3.5rem;
    padding: 0;
    border-radius: 50%;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 50;
}

.btn-fab:hover {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

@media (max-width: 639px) {
    .btn-fab {
        bottom: 1rem;
        right: 1rem;
        width: 3rem;
        height: 3rem;
    }
}

/* Button toolbar */
.btn-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

@media (max-width: 639px) {
    .btn-toolbar-responsive {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-toolbar-responsive .btn {
        width: 100%;
    }
}
