/**
 * Unified Button System
 *
 * @package eRide Theme
 * @version 2.3.0
 * @created 2026-01-02
 * @modified 2026-01-13 - Use shared animations from variables.css
 *
 * PURPOSE: Provide consistent button styling for custom components
 * using the brand teal color from variables.css.
 *
 * DEPENDENCIES: variables.css (colors + eride-spin animation)
 *
 * COLOR SYSTEM: References variables.css
 * - Primary:      var(--color-primary) - brand teal
 * - Primary Dark: var(--color-primary-dark) - hover state
 * - See variables.css for full color palette
 *
 * USAGE: Apply these classes to custom PHP components.
 * React components use Tailwind with matching colors.
 *
 * CHANGELOG:
 * v2.3.0 - Consolidated animations: use eride-spin from variables.css
 *        - Removed local @keyframes eride-btn-spin
 * v2.2.0 - Integrated with global variables.css color system
 *        - Removed local color definitions (use global)
 *        - Aligned all buttons with brand teal
 * v2.1.0 - Unified color system with #14B8A6 teal (deprecated)
 * v2.0.0 - Theme-aligned rewrite (deprecated)
 * v1.0.0 - Initial unified button system (deprecated)
 */

/* ============================================
   Unified Color System
   ============================================
   References global variables.css - DO NOT redefine colors here
   See variables.css for: --color-primary, --color-primary-dark, etc.
*/

:root {
    /* Map unified-* to global color system for backwards compatibility */
    --unified-primary: var(--color-primary);
    --unified-primary-dark: var(--color-primary-dark);
    --unified-base: var(--color-base, #ffffff);
    --unified-contrast: var(--color-contrast, #000000);
    --unified-gray-text: var(--color-gray-100, #333e48);
    --unified-gray-border: var(--color-gray-1100, #d6d6d6);
    --unified-gray-bg: var(--color-base-2, #f5f5f6);
    --unified-danger: var(--color-danger-strong, #d9374e);
    --unified-danger-dark: var(--color-error, #c0392b);
}

/* ============================================
   Unified Button Base
   ============================================

   Primary button style:
   - Teal background (var(--color-primary)) with white text
   - Pill-shaped (border-radius: 20px)
   - Uppercase text with letter-spacing
   - Smooth transitions
*/

.eride-btn {
    /* Layout */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    /* Sizing */
    min-height: 44px;
    padding: 14px 24px;

    /* Typography */
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;

    /* Visual - unified colors */
    background-color: var(--unified-primary);
    color: var(--unified-base);
    border: none;
    border-radius: 20px;

    /* Interaction */
    cursor: pointer;
    transition: all 0.3s ease-in-out;

    /* Reset */
    appearance: none;
    -webkit-appearance: none;
}

.eride-btn:hover,
.eride-btn:focus {
    background-color: var(--unified-primary-dark);
    color: var(--unified-base);
    text-decoration: none;
}

.eride-btn:active {
    transform: translateY(1px);
}

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

/* ============================================
   Outline Variant
   ============================================
*/

.eride-btn--outline {
    background-color: transparent;
    color: var(--unified-primary);
    border: 2px solid var(--unified-primary);
}

.eride-btn--outline:hover,
.eride-btn--outline:focus {
    background-color: var(--unified-primary);
    color: var(--unified-base);
}

/* ============================================
   Secondary Variant (Gray/Neutral)
   ============================================
*/

.eride-btn--secondary {
    background-color: var(--unified-gray-text);
    color: var(--unified-base);
}

.eride-btn--secondary:hover,
.eride-btn--secondary:focus {
    background-color: var(--unified-contrast);
    color: var(--unified-base);
}

/* ============================================
   Ghost Variant (Text-only with hover fill)
   ============================================
*/

.eride-btn--ghost {
    background-color: transparent;
    color: var(--unified-contrast);
    border: none;
}

.eride-btn--ghost:hover,
.eride-btn--ghost:focus {
    background-color: var(--unified-gray-bg);
    color: var(--unified-contrast);
}

/* ============================================
   Inverted Variant (White button for dark bgs)
   ============================================
*/

.eride-btn--inverted {
    background-color: var(--unified-base);
    color: var(--unified-contrast);
}

.eride-btn--inverted:hover,
.eride-btn--inverted:focus {
    background-color: var(--unified-gray-bg);
    color: var(--unified-contrast);
}

/* ============================================
   Danger Variant
   ============================================
*/

.eride-btn--danger {
    background-color: var(--unified-danger);
    color: var(--unified-base);
}

.eride-btn--danger:hover,
.eride-btn--danger:focus {
    background-color: var(--unified-danger-dark);
    color: var(--unified-base);
}

/* ============================================
   Size Modifiers
   ============================================
*/

.eride-btn--sm {
    min-height: 36px;
    padding: 8px 16px;
    font-size: 13px;
}

.eride-btn--lg {
    min-height: 52px;
    padding: 16px 32px;
    font-size: 16px;
}

/* ============================================
   Shape Modifiers
   ============================================
*/

.eride-btn--rounded {
    border-radius: 8px;
}

.eride-btn--square {
    border-radius: 0;
}

/* ============================================
   Full Width
   ============================================
*/

.eride-btn--block {
    display: flex;
    width: 100%;
}

/* ============================================
   Disabled State
   ============================================
*/

.eride-btn:disabled,
.eride-btn[disabled],
.eride-btn.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ============================================
   Loading State
   ============================================
*/

.eride-btn.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.eride-btn.is-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid var(--unified-base);
    border-top-color: transparent;
    border-radius: 50%;
    animation: eride-spin 0.8s linear infinite; /* Uses shared animation from variables.css */
}

/* ============================================
   Custom Component: Meta OTP Buttons
   ============================================
   Styles for WhatsApp OTP login form buttons
*/

.meta-otp-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 14px 24px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease-in-out;
}

.meta-otp-button-primary {
    background-color: var(--unified-primary);
    color: var(--unified-base);
}

.meta-otp-button-primary:hover,
.meta-otp-button-primary:focus {
    background-color: var(--unified-primary-dark);
}

.meta-otp-button-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.meta-otp-link-button {
    background: transparent;
    border: none;
    color: var(--unified-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.meta-otp-link-button:hover {
    color: var(--unified-primary-dark);
}

/* ============================================
   Custom Component: Quote Option Pills
   ============================================
   Tab-style selection buttons for treatment plans
*/

.quote-option-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    background-color: transparent;
    color: var(--unified-gray-text);
    border: 2px solid var(--unified-gray-border);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quote-option-pill:hover {
    border-color: var(--unified-primary);
    color: var(--unified-primary);
}

.quote-option-pill.is-active,
.quote-option-pill.active,
.quote-option-pill[aria-selected="true"] {
    background-color: var(--unified-primary);
    border-color: var(--unified-primary);
    color: var(--unified-base);
}

/* ============================================
   Custom Component: Treatment Photo Buttons
   ============================================
*/

.tp-view-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    background-color: transparent;
    color: var(--unified-gray-text);
    border: 1px solid var(--unified-gray-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tp-view-btn:hover {
    background-color: var(--unified-gray-bg);
}

.tp-view-btn.is-active,
.tp-view-btn.active {
    background-color: var(--unified-primary);
    border-color: var(--unified-primary);
    color: var(--unified-base);
}

.tp-editor-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 500;
    background-color: var(--unified-base);
    color: var(--unified-gray-text);
    border: 1px solid var(--unified-gray-border);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tp-editor-btn:hover {
    background-color: var(--unified-gray-bg);
    border-color: #7f7f7f;
}

/* ============================================
   Custom Component: Print Button
   ============================================
*/

.print-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    background-color: var(--unified-primary);
    color: var(--unified-base);
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.print-button:hover {
    background-color: var(--unified-primary-dark);
}

@media print {
    .print-button.no-print {
        display: none !important;
    }
}

/* ============================================
   Custom Component: Filter Pills
   ============================================
   Used in treatment taxonomy archives
*/

.treatment-pill,
.filter-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    background-color: var(--unified-base);
    color: var(--unified-gray-text);
    border: 1px solid var(--unified-gray-border);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.treatment-pill:hover,
.filter-toggle-btn:hover {
    border-color: var(--unified-primary);
    color: var(--unified-primary);
}

/* Active state for filter toggle buttons - subtle indicator (Issue #9)
 * Uses subtle border + soft shadow instead of teal background fill */
.filter-toggle-btn.is-active,
.filter-toggle-btn.active {
    background-color: var(--unified-base);
    border-color: var(--unified-primary);
    color: var(--unified-contrast);
    font-weight: 600;
    box-shadow:
        0 2px 4px rgba(100, 197, 178, 0.15),
        0 1px 2px rgba(100, 197, 178, 0.1);
}

/* ============================================
   Accessibility: Reduced Motion
   ============================================
*/

@media (prefers-reduced-motion: reduce) {
    .eride-btn,
    .meta-otp-button,
    .quote-option-pill,
    .tp-view-btn,
    .tp-editor-btn,
    .print-button,
    .treatment-pill,
    .filter-toggle-btn {
        transition: none;
    }

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

/* ============================================
   Accessibility: High Contrast
   ============================================
*/

@media (prefers-contrast: more) {
    .eride-btn,
    .meta-otp-button,
    .quote-option-pill,
    .tp-view-btn,
    .tp-editor-btn,
    .print-button,
    .treatment-pill,
    .filter-toggle-btn {
        border: 2px solid currentColor;
    }

    .eride-btn:focus-visible,
    .meta-otp-button:focus-visible,
    .quote-option-pill:focus-visible {
        outline-width: 3px;
        outline-offset: 3px;
    }
}
