/**
 * LEX Copy to Clipboard Component
 * Reusable copy button component with visual feedback
 * 
 * Usage - Basic:
 * <button data-lex-copy="text-to-copy" class="lex-copy-button">
 *     <span class="dashicons dashicons-admin-page"></span>
 *     Copy
 * </button>
 * 
 * Usage - With Variants:
 * <button data-lex-copy="text" class="lex-copy-button lex-copy-button--secondary lex-copy-button--small">
 *     Copy
 * </button>
 * 
 * NOTE: data-lex-copy attribute activates the copy functionality
 *       CSS classes are only for styling
 */

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
    --lex-copy-bg: var(--lex-color-primary);
    --lex-copy-bg-hover: var(--lex-color-primary-hover);
    --lex-copy-color: var(--lex-color-primary-contrast);
    --lex-copy-success-bg: var(--lex-color-success);
    --lex-copy-shadow: 0 2px 8px color-mix(in srgb, var(--lex-color-primary) 25%, transparent);
    --lex-copy-shadow-active: 0 1px 4px color-mix(in srgb, var(--lex-color-primary) 30%, transparent);
}

/* ============================================
   BASE COPY BUTTON
   ============================================ */
.lex-copy-button,
button.lex-copy-button {
    /* Reset WordPress core button styles */
    border: 1px solid transparent;
    border-radius: var(--lex-radius-md);
    box-shadow: none;
    background: var(--lex-copy-bg);
    color: var(--lex-copy-color);
    font-family: inherit;
    font-size: var(--lex-font-size-md);
    font-weight: var(--lex-font-weight-medium);
    line-height: 1;
    margin: 0;
    padding-block: var(--lex-space-2);
    padding-inline: var(--lex-space-3);
    text-decoration: none;
    text-shadow: none;
    vertical-align: baseline;
    justify-content: center;
    align-items: center;
    
    /* Custom styles */
    display: inline-flex;
    align-items: center;
    gap: var(--lex-space-1);
    cursor: pointer;
    transition: all var(--lex-transition-base);
    box-sizing: border-box;
    white-space: nowrap;
    -webkit-appearance: none;
    appearance: none;
}

.lex-copy-button:hover,
.lex-copy-button:focus,
button.lex-copy-button:hover,
button.lex-copy-button:focus {
    background: var(--lex-copy-bg-hover);
    border: 1px solid transparent;
    color: var(--lex-copy-color);
    text-decoration: none;
    text-shadow: none;
    box-shadow: var(--lex-copy-shadow);
    outline: none;
}

.lex-copy-button:active,
button.lex-copy-button:active {
    transform: translateY(1px);
    box-shadow: var(--lex-copy-shadow-active);
}

.lex-copy-button:disabled,
button.lex-copy-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    background: var(--lex-copy-bg);
}

/* Icon styling */
.lex-copy-button .dashicons {
    font-size: var(--lex-font-size-lg);
    width: var(--lex-space-4);
    height: var(--lex-space-4);
    line-height: 1;
    margin: 0;
    flex-shrink: 0;
}


/* ============================================
   VARIANT: OUTLINE
   ============================================ */
.lex-copy-button--outline,
button.lex-copy-button--outline {
    background: none;
    background-color: transparent;
    border: 1px solid var(--lex-copy-bg);
    color: var(--lex-copy-bg);
}

.lex-copy-button--outline:hover,
.lex-copy-button--outline:focus,
button.lex-copy-button--outline:hover,
button.lex-copy-button--outline:focus {
    border: 1px solid var(--lex-copy-bg);
    background: var(--lex-copy-bg);
    color: var(--lex-copy-color);
}

.lex-copy-button--outline:active,
button.lex-copy-button--outline:active {
    background: var(--lex-copy-bg-hover);
    border-color: var(--lex-copy-bg-hover);
    transform: translateY(1px);
    box-shadow: var(--lex-copy-shadow-active);
}

.lex-copy-button--outline:disabled,
button.lex-copy-button--outline:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    background: transparent;
    border-color: var(--lex-copy-bg);
}

/* ============================================
   SUCCESS STATE (Copied!)
   ============================================ */
.lex-copy-button--copied,
button.lex-copy-button--copied {
    background: var(--lex-copy-success-bg);
    border-color: transparent;
    color: var(--lex-color-primary-contrast);
    box-shadow: none;
}

.lex-copy-button--copied:hover,
button.lex-copy-button--copied:hover {
    background: var(--lex-copy-success-bg);
    border-color: transparent;
}

/* ============================================
   VARIANT: SECONDARY
   ============================================ */
.lex-copy-button--secondary,
button.lex-copy-button--secondary {
    background: var(--lex-color-surface);
    border: 1px solid var(--lex-color-border);
    color: var(--lex-color-text-muted);
}

.lex-copy-button--secondary:hover,
.lex-copy-button--secondary:focus,
button.lex-copy-button--secondary:hover,
button.lex-copy-button--secondary:focus {
    background: var(--wp-color-gray-0);
    border-color: var(--lex-color-border-hover);
    color: var(--lex-color-text);
    box-shadow: var(--lex-shadow-md);
}

/* ============================================
   VARIANT: SMALL
   ============================================ */
.lex-copy-button--small,
button.lex-copy-button--small {
    padding-block: var(--lex-space-1);
    padding-inline: var(--lex-space-2);
    font-size: var(--lex-font-size-xs);
}

.lex-copy-button--small .dashicons,
button.lex-copy-button--small .dashicons {
    font-size: var(--lex-font-size-base);
    width: var(--lex-font-size-base);
    height: var(--lex-font-size-base);
}

/* ============================================
   VARIANT: BLOCK (Full Width)
   ============================================ */
.lex-copy-button--block,
button.lex-copy-button--block {
    width: 100%;
    justify-content: center;
}

/* ============================================
   FOCUS STATES
   ============================================ */
.lex-copy-button:focus,
button.lex-copy-button:focus {
    outline: 2px solid var(--lex-color-primary-light);
    outline-offset: 2px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media screen and (max-width: 782px) {
    .lex-copy-button,
    button.lex-copy-button {
        font-size: var(--lex-font-size-xs);
        padding-block: var(--lex-space-1);
        padding-inline: var(--lex-space-3);
    }
    
    .lex-copy-button .dashicons,
    button.lex-copy-button .dashicons {
        font-size: var(--lex-font-size-base);
        width: var(--lex-font-size-base);
        height: var(--lex-font-size-base);
    }
}
