/**
 * Modern Button Component Styles
 * 
 * A sophisticated, elegant button system inspired by Material Design principles
 * with advanced animations, micro-interactions, and refined aesthetics.
 * All buttons respect the site's design system and dark mode preferences.
 */

/* Base Button Foundation
   ------------------------------------------- */
   .btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1.5;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    overflow: hidden;
    transform: translateZ(0);
    user-select: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
}

/* Material Ripple Effect
   ------------------------------------------- */
.btn::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background-color: currentColor;
    opacity: 0;
    pointer-events: none;
    transition: width 0.3s cubic-bezier(0, 0, 0.2, 1), 
                height 0.3s cubic-bezier(0, 0, 0.2, 1), 
                opacity 0.3s cubic-bezier(0, 0, 0.2, 1);
}

.btn:active::after {
    width: 300%;
    height: 300%;
    opacity: 0.12;
    transition: 0s;
}

/* Focus & Accessibility 
   ------------------------------------------- */
.btn:focus {
    outline: none;
}

.btn:focus-visible {
    box-shadow: 0 0 0 2px var(--bg-primary, #f3f4f6), 
                0 0 0 4px var(--accent-color, #ff8c00);
}

/* Elevation System
   ------------------------------------------- */
.btn-elevated {
    box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.07), 
                0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn-elevated:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 
                0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.btn-elevated:active {
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* Button Variants
   ------------------------------------------- */
/* Primary Button */
.btn-primary {
    background-color: var(--accent-color, #ff8c00);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover, #e67e00);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Secondary Button */
.btn-secondary {
    background-color: rgba(var(--accent-color-rgb, 255, 140, 0), 0.1);
    color: var(--accent-color, #ff8c00);
}

.btn-secondary:hover {
    background-color: rgba(var(--accent-color-rgb, 255, 140, 0), 0.18);
}

/* Tertiary Button */
.btn-tertiary {
    background-color: transparent;
    color: var(--text-primary, #111827);
    box-shadow: inset 0 0 0 1px var(--border-color, #e5e7eb);
}

.btn-tertiary:hover {
    background-color: rgba(0, 0, 0, 0.03);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

/* Text Button */
.btn-text {
    background-color: transparent;
    color: var(--accent-color, #ff8c00);
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.btn-text:hover {
    background-color: rgba(var(--accent-color-rgb, 255, 140, 0), 0.06);
}

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

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.813rem;
    border-radius: 0.313rem;
}

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

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

/* Icon Integration
   ------------------------------------------- */
.btn-icon {
    padding: 0.625rem;
    border-radius: 50%;
}

.btn-icon-xs {
    padding: 0.25rem;
}

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

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

.btn-icon-xl {
    padding: 0.875rem;
}

.btn-icon svg {
    width: 1.25rem;
    height: 1.25rem;
}

.btn-icon-xs svg {
    width: 0.875rem;
    height: 0.875rem;
}

.btn-icon-sm svg {
    width: 1rem;
    height: 1rem;
}

.btn-icon-lg svg {
    width: 1.5rem;
    height: 1.5rem;
}

.btn-icon-xl svg {
    width: 1.75rem;
    height: 1.75rem;
}

/* Combined Icon + Text */
.btn-with-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

/* Special States
   ------------------------------------------- */
/* Disabled State */
.btn:disabled,
.btn.disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

/* Loading State */
.btn-loading {
    position: relative;
    pointer-events: none;
    background-size: 30px 30px !important;
    background-image: linear-gradient(
        -45deg,
        rgba(255, 255, 255, 0.15) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.15) 50%,
        rgba(255, 255, 255, 0.15) 75%,
        transparent 75%,
        transparent
    ) !important;
    animation: btn-loading-stripes 1s linear infinite;
}

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

.btn-loading::before {
    content: "";
    position: absolute;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-top-color: transparent;
    animation: btn-loading-spin 0.7s linear infinite;
}

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

@keyframes btn-loading-stripes {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 30px 0;
    }
}

/* Enhanced Aesthetics
   ------------------------------------------- */
/* Glowing Effect */
.btn-glow {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-glow:hover {
    box-shadow: 0 0 12px rgba(var(--accent-color-rgb, 255, 140, 0), 0.4);
}

/* Subtle gradient for tactile feeling */
.btn-primary {
    background-image: linear-gradient(to bottom, 
        rgba(255, 255, 255, 0.08),
        rgba(0, 0, 0, 0.05));
}

/* Premium Buttons */
.btn-premium {
    background: linear-gradient(135deg, var(--accent-color, #ff8c00), rgba(var(--accent-color-rgb, 255, 140, 0), 0.8));
    color: white;
    box-shadow: 0 4px 10px -1px rgba(var(--accent-color-rgb, 255, 140, 0), 0.4), 
                0 2px 4px -2px rgba(var(--accent-color-rgb, 255, 140, 0), 0.2);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

.btn-premium:hover {
    box-shadow: 0 6px 15px -3px rgba(var(--accent-color-rgb, 255, 140, 0), 0.5),
                0 4px 6px -4px rgba(var(--accent-color-rgb, 255, 140, 0), 0.3);
    transform: translateY(-2px);
}

.btn-premium:active {
    box-shadow: 0 2px 6px -2px rgba(var(--accent-color-rgb, 255, 140, 0), 0.4);
    transform: translateY(0);
}

/* Glass Effect Button */
.btn-glass {
    background-color: var(--accent-color-glassy, rgba(255, 255, 255, 0.1));
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    color: white;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

.btn-glass:hover {
    background-color: var(--accent-hover-glassy, rgba(255, 255, 255, 0.2));
    border-color: var(--accent-color);
}

/* Floating Action Button */
.btn-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background-color: var(--accent-color, #ff8c00);
    color: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15), 
                0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 50;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                background-color 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-fab:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.18), 
                0 3px 6px rgba(0, 0, 0, 0.12);
}

.btn-fab:active {
    transform: scale(0.98);
}

.btn-fab svg {
    width: 1.5rem;
    height: 1.5rem;
}

/* Semantic Colors
   ------------------------------------------- */
.btn-success {
    background-color: #10b981;
    color: white;
}

.btn-success:hover {
    background-color: #059669;
}

.btn-danger {
    background-color: #ef4444;
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-warning {
    background-color: #f59e0b;
    color: white;
}

.btn-warning:hover {
    background-color: #d97706;
}

.btn-info {
    background-color: #3b82f6;
    color: white;
}

.btn-info:hover {
    background-color: #2563eb;
}

/* Button Groups
   ------------------------------------------- */
.btn-group {
    display: inline-flex;
    border-radius: 0.375rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.btn-group .btn {
    border-radius: 0;
    box-shadow: none;
    position: relative;
    flex: 1;
}

.btn-group .btn::before {
    content: "";
    position: absolute;
    top: 10%;
    right: 0;
    height: 80%;
    width: 1px;
    background-color: rgba(0, 0, 0, 0.1);
    pointer-events: none;
}

.btn-group .btn:last-child::before {
    display: none;
}

.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;
}

/* Call-to-Action Button */
.btn-cta {
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.025em;
    background: linear-gradient(135deg, var(--accent-color, #ff8c00) 0%, var(--accent-hover, #e67e00) 100%);
    color: white;
    border-radius: 0.5rem;
    box-shadow: 0 4px 10px rgba(var(--accent-color-rgb, 255, 140, 0), 0.3), 
                0 1px 3px rgba(var(--accent-color-rgb, 255, 140, 0), 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(var(--accent-color-rgb, 255, 140, 0), 0.35), 
                0 3px 6px rgba(var(--accent-color-rgb, 255, 140, 0), 0.25);
}

.btn-cta:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(var(--accent-color-rgb, 255, 140, 0), 0.2);
}

/* Dark Mode Refinements
   ------------------------------------------- */
[data-theme="dark"] .btn-tertiary {
    color: var(--text-primary, #f9fafb);
    box-shadow: inset 0 0 0 1px var(--border-color, #4b5563);
}

[data-theme="dark"] .btn-tertiary:hover {
    background-color: rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .btn-secondary {
    background-color: rgba(var(--accent-color-rgb, 255, 159, 28), 0.15);
    color: var(--accent-color, #ff9f1c);
}

[data-theme="dark"] .btn-secondary:hover {
    background-color: rgba(var(--accent-color-rgb, 255, 159, 28), 0.22);
}

[data-theme="dark"] .btn-text {
    color: var(--accent-color, #ff9f1c);
}

[data-theme="dark"] .btn-text:hover {
    background-color: rgba(var(--accent-color-rgb, 255, 159, 28), 0.1);
}

[data-theme="dark"] .btn-group .btn::before {
    background-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .btn:focus-visible {
    box-shadow: 0 0 0 2px var(--bg-primary, #111827), 
                0 0 0 4px var(--accent-color, #ff9f1c);
}

/* Responsive Adjustments
   ------------------------------------------- */
@media (max-width: 768px) {
    .btn-responsive {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    .btn-cta.btn-responsive {
        padding: 0.625rem 1.5rem;
    }
    
    .btn-fab {
        width: 3rem;
        height: 3rem;
        bottom: 1.25rem;
        right: 1.25rem;
    }
    
    .btn-fab svg {
        width: 1.25rem;
        height: 1.25rem;
    }
}

@media (max-width: 640px) {
    .btn-full-mobile {
        width: 100%;
        display: flex;
        justify-content: center;
    }
}

/* Animation Utilities
   ------------------------------------------- */
@keyframes micro-bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-2px);
    }
}

.btn-micro-bounce:hover {
    animation: micro-bounce 0.5s ease infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(var(--accent-color-rgb, 255, 140, 0), 0.6);
    }
    70% {
        box-shadow: 0 0 0 12px rgba(var(--accent-color-rgb, 255, 140, 0), 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(var(--accent-color-rgb, 255, 140, 0), 0);
    }
}

.btn-pulse {
    animation: pulse 2s infinite;
}

/* Preload & Theme Transition Handling
   ------------------------------------------- */
.preload .btn {
    transition: none !important;
}

.theme-transition .btn {
    transition: color 0.6s cubic-bezier(0.22, 1, 0.36, 1),
                background-color 0.6s cubic-bezier(0.22, 1, 0.36, 1),
                box-shadow 0.6s cubic-bezier(0.22, 1, 0.36, 1),
                border-color 0.6s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
}