/**
 * Unified Copy Style & Micro-UX Feedback System (Storefront + CMS)
 * Golden Reference: /account/orders (.account-order-copy-btn)
 */

/* 1. Inline Code + Icon Chip: [A301D0000008 📋] -> [A301D0000008 ✓] */
.app-copy-chip,
.account-order-copy-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 1px 6px;
    margin: -1px 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    color: inherit;
    font-size: inherit;
    line-height: 1.4;
    vertical-align: baseline;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.app-copy-chip:hover,
.account-order-copy-btn:hover {
    background: #f3f4f6;
    border-color: #e5e7eb;
    text-decoration: none;
}

.app-copy-chip:focus-visible,
.app-copy-icon-btn:focus-visible,
.app-copy-action-btn:focus-visible {
    outline: 2px solid rgba(255, 80, 0, 0.32);
    outline-offset: 1px;
}

.app-copy-code,
.account-order-code {
    color: #111827;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 13px;
    font-weight: 600;
}

.app-copy-chip--sm .app-copy-code {
    font-size: 12px;
}

.app-copy-chip--inherit .app-copy-code {
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
}

/* 2. Compact Icon-Only Trigger (next to links, headings, bank rows, table cells) */
.app-copy-icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    margin: -2px 0 -2px 2px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    color: #9ca3af;
    line-height: 1;
    vertical-align: middle;
    flex-shrink: 0;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.app-copy-icon-btn:hover {
    background: #f3f4f6;
    border-color: #e5e7eb;
    color: #ff5000;
    text-decoration: none;
}

/* 3. Action Copy Button with Text Label (e.g. "Sao chép địa chỉ kho TQ") */
.app-copy-action-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 4px 10px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    cursor: pointer;
    color: #374151;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.35;
    white-space: nowrap;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.app-copy-action-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #111827;
    text-decoration: none;
}

.app-copy-action-btn:hover .app-copy-icon {
    color: #ff5000;
}

/* 4. Shared Dual-SVG Icons */
.app-copy-icon,
.account-order-copy-icon {
    color: #9ca3af;
    flex-shrink: 0;
    transition: color 0.15s ease;
}

.app-copy-icon-btn .app-copy-icon {
    color: currentColor;
}

.app-copied-icon,
.account-order-copied-icon {
    display: none;
    color: #059669;
    flex-shrink: 0;
}

.app-copy-chip:hover .app-copy-icon,
.account-order-copy-btn:hover .account-order-copy-icon {
    color: #ff5000;
}

/* 5. Universal Copied State (.is-copied / [data-cf-copied="1"]) */
.app-copy-chip.is-copied,
.app-copy-icon-btn.is-copied,
.app-copy-action-btn.is-copied,
.account-order-copy-btn.is-copied,
[data-cf-copied="1"] {
    background: #ecfdf5 !important;
    border-color: #a7f3d0 !important;
}

.app-copy-icon-btn.is-copied,
.app-copy-action-btn.is-copied,
[data-cf-copied="1"]:not(.app-copy-chip):not(.account-order-copy-btn) {
    color: #047857 !important;
}

.app-copy-chip.is-copied .app-copy-code,
.account-order-copy-btn.is-copied .account-order-code,
[data-cf-copied="1"] .app-copy-code,
[data-cf-copied="1"] .account-order-code {
    color: #111827 !important;
}

.app-copy-chip.is-copied .app-copy-icon,
.app-copy-icon-btn.is-copied .app-copy-icon,
.app-copy-action-btn.is-copied .app-copy-icon,
.account-order-copy-btn.is-copied .account-order-copy-icon,
[data-cf-copied="1"] .app-copy-icon,
[data-cf-copied="1"] .account-order-copy-icon,
[data-cf-copied="1"] .icon-copy,
[data-cf-copied="1"] .ico-copy {
    display: none !important;
}

.app-copy-chip.is-copied .app-copied-icon,
.app-copy-icon-btn.is-copied .app-copied-icon,
.app-copy-action-btn.is-copied .app-copied-icon,
.account-order-copy-btn.is-copied .account-order-copied-icon,
[data-cf-copied="1"] .app-copied-icon,
[data-cf-copied="1"] .account-order-copied-icon,
[data-cf-copied="1"] .icon-check,
[data-cf-copied="1"] .ico-check {
    display: inline-block !important;
    color: #059669 !important;
}

.app-cf-injected-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #059669 !important;
    flex-shrink: 0;
    line-height: 1;
}

/* Harmonize existing specialized triggers in idle & hover states */
.order-detail-page .btn-copy-order-code,
.btn-topup-copy,
.btn-link-copy,
.cms-btn-copy:not(.cms-btn) {
    border-radius: 4px;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.order-detail-page .btn-copy-order-code:hover,
.btn-topup-copy:hover,
.btn-link-copy:hover,
.cms-btn-copy:not(.cms-btn):hover {
    background: #f3f4f6;
    border-color: #e5e7eb;
    color: #ff5000;
}

/* Suppress legacy inline tooltip nodes to prevent duplicate tooltips */
.account-order-copy-feedback,
.order-detail-page .btn-copy-order-code .copy-order-feedback {
    display: none !important;
}

/* 6. Floating Dark Portal Tooltip ("Đã chép") — Never clipped by overflow: hidden/auto */
.app-copy-floating-tip {
    position: fixed;
    top: 0;
    left: 0;
    padding: 2px 7px;
    border-radius: 4px;
    background: #111827;
    color: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.45;
    letter-spacing: 0;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateY(3px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 100050;
    box-shadow: 0 2px 6px rgba(17, 24, 39, 0.18);
}

.app-copy-floating-tip.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Screen-reader polite announcement region */
.app-copy-sr-live {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* iOS HIG Touch Target Expansion: keeps 24x24px visual icon & compact chips intact while expanding hit area */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
    .app-copy-icon-btn::after {
        content: "";
        position: absolute;
        top: 50%;
        left: 50%;
        width: 44px;
        height: 44px;
        transform: translate(-50%, -50%);
    }

    .app-copy-chip::after,
    .account-order-copy-btn::after,
    .app-copy-action-btn::after {
        content: "";
        position: absolute;
        top: 50%;
        left: -4px;
        right: -4px;
        height: max(100%, 44px);
        transform: translateY(-50%);
    }
}

