/* ============================================================================
   UNIFIED BUTTON SYSTEM - AppWiso
   ============================================================================

   This file defines all button styles for AppWiso.

   Variants:
   - .btn-primary    → Primary action (black/white accent)
   - .btn-secondary  → Secondary action (subtle background)
   - .btn-accent     → Feature highlight (amber, Pulse feature)
   - .btn-ghost      → Minimal emphasis (transparent)
   - .btn-danger     → Destructive action (red)

   Sizes:
   - .btn-sm         → Compact (8px 16px)
   - .btn            → Default (12px 24px)
   - .btn-lg         → Large (16px 32px)

   States:
   - :hover          → Lift + shadow (auto-added)
   - :disabled       → Reduced opacity + no hover
   - :focus          → Outline for accessibility

   ============================================================================ */

/* Base Button */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 12px 24px;
    border-radius: 100px;              /* Pill shape per DESIGN_GUIDELINES */
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.01em;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

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

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

/* Primary - High emphasis actions */
.btn-primary {
    background: var(--accent-color);   /* Black in light / White in dark */
    color: var(--bg-color);
}

.btn-primary:hover:not(:disabled) {
    opacity: 0.9;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Secondary - Medium emphasis */
.btn-secondary {
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--card-border);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--accent-color);
    background: var(--code-bg);
}

/* Accent - Feature highlight (Pulse/Bloomberg aesthetic) */
.btn-accent {
    background: var(--accent-primary);  /* #f59e0b amber */
    color: white;                       /* White text for better contrast on amber */
    font-weight: 700;
}

.btn-accent:hover:not(:disabled) {
    opacity: 0.9;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

/* Ghost - Minimal emphasis (text-only) */
.btn-ghost {
    background: transparent;
    color: var(--text-color);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--card-bg);
}

/* Outline - Border-based styling */
.btn-outline {
    background: transparent;
    color: var(--accent-color);
    border: 2px solid var(--accent-color);
    padding: 10px 22px;  /* Adjusted for border thickness */
}

.btn-outline:hover:not(:disabled) {
    background: var(--accent-color);
    color: var(--bg-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Danger - Destructive actions */
.btn-danger {
    background: var(--danger-color, #ef4444);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    opacity: 0.9;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Success - Positive actions */
.btn-success {
    background: var(--success-color, #22c55e);
    color: white;
}

.btn-success:hover:not(:disabled) {
    opacity: 0.9;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

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

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
}

/* ============================================================================
   STATES & UTILITIES
   ============================================================================ */

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

/* Icon spacing */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Loading state (add via JS) */
.btn.is-loading {
    opacity: 0.7;
    pointer-events: none;
}

.btn.is-loading::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 0.5rem;
}

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

/* Button groups */
.btn-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-group.vertical {
    flex-direction: column;
}

/* ============================================================================
   LEGACY COMPATIBILITY ALIASES
   ============================================================================
   Use .btn classes instead - these are deprecated
   ============================================================================ */

/* From main.css */
.btn-primary-pill { @extend .btn-primary; }
.btn-secondary-pill { @extend .btn-secondary; }

/* From landing.ejs v2-btn */
.v2-btn-primary { @extend .btn-primary; }
.v2-btn-secondary { @extend .btn-secondary; }

/* From auth pages (inline btn) */
/* These already use .btn base, just consolidate */

/* ============================================================================
   FORM BUTTON INTEGRATION
   ============================================================================ */

button,
input[type="button"],
input[type="submit"],
input[type="reset"] {
    font-family: 'Inter', sans-serif;
}

/* Form submit buttons default to primary */
form button[type="submit"]:not([class*="btn-"]) {
    @extend .btn;
    @extend .btn-primary;
}

/* Form reset buttons default to secondary */
form button[type="reset"]:not([class*="btn-"]) {
    @extend .btn;
    @extend .btn-secondary;
}

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

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

    .btn-lg {
        padding: 14px 28px;
        font-size: 15px;
    }

    .btn-group {
        flex-direction: column;
    }

    .btn-block {
        width: 100%;
    }
}

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

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

    .btn-secondary {
        border: 2px solid var(--card-border);
    }
}

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

    .btn:hover {
        transform: none;
    }

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