/* ============================================
   ENHANCED INTERACTIONS & BUTTON SYSTEM
   Phase 5: Refined buttons with micro-interactions
   Miniaturized (1/4 scale), smooth animations
   ============================================ */

/* ============================================
   REFINED BUTTON SYSTEM
   ============================================ */

/* Base Button - Miniaturized & Enhanced */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: var(--button-padding-y) var(--button-padding-x); /* 0.5rem 1rem */
    border-radius: var(--radius-md);
    font-size: var(--button-font-size); /* 0.875rem */
    font-weight: var(--font-semibold);
    font-family: 'Plus Jakarta Sans', sans-serif;
    letter-spacing: -0.01em;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    border: none;
    transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    user-select: none;
}

/* Primary Button - Gradient with Smooth Hover */
.btn-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: var(--bg-lightest);
    box-shadow: 0 2px 8px rgba(79, 117, 255, 0.20);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(79, 117, 255, 0.30);
    background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-primary) 100%);
}

.btn-primary:active {
    transform: translateY(-1px) scale(0.98);
    box-shadow: 0 3px 10px rgba(79, 117, 255, 0.25);
}

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

/* Secondary Button - Outlined with Hover Fill */
.btn-secondary {
    background: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
    box-shadow: 0 1px 3px rgba(79, 117, 255, 0.05);
}

.btn-secondary:hover {
    background: var(--color-primary);
    color: var(--bg-lightest);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 117, 255, 0.20);
}

.btn-secondary:active {
    transform: translateY(-1px) scale(0.98);
}

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

/* Tertiary Button - Ghost Style with Subtle Hover */
.btn-tertiary {
    background: transparent;
    color: var(--text-primary);
    border: none;
    box-shadow: none;
}

.btn-tertiary:hover {
    background: var(--bg-light);
    color: var(--color-primary);
    transform: translateY(-1px);
}

.btn-tertiary:active {
    transform: scale(0.98);
    background: var(--bg-medium);
}

/* Outline Button (Alternative Secondary) */
.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.btn-outline:hover {
    background: var(--bg-light);
    border-color: var(--color-primary);
    color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.btn-outline:active {
    transform: translateY(-1px) scale(0.98);
}

/* Icon Button - Compact & Circular */
.btn-icon {
    width: 2rem; /* Miniaturized from 2.5rem */
    height: 2rem;
    padding: 0;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
    transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-icon:hover {
    background: var(--color-primary);
    color: var(--bg-lightest);
    border-color: var(--color-primary);
    transform: translateY(-2px) rotate(5deg);
    box-shadow: 0 4px 12px rgba(79, 117, 255, 0.25);
}

.btn-icon:active {
    transform: translateY(-1px) scale(0.95);
}

/* Button Sizes */
.btn-sm {
    padding: var(--button-padding-sm-y) var(--button-padding-sm-x); /* 0.375rem 0.75rem */
    font-size: var(--button-font-size-sm); /* 0.75rem */
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: var(--font-base); /* 1rem */
}

.btn-xl {
    padding: 1rem 2rem;
    font-size: var(--font-md); /* 1.125rem */
}

/* Button Variants - Success, Warning, Error */
.btn-success {
    background: linear-gradient(135deg, var(--color-success) 0%, var(--color-success) 100%);
    color: var(--bg-lightest);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.20);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.30);
    filter: brightness(1.1);
}

.btn-warning {
    background: linear-gradient(135deg, var(--color-warning) 0%, var(--color-warning) 100%);
    color: var(--bg-lightest);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.20);
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.30);
    filter: brightness(1.1);
}

.btn-error {
    background: linear-gradient(135deg, var(--color-error) 0%, var(--color-error) 100%);
    color: var(--bg-lightest);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.20);
}

.btn-error:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.30);
    filter: brightness(1.1);
}

/* Button States */
.btn:disabled,
.btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.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 currentColor;
    border-radius: 50%;
    border-right-color: transparent;
    animation: spin 0.6s linear infinite;
}

/* Nav CTA Button */
.btn-nav-cta {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: var(--bg-lightest);
    border-radius: var(--radius-md);
    font-weight: var(--font-semibold);
    font-size: var(--font-sm);
    text-decoration: none;
    transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(79, 117, 255, 0.15);
}

.btn-nav-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 117, 255, 0.25);
    background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-primary) 100%);
}

.btn-nav-cta:active {
    transform: translateY(-1px) scale(0.98);
}

/* ============================================
   MICRO-INTERACTIONS - LINKS
   ============================================ */

/* Enhanced Link Hover with Underline Animation */
a:not(.btn):not(.btn-nav-cta) {
    color: var(--color-primary);
    text-decoration: none;
    position: relative;
    transition: color 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

a:not(.btn):not(.btn-nav-cta)::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--color-primary);
    transition: width 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

a:not(.btn):not(.btn-nav-cta):hover {
    color: var(--color-primary-dark);
}

a:not(.btn):not(.btn-nav-cta):hover::after {
    width: 100%;
}

/* Nav Links - Special Styling */
.nav-links a {
    color: var(--text-primary);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.nav-links a::after {
    display: none; /* Remove underline for nav */
}

.nav-links a:hover {
    color: var(--color-primary);
    background: var(--bg-light);
}

/* ============================================
   CARD MICRO-INTERACTIONS
   ============================================ */

/* Enhanced Card Hover - Already on automation cards, apply elsewhere */
.card,
.feature-card,
.pricing-card,
.stat-card {
    transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover,
.feature-card:hover,
.pricing-card:hover,
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    border-color: rgba(79, 117, 255, 0.20);
}

/* Card with Glow Effect on Hover */
.card-glow:hover {
    box-shadow:
        0 8px 24px rgba(15, 23, 42, 0.12),
        0 0 20px rgba(79, 117, 255, 0.15);
}

/* ============================================
   INPUT MICRO-INTERACTIONS
   ============================================ */

/* Enhanced Input Focus with Glow */
.input-field,
.select-field,
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
textarea,
select {
    transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.input-field:focus,
.select-field:focus,
input:focus,
textarea:focus,
select:focus {
    border-color: var(--color-primary) !important;
    box-shadow:
        0 0 0 3px rgba(79, 117, 255, 0.08),
        0 1px 3px rgba(79, 117, 255, 0.10) !important;
    transform: translateY(-1px);
}

/* Input with Icon - Add subtle animation */
.input-group:has(input:focus) label {
    color: var(--color-primary);
    transform: translateX(2px);
    transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   CHECKBOX & TOGGLE ANIMATIONS
   ============================================ */

/* Enhanced Checkbox with Smooth Check Animation */
input[type="checkbox"] {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-medium);
    border-radius: var(--radius-sm);
    background: var(--bg-lightest);
    cursor: pointer;
    position: relative;
    transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

input[type="checkbox"]:hover {
    border-color: var(--color-primary);
    transform: scale(1.05);
}

input[type="checkbox"]:checked {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    color: var(--bg-lightest);
    font-size: 12px;
    animation: checkmark 250ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes checkmark {
    to {
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-medium);
    border-radius: var(--radius-full);
    transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--bg-lightest);
    border-radius: 50%;
    transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toggle input:checked + .toggle-slider {
    background: var(--color-primary);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.toggle:hover .toggle-slider {
    box-shadow: 0 0 8px rgba(79, 117, 255, 0.15);
}

/* ============================================
   RIPPLE EFFECT (Subtle)
   ============================================ */

.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.4s, height 0.4s;
}

.btn-ripple:active::after {
    width: 300px;
    height: 300px;
    transition: width 0s, height 0s;
}

/* ============================================
   PAGE LOAD ANIMATIONS
   ============================================ */

/* Fade-in animation for sections */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Stagger children animations */
.stagger-children > * {
    opacity: 0;
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.5s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.6s; }

/* ============================================
   SCROLL-TRIGGERED ANIMATIONS (Subtle)
   ============================================ */

/* Elements with scroll-reveal class */
.scroll-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Scale-in animation */
.scale-in {
    opacity: 0;
    transform: scale(0.95);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.scale-in.revealed {
    opacity: 1;
    transform: scale(1);
}

/* ============================================
   LOADING STATES
   ============================================ */

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

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-light) 25%,
        var(--bg-medium) 50%,
        var(--bg-light) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ============================================
   UTILITY ANIMATIONS
   ============================================ */

.bounce {
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.shake {
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* ============================================
   FOCUS VISIBLE STATES (Accessibility)
   ============================================ */

*:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

button:focus-visible,
.btn:focus-visible {
    outline-offset: 3px;
}

/* ============================================
   REDUCED MOTION SUPPORT
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .btn:hover,
    .card:hover,
    a:hover {
        transform: none !important;
    }
}

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

@media (max-width: 768px) {
    .btn {
        padding: 0.5rem 1rem;
        font-size: var(--font-sm);
    }

    .btn-lg {
        padding: 0.625rem 1.25rem;
        font-size: var(--font-base);
    }

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

/* ============================================
   HOVER ONLY ON NON-TOUCH DEVICES
   ============================================ */

@media (hover: none) {
    .btn:hover,
    .card:hover,
    a:hover {
        transform: none;
    }
}
