/* =============================================================================
   BUTTON COMPONENTS - Unified Button System
   =============================================================================

   Uses semantic tokens from themes.css for automatic theme support.
   All buttons across the application use these base styles.

   BUTTON VARIANTS:
   - .btn-primary - Primary action buttons (blue)
   - .btn-secondary - Secondary actions (gray)
   - .btn-danger - Destructive actions (red)
   - .btn-success - Success actions (green)
   - .btn-action - Outline style buttons
   - .view-btn - View toggle buttons
   - .sort-btn - Sort control buttons
   - .page-btn - Pagination buttons
   - .quantity-btn - +/- quantity controls
   - .btn-favorite-icon - Favorite icon button

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

/* ========================================
   BASE BUTTON STYLES
   ======================================== */

/* Shared button base */
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-success {
    border: none;
    border-radius: var(--radius-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
}

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

/* Primary Button - Main actions */
.btn-primary {
    background: var(--button-primary-bg);
    color: var(--button-primary-text);
}

.btn-primary:hover {
    background: var(--button-primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

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

.btn-primary:disabled {
    background: var(--interactive-disabled);
    color: var(--text-disabled);
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
}

.btn-primary:disabled:hover {
    background: var(--interactive-disabled);
    transform: none;
    box-shadow: none;
}

/* Secondary Button - Alternative actions */
.btn-secondary {
    background: var(--button-secondary-bg);
    color: var(--button-secondary-text);
}

.btn-secondary:hover {
    background: var(--button-secondary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

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

.btn-secondary:disabled {
    background: var(--interactive-disabled);
    color: var(--text-disabled);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Danger Button - Destructive actions */
.btn-danger {
    background: var(--button-danger-bg);
    color: var(--button-danger-text);
}

.btn-danger:hover {
    background: var(--button-danger-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

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

.btn-danger:disabled {
    background: var(--interactive-disabled);
    color: var(--text-disabled);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Success Button - Positive actions */
.btn-success {
    background: var(--button-success-bg);
    color: var(--button-success-text);
}

.btn-success:hover {
    background: var(--button-success-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

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

.btn-success:disabled {
    background: var(--interactive-disabled);
    color: var(--text-disabled);
    cursor: not-allowed;
    opacity: 0.6;
}

/* ========================================
   OUTLINE/ACTION BUTTONS
   ======================================== */

/* Action Button - Outline style */
.btn-action {
    flex: 1;
    min-width: 150px;
    padding: var(--spacing-sm) var(--spacing-lg);
    background: var(--surface-primary);
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
}

.btn-action:hover {
    background: var(--color-primary);
    color: var(--button-primary-text);
}

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

.btn-action:disabled {
    border-color: var(--border-primary);
    color: var(--text-disabled);
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-action:disabled:hover {
    background: var(--surface-primary);
    color: var(--text-disabled);
}

/* ========================================
   TOGGLE & CONTROL BUTTONS
   ======================================== */

/* View Toggle Buttons */
.view-toggle {
    display: flex;
    gap: var(--spacing-xs);
}

.view-btn {
    padding: var(--spacing-sm) var(--spacing-lg);
    border: 1px solid var(--border-primary);
    background: var(--surface-primary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    transition: all var(--transition-fast);
    color: var(--text-primary);
}

.view-btn.active {
    background: var(--color-primary);
    color: var(--button-primary-text);
    border-color: var(--color-primary);
}

.view-btn:hover:not(.active) {
    background: var(--interactive-hover);
    border-color: var(--border-focus);
}

.view-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Sort Buttons */
.sort-btn {
    padding: var(--spacing-sm) var(--spacing-lg);
    border: 1px solid var(--border-primary);
    background: var(--surface-primary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    transition: all var(--transition-fast);
    white-space: nowrap;
    color: var(--text-primary);
}

.sort-btn.active {
    background: var(--color-primary);
    color: var(--button-primary-text);
    border-color: var(--color-primary);
}

.sort-btn:hover:not(.active) {
    background: var(--interactive-hover);
    border-color: var(--border-focus);
}

.sort-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================
   PAGINATION BUTTONS
   ======================================== */

.page-btn {
    padding: var(--spacing-sm) var(--spacing-lg);
    border: 1px solid var(--border-primary);
    background: var(--surface-primary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    transition: all var(--transition-fast);
    color: var(--text-primary);
}

.page-btn.active {
    background: var(--color-primary);
    color: var(--button-primary-text);
    border-color: var(--color-primary);
    font-weight: 600;
}

.page-btn:hover:not(.active):not(:disabled) {
    background: var(--interactive-hover);
    border-color: var(--border-focus);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--surface-secondary);
    color: var(--text-disabled);
}

/* Back Button */
.back-button {
    background: var(--button-secondary-bg);
    color: var(--button-secondary-text);
    border: none;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: background var(--transition-fast);
}

.back-button:hover {
    background: var(--button-secondary-hover);
}

/* ========================================
   QUANTITY CONTROLS
   ======================================== */

.quantity-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-primary);
    background: var(--surface-primary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    transition: all var(--transition-fast);
    color: var(--text-primary);
}

.quantity-btn:hover:not(:disabled) {
    background: var(--interactive-hover);
    border-color: var(--border-focus);
    color: var(--color-primary);
}

.quantity-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.quantity-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    color: var(--text-disabled);
}

/* ========================================
   SPECIAL BUTTONS
   ======================================== */

/* Favorite Icon Button */
.btn-favorite-icon {
    background: none;
    border: 2px solid var(--color-error);
    color: var(--color-error);
    border-radius: var(--radius-full);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-left: auto;
}

.btn-favorite-icon:hover {
    background: var(--color-error);
    color: var(--color-white);
    transform: scale(1.1);
}

.btn-favorite-icon.favorited {
    background: var(--color-error);
    color: var(--color-white);
}

.btn-favorite-icon:active {
    transform: scale(1.05);
}

.btn-favorite-icon .favorite-icon {
    font-size: var(--font-size-lg);
}

/* ========================================
   BUTTON GROUPS
   ======================================== */

.button-group {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

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

.button-group.button-group-stretch > * {
    flex: 1;
}

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

.btn-sm {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: var(--font-size-xs);
}

.btn-lg {
    padding: var(--spacing-md) var(--spacing-xl);
    font-size: var(--font-size-base);
}

.btn-xl {
    padding: var(--spacing-lg) var(--spacing-2xl);
    font-size: var(--font-size-lg);
}

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

@media (max-width: 768px) {
    .btn-action {
        width: 100%;
    }

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

    .button-group > * {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .sort-btn,
    .page-btn,
    .view-btn {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: var(--font-size-xs);
    }

    .btn-primary,
    .btn-secondary,
    .btn-danger,
    .btn-success {
        padding: var(--spacing-xs) var(--spacing-md);
        font-size: var(--font-size-xs);
    }
}

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

/* Focus states */
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-danger:focus-visible,
.btn-success:focus-visible,
.btn-action:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.view-btn:focus-visible,
.sort-btn:focus-visible,
.page-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.quantity-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.btn-favorite-icon:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring-error);
}

/* Keyboard navigation indicator */
.btn-primary:focus-visible::before,
.btn-secondary:focus-visible::before,
.btn-danger:focus-visible::before,
.btn-success:focus-visible::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: inherit;
    box-shadow: var(--focus-ring);
    pointer-events: none;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .btn-primary,
    .btn-secondary,
    .btn-danger,
    .btn-success,
    .btn-action,
    .view-btn,
    .sort-btn,
    .page-btn,
    .quantity-btn,
    .btn-favorite-icon {
        transition: none;
    }

    .btn-primary:hover,
    .btn-secondary:hover,
    .btn-danger:hover,
    .btn-success:hover {
        transform: none;
    }

    .btn-favorite-icon:hover {
        transform: none;
    }
}

/* ========================================
   THEME NOTES
   ========================================

   This file uses CSS variables from themes.css exclusively.
   Dark theme support is automatic - no body.dark-theme overrides needed!

   Variables used:
   - Buttons: --button-primary-bg/hover/text, --button-secondary-bg/hover/text
              --button-danger-bg/hover/text, --button-success-bg/hover/text
   - Surface: --surface-primary, --surface-secondary
   - Text: --text-primary, --text-disabled
   - Border: --border-primary, --border-focus
   - Interactive: --interactive-hover, --interactive-disabled
   - Colors: --color-primary, --color-error, --color-white
   - Shadows: --shadow-sm
   - Spacing: --spacing-xs through --spacing-2xl
   - Radius: --radius-sm through --radius-full
   - Transitions: --transition-fast
   - Focus: --focus-ring, --focus-ring-error
   - Font sizes: --font-size-xs through --font-size-lg

   To customize buttons for a specific theme:
   1. Update the semantic tokens in themes.css
   2. All buttons will update automatically
   3. No need for body.dark-theme overrides

   USAGE EXAMPLES:

   Primary action:
   <button class="btn-primary">Save</button>

   Danger action:
   <button class="btn-danger">Delete</button>

   Outline action:
   <button class="btn-action">View Details</button>

   Button group:
   <div class="button-group">
       <button class="btn-primary">Confirm</button>
       <button class="btn-secondary">Cancel</button>
   </div>

   Size variants:
   <button class="btn-primary btn-sm">Small</button>
   <button class="btn-primary">Normal</button>
   <button class="btn-primary btn-lg">Large</button>

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