/**
 * PS Button Block Styles
 * 
 * Comprehensive styling for the PS Button block including
 * base styles, predefined styles, sizes, states, and animations.
 * 
 * @package PS5_Theme\Blocks
 * @since 1.0.0
 */

/* ==========================================================================
   Base Button Styles
   ========================================================================== */

.ps-button-wrapper {
    display: block;
    margin: 0;
    padding: 0;
}

.ps-button {
    /* Reset browser defaults */
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font: inherit;
    line-height: normal;
    overflow: visible;
    padding: 0;
    margin: 0;
    text-decoration: none;
    
    /* Base button styling */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    font-family: inherit;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    user-select: none;
    transition: all 0.15s ease-in-out;
    position: relative;
    min-height: 40px;
    
    /* Remove focus outline, we'll add custom focus styles */
    outline: none;
    
    /* Prevent double-click selection */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Remove default button styling in specific browsers */
.ps-button::-moz-focus-inner {
    border: 0;
    padding: 0;
}

.ps-button:focus {
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

/* Button text */
.ps-button-text {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
    flex: 1 0 auto;
}

/* Icon styling */
.ps-button-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1em;
    height: 1em;
    line-height: 1;
    vertical-align: middle;
}

/* SVG icon styling for color inheritance */
.ps-button-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor !important;
    color: currentColor;
    stroke: currentColor;
    vertical-align: top;
}

.ps-button-icon--left {
    order: -1;
}

.ps-button-icon--right {
    order: 1;
}

/* Full width button */
.ps-button--full-width {
    width: 100%;
    display: flex;
    justify-content: center;
}

/* Disabled state */
.ps-button:disabled,
.ps-button[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* ==========================================================================
   Button Sizes
   ========================================================================== */

.ps-button--small {
    padding: 8px 16px;
    font-size: 14px;
    min-height: 32px;
}

.ps-button--small .ps-button-icon {
    width: 14px;
    height: 14px;
}

.ps-button--medium {
    padding: 12px 24px;
    font-size: 16px;
    min-height: 40px;
}

.ps-button--medium .ps-button-icon {
    width: 16px;
    height: 16px;
}

.ps-button--large {
    padding: 16px 32px;
    font-size: 18px;
    min-height: 48px;
}

.ps-button--large .ps-button-icon {
    width: 18px;
    height: 18px;
}

/* ==========================================================================
   Button Style Presets
   ========================================================================== */

/* Primary Button */
.ps-button--primary {
    background-color: #3b82f6;
    color: #ffffff;
    border: 1px solid #3b82f6;
    border-radius: 8px;
}

.ps-button--primary:hover {
    background-color: #2563eb;
    border-color: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.ps-button--primary:active {
    background-color: #1d4ed8;
    border-color: #1d4ed8;
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

/* Secondary Button */
.ps-button--secondary {
    background-color: #6b7280;
    color: #ffffff;
    border: 1px solid #6b7280;
    border-radius: 8px;
}

.ps-button--secondary:hover {
    background-color: #4b5563;
    border-color: #4b5563;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(107, 114, 128, 0.3);
}

.ps-button--secondary:active {
    background-color: #374151;
    border-color: #374151;
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(107, 114, 128, 0.3);
}

/* Outline Button */
.ps-button--outline {
    background-color: transparent;
    color: #3b82f6;
    border: 2px solid #3b82f6;
    border-radius: 8px;
}

.ps-button--outline:hover {
    background-color: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.2);
}

.ps-button--outline:active {
    background-color: #1d4ed8;
    color: #ffffff;
    border-color: #1d4ed8;
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

/* Ghost Button */
.ps-button--ghost {
    background-color: transparent;
    color: #6b7280;
    border: 1px solid transparent;
    border-radius: 8px;
}

.ps-button--ghost:hover {
    background-color: rgba(107, 114, 128, 0.1);
    color: #374151;
    transform: translateY(-1px);
}

.ps-button--ghost:active {
    background-color: rgba(107, 114, 128, 0.15);
    color: #374151;
    transform: translateY(0);
}

/* Link Button */
.ps-button--link {
    background-color: transparent;
    color: #3b82f6;
    border: 1px solid transparent;
    border-radius: 0;
    padding-left: 0;
    padding-right: 0;
    min-height: auto;
}

.ps-button--link:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

.ps-button--link:active {
    color: #1e40af;
}

/* Custom Button (no preset styles) */
.ps-button--custom {
    /* No preset styles - will be controlled by block attributes */
    border-radius: 8px;
}

/* ==========================================================================
   Animation and Transition Effects
   ========================================================================== */

/* Smooth transitions for all interactive elements */
.ps-button {
    transition: 
        background-color 0.15s ease-in-out,
        border-color 0.15s ease-in-out,
        color 0.15s ease-in-out,
        transform 0.15s ease-in-out,
        box-shadow 0.15s ease-in-out;
}

/* Icon transitions */
.ps-button-icon {
    transition: transform 0.15s ease-in-out;
}

/* Subtle icon animation on hover */
.ps-button:hover .ps-button-icon--right {
    transform: translateX(2px);
}

.ps-button:hover .ps-button-icon--left {
    transform: translateX(-2px);
}

/* ==========================================================================
   Loading and Loading States
   ========================================================================== */

.ps-button--loading {
    position: relative;
    pointer-events: none;
}

.ps-button--loading .ps-button-text,
.ps-button--loading .ps-button-icon {
    opacity: 0.7;
}

.ps-button--loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: ps-button-spin 0.8s linear infinite;
}

@keyframes ps-button-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

/* Mobile optimizations */
@media (max-width: 640px) {
    .ps-button--large {
        padding: 14px 28px;
        font-size: 16px;
    }
    
    .ps-button--medium {
        padding: 10px 20px;
        font-size: 15px;
    }
    
    .ps-button--small {
        padding: 8px 14px;
        font-size: 13px;
    }
    
    /* Ensure buttons are easily tappable on mobile */
    .ps-button {
        min-height: 44px;
    }
    
    .ps-button--small {
        min-height: 36px;
    }
    
    .ps-button--large {
        min-height: 50px;
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* High contrast mode support */
@media (prefers-contrast: high) {
    .ps-button {
        border-width: 2px;
    }
    
    .ps-button--ghost,
    .ps-button--link {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .ps-button {
        transition: none;
    }
    
    .ps-button:hover {
        transform: none;
    }
    
    .ps-button:active {
        transform: none;
    }
    
    .ps-button-icon {
        transition: none;
    }
    
    .ps-button:hover .ps-button-icon--right,
    .ps-button:hover .ps-button-icon--left {
        transform: none;
    }
}

/* Focus visible for keyboard navigation */
.ps-button:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    box-shadow: none;
}

/* ==========================================================================
   Block Editor Specific Styles
   ========================================================================== */

/* Editor-only styles */
.block-editor .ps-button {
    /* Prevent editor interactions from interfering */
    pointer-events: none;
}

.block-editor .ps-button-wrapper {
    /* Allow wrapper to be clickable in editor */
    position: relative;
}

/* Show block outline in editor when selected */
.block-editor .wp-block.is-selected .ps-button-wrapper {
    outline: 1px dashed #007cba;
    outline-offset: 2px;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .ps-button {
        /* Reset button styles for print */
        background: transparent !important;
        color: #000 !important;
        border: 1px solid #000 !important;
        box-shadow: none !important;
        transform: none !important;
    }
    
    .ps-button::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
}
.block-editor-block-list__block[data-type="ps5-theme/ps-button"] {
    max-width: 100% !important;
}