/**
 * Copy to Clipboard Elementor Widget CSS - Updated Version
 */

/* Base button styling for proper centering */
.dce-clipboard-wrapper .elementor-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
}

.dce-clipboard-wrapper .elementor-button .elementor-button-content-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

/* Icon only button styling */
.dce-clipboard-wrapper .ctce-button-icon_only .elementor-button-content-wrapper {
    padding: 0;
}

.dce-clipboard-wrapper .ctce-button-icon_only .elementor-button-icon {
    margin: 0 !important;
}

/* Icon + Text button styling */
.dce-clipboard-wrapper .ctce-button-icon_text .elementor-button-content-wrapper {
    gap: 0;
}

/* Loading state */
.dce-clipboard-wrapper .elementor-button.ctce-loading {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

.dce-clipboard-wrapper .elementor-button.ctce-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    margin: auto;
    border: 2px solid currentColor;
    border-radius: 50%;
    border-right-color: transparent;
    animation: ctce-spinner 0.75s linear infinite;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Error state */
.dce-clipboard-wrapper .elementor-button.ctce-error-state {
    background-color: #dc3545 !important;
    border-color: #dc3545 !important;
    color: #fff !important;
}

/* Animation keyframes */
@keyframes ctce-spinner {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

@keyframes ctce-shake-animation {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-10px); }
    20%, 40%, 60%, 80% { transform: translateX(10px); }
}

@keyframes ctce-bounce-animation {
    0%, 20%, 53%, 80%, 100% { transform: translateY(0); }
    40%, 43% { transform: translateY(-30px); }
    70% { transform: translateY(-15px); }
    90% { transform: translateY(-4px); }
}

@keyframes ctce-pulse-animation {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes ctce-flash-animation {
    0%, 50%, 100% { opacity: 1; }
    25%, 75% { opacity: 0; }
}

@keyframes ctce-swing-animation {
    20% { transform: rotate(15deg); }
    40% { transform: rotate(-10deg); }
    60% { transform: rotate(5deg); }
    80% { transform: rotate(-5deg); }
    100% { transform: rotate(0deg); }
}

/* Animation classes */
.dce-clipboard-wrapper .elementor-button.ctce-animated.ctce-shake {
    animation: ctce-shake-animation 0.8s ease-in-out;
}

.dce-clipboard-wrapper .elementor-button.ctce-animated.ctce-bounce {
    animation: ctce-bounce-animation 1s ease;
}

.dce-clipboard-wrapper .elementor-button.ctce-animated.ctce-pulse {
    animation: ctce-pulse-animation 0.6s ease-in-out;
}

.dce-clipboard-wrapper .elementor-button.ctce-animated.ctce-flash {
    animation: ctce-flash-animation 0.8s ease-in-out;
}

.dce-clipboard-wrapper .elementor-button.ctce-animated.ctce-swing {
    animation: ctce-swing-animation 1s ease-in-out;
    transform-origin: center center;
}

/* Input group styling for text type */
.dce-clipboard-wrapper.dce-clipboard-wrapper-text.elementor-field-group {
    display: flex;
    align-items: stretch;
    width: 100%;
}

.dce-clipboard-wrapper .dce-input-group {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    width: 100%;
}

.dce-clipboard-wrapper .dce-input-group-prepend,
.dce-clipboard-wrapper .dce-input-group-append {
    display: flex;
}

.dce-clipboard-wrapper .dce-input-group-prepend .elementor-button,
.dce-clipboard-wrapper .dce-input-group-append .elementor-button {
    border-radius: 0;
    border-right: 0;
}

.dce-clipboard-wrapper .dce-input-group-append .elementor-button {
    border-left: 0;
    border-right: 1px solid;
}

.dce-clipboard-wrapper .dce-form-control {
    position: relative;
    flex: 1 1 auto;
    width: 1%;
    margin-bottom: 0;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 0;
    background-color: #fff;
    background-clip: padding-box;
}

/* Textarea specific styling */
.dce-clipboard-wrapper-textarea {
    position: relative;
}

.dce-clipboard-wrapper-textarea .dce-clipboard-value {
    width: 100%;
    min-height: 150px;
    resize: vertical;
    font-family: monospace;
    white-space: pre-wrap;
    overflow: auto;
}

.dce-clipboard-wrapper-textarea .elementor-button {
    margin-top: 10px;
}

.dce-clipboard-wrapper-textarea .elementor-button[style*="position: absolute"] {
    margin-top: 0;
    z-index: 10;
}

/* Code block styling */
.dce-clipboard-wrapper .dce-clipboard-code {
    position: relative;
    background: #f8f8f8;
    border: 1px solid #e1e1e8;
    border-radius: 4px;
    margin: 0;
    padding: 0;
    overflow: auto;
}

.dce-clipboard-wrapper .dce-clipboard-code code {
    display: block;
    padding: 1rem;
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.5;
    color: #212529;
    background: transparent;
    border: none;
    border-radius: 0;
}

/* Line numbers for code */
.dce-clipboard-wrapper .line-numbers {
    position: relative;
    padding-left: 3.8em !important;
    counter-reset: linenumber;
}

.dce-clipboard-wrapper .line-numbers > code {
    position: relative;
    white-space: inherit;
}

.dce-clipboard-wrapper .line-numbers .line-numbers-rows {
    position: absolute;
    pointer-events: none;
    top: 0;
    font-size: 100%;
    left: -3.8em;
    width: 3em;
    letter-spacing: -1px;
    border-right: 1px solid #999;
    user-select: none;
}

/* Responsive design */
@media (max-width: 768px) {
    .dce-clipboard-wrapper .dce-input-group {
        flex-direction: column;
    }
    
    .dce-clipboard-wrapper .dce-input-group-prepend,
    .dce-clipboard-wrapper .dce-input-group-append {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .dce-clipboard-wrapper .dce-input-group-append {
        margin-bottom: 0;
        margin-top: 0.5rem;
    }
    
    .dce-clipboard-wrapper .dce-input-group-prepend .elementor-button,
    .dce-clipboard-wrapper .dce-input-group-append .elementor-button {
        width: 100%;
        border: 1px solid;
        border-radius: 4px;
    }
    
    .dce-clipboard-wrapper .dce-form-control {
        border-radius: 4px;
    }
}

/* Success state styling */
.dce-clipboard-wrapper .elementor-button.ctce-success {
    background-color: #28a745 !important;
    border-color: #28a745 !important;
    color: #fff !important;
}

/* Flexbox utilities */
.dce-flexbox {
    display: flex !important;
}

.dce-block {
    display: block !important;
    width: 100% !important;
}

/* Button size adjustments for icon-only buttons */
.dce-clipboard-wrapper .ctce-button-icon_only.elementor-size-xs {
    min-width: 32px;
    height: 32px;
    padding: 8px !important;
}

.dce-clipboard-wrapper .ctce-button-icon_only.elementor-size-sm {
    min-width: 36px;
    height: 36px;
    padding: 10px !important;
}

.dce-clipboard-wrapper .ctce-button-icon_only.elementor-size-md {
    min-width: 44px;
    height: 44px;
    padding: 12px !important;
}

.dce-clipboard-wrapper .ctce-button-icon_only.elementor-size-lg {
    min-width: 52px;
    height: 52px;
    padding: 16px !important;
}

.dce-clipboard-wrapper .ctce-button-icon_only.elementor-size-xl {
    min-width: 60px;
    height: 60px;
    padding: 20px !important;
}

/* Hover effects */
.dce-clipboard-wrapper .elementor-button:hover {
    transform: translateY(-2px);
    transition: all 0.3s ease;
}

.dce-clipboard-wrapper .elementor-button:active {
    transform: translateY(0);
}

/* Focus states for accessibility */
.dce-clipboard-wrapper .elementor-button:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.dce-clipboard-wrapper .dce-clipboard-value:focus {
    outline: 2px solid #007cba;
    outline-offset: -2px;
    border-color: #007cba;
}