/* ============================================
   Share Keyword Modal Styles
   ============================================ */

/* Modal Container */
.shareKeywordModal {
    position: fixed;
    inset: 0;
    z-index: 9999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease;
    font-family: var(
        --font-family,
        'Inter',
        -apple-system,
        BlinkMacSystemFont,
        'Segoe UI',
        Roboto,
        sans-serif
    );
}

.shareKeywordModal.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.shareKeywordModal.is-closing {
    opacity: 0;
    pointer-events: none;
    visibility: visible;
}

/* Overlay */
.shareKeywordModal__overlay {
    position: absolute;
    inset: 0;
    background-color: #0000008c;
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.shareKeywordModal.active .shareKeywordModal__overlay {
    opacity: 1;
}

.shareKeywordModal.is-closing .shareKeywordModal__overlay {
    opacity: 0;
}

/* Modal Content */
.shareKeywordModal__content {
    position: relative;
    background: #fff;
    border-radius: 18px;
    padding: 16px 28px 24px 28px;
    max-width: 640px;
    width: 94%;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.15),
        0 8px 24px rgba(0, 0, 0, 0.1);
    /* Improve animation performance and force proper rendering on mobile devices */
    will-change: transform, opacity;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.shareKeywordModal.active:not(.is-closing) .shareKeywordModal__content {
    animation: shareModalScaleIn 0.24s ease-out;
}

.shareKeywordModal.is-closing .shareKeywordModal__content {
    animation: shareModalScaleOut 0.18s ease-in forwards;
}

@keyframes shareModalScaleIn {
    from {
        opacity: 0;
        transform: scale(0.94);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes shareModalScaleOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.94);
    }
}

/* Close Button */
.shareKeywordModal__close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    padding: 0;
}

.shareKeywordModal__close:hover {
    background-color: #f3f4f6;
}

.shareKeywordModal__close svg path {
    transition: stroke 0.15s ease;
}

.shareKeywordModal__close:hover svg path {
    stroke: #374151;
}

/* Icon Container */
.shareKeywordModal__icon {
    width: 64px;
    height: 64px;
    margin: 4px auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #ebf5ff 0%, #dbeafe 100%);
    border-radius: 50%;
    border: 1px solid #bfdbfe;
}

/* Title */
.shareKeywordModal__title {
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    color: #1f2937;
    margin: 12px 0 28px;
    line-height: 1.25;
    letter-spacing: -0.01em;
    user-select: none;
}

/* White label toggle */
.shareKeywordModal__toggle {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.shareKeywordModal__toggle--loading .shareKeywordModal__toggleLabel {
    display: none;
    visibility: hidden;
    pointer-events: none;
}

.shareKeywordModal__toggleSkeleton {
    display: none;
    align-items: center;
    gap: 10px;
}

.shareKeywordModal__toggle--loading .shareKeywordModal__toggleSkeleton {
    display: inline-flex;
}

.shareKeywordModal__toggleSkeletonPart {
    position: relative;
    display: inline-block;
    background: #e5e7eb;
    overflow: hidden;
}

.shareKeywordModal__toggleSkeletonSwitch {
    width: 38px;
    height: 20px;
    border-radius: 999px;
}

.shareKeywordModal__toggleSkeletonText {
    width: 118px;
    height: 12px;
    border-radius: 8px;
}

.shareKeywordModal__toggleSkeletonPart::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.6) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: translateX(-100%);
    animation: shareKeywordModalToggleSkeleton 1.2s ease-in-out infinite;
}

@keyframes shareKeywordModalToggleSkeleton {
    0% {
        transform: translateX(-100%);
    }
    50% {
        transform: translateX(40%);
    }
    100% {
        transform: translateX(100%);
    }
}

.shareKeywordModal__toggleLabel {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    user-select: none;
    margin-bottom: 0;
}

.shareKeywordModal__toggleInput {
    appearance: none;
    width: 38px;
    height: 20px;
    background: #e5e7eb;
    border-radius: 999px;
    position: relative;
    transition: background-color 0.2s ease;
    outline: none;
}

.shareKeywordModal__toggleInput::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease;
}

.shareKeywordModal__toggleInput:checked {
    background: #3b82f6;
}

.shareKeywordModal__toggleInput:checked::after {
    transform: translateX(18px);
}

.shareKeywordModal__toggleInput:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Section */
.shareKeywordModal__section {
    margin-bottom: 22px;
    /* Force proper rendering on mobile devices for dynamically shown sections */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.shareKeywordModal__section:last-of-type {
    margin-bottom: 0;
}

/* Hide sections by default - show based on modal mode */
.shareKeywordModal[data-mode='campaign']
    .shareKeywordModal__section[data-section='image'],
.shareKeywordModal[data-mode='campaign']
    .shareKeywordModal__section[data-section='gif'] {
    display: none;
}

/* Label */
.shareKeywordModal__label {
    display: block;
    font-size: 14px;
    font-weight: 400;
    color: #1e1f20;
    margin-bottom: 10px;
    user-select: none;
}

/* Input Wrapper */
.shareKeywordModal__inputWrapper {
    position: relative;
    display: flex;
    align-items: center;
    height: 40px;
    background: #f8f9fa;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    overflow: hidden;
    gap: 10px;
    padding: 0 10px 0 12px;
    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
    /* Ensure child buttons are visible on mobile devices */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    /* Create new stacking context to fix rendering on mobile devices */
    isolation: isolate;
}

.shareKeywordModal__inputWrapper--loading .shareKeywordModal__input {
    color: transparent;
}

.shareKeywordModal__loadingText {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 400;
    color: #9ca3af;
    pointer-events: none;
    z-index: 2;
}

.shareKeywordModal__loadingDots {
    display: inline-flex;
    gap: 4px;
}

.shareKeywordModal__loadingDot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    opacity: 0.25;
    animation: shareKeywordModalDot 1s ease-in-out infinite;
}

.shareKeywordModal__loadingDot:nth-child(2) {
    animation-delay: 0.15s;
}

.shareKeywordModal__loadingDot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes shareKeywordModalDot {
    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: 0.25;
    }
    40% {
        transform: translateY(-3px);
        opacity: 1;
    }
}

.shareKeywordModal__inputWrapper:focus-within {
    background: #fff;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.shareKeywordModal__inputWrapper--loading {
    position: relative;
    overflow: hidden;
    border-color: #e5e7eb;
    box-shadow: none;
}

.shareKeywordModal__inputWrapper--loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        rgba(229, 231, 235, 0.4) 0%,
        rgba(209, 213, 219, 0.6) 50%,
        rgba(229, 231, 235, 0.4) 100%
    );
    animation: shareKeywordModalShimmer 1.2s infinite ease-in-out;
}

@keyframes shareKeywordModalShimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Input */
.shareKeywordModal__input {
    flex: 1;
    padding: 0;
    font-size: 14px;
    color: #7c8392;
    background: transparent;
    border: none;
    outline: none;
    min-width: 0;
    font-family: inherit;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    height: 100%;
    display: flex;
    align-items: center;
}

.shareKeywordModal__inputWrapper:focus-within .shareKeywordModal__input {
    color: #1e1f20;
    background: transparent;
}

.shareKeywordModal__input::placeholder {
    color: #9ca3af;
}

.shareKeywordModal__input:disabled {
    color: #9ca3af;
    cursor: default;
}

/* Action Buttons Container */
.shareKeywordModal__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 4px 0 0;
    background: transparent;
    border: none;
    /* prevent action buttons from collapsing when URLs overflow on small screens */
    flex: 0 0 auto;
    /* Force proper rendering on mobile devices */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.shareKeywordModal__actions--disabled {
    opacity: 0.55;
    pointer-events: none;
    /* Force repaint on mobile devices when class changes */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Action Buttons */
.shareKeywordModal__btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #f8f9fa;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition:
        background-color 0.15s ease,
        color 0.15s ease,
        transform 0.1s ease;
    padding: 0;
    outline: none;
    box-shadow: none;
    color: #1e1f20;
    /* Force hardware acceleration and proper repaint on mobile devices */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.shareKeywordModal__btn:hover {
    background-color: #f3f6ff;
    border-color: #dbeafe;
}

.shareKeywordModal__btn:focus,
.shareKeywordModal__btn:focus-visible {
    outline: none;
    box-shadow: none;
    background-color: #f8f9fa;
}

.shareKeywordModal__btn:disabled {
    cursor: default;
    opacity: 0.6;
    transform: none;
}

.shareKeywordModal__btn:active {
    transform: scale(0.95);
}

.shareKeywordModal__btn svg {
    display: block;
    width: 20px;
    height: 20px;
    color: inherit;
    /* Force proper SVG rendering on mobile devices */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.shareKeywordModal__btn svg path,
.shareKeywordModal__btn svg rect {
    stroke: currentColor;
    fill: none;
    transition:
        stroke 0.15s ease,
        fill 0.15s ease;
    /* Ensure proper stroke rendering on mobile devices */
    vector-effect: non-scaling-stroke;
}

.shareKeywordModal__btn:not(.copied):hover {
    color: #3b82f6;
}

/* Copy success state */
.shareKeywordModal__btn--copy.copied {
    background-color: #f8f9fa;
    color: #20b00a;
}

/* ============================================
   Share Button Dropdown Styles
   ============================================ */

.shareButtonDropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: #fff;
    border-radius: 12px;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.12),
        0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
    padding: 6px;
    min-width: 200px;
    z-index: 9999999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition:
        opacity 0.15s ease,
        transform 0.15s ease,
        visibility 0.15s ease;
}

.shareButtonDropdown.active {
    display: block;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.shareButtonDropdown__item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    text-align: left;
    transition:
        background-color 0.15s ease,
        color 0.15s ease;
    font-family: var(
        --font-family,
        'Inter',
        -apple-system,
        BlinkMacSystemFont,
        'Segoe UI',
        Roboto,
        sans-serif
    );
}

.shareButtonDropdown__item:hover {
    background-color: #f3f4f6;
    color: #1f2937;
}

.shareButtonDropdown__item:active {
    background-color: #e5e7eb;
}

.shareButtonDropdown__item + .shareButtonDropdown__item {
    margin-top: 2px;
}

/* Position dropdown relative to share button */
#shareButton {
    position: relative;
}

/* ============================================
   Delete Button Styles
   ============================================ */

.shareKeywordModal__deleteBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 20px;
    padding: 12px 16px;
    background: transparent;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #dc2626;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease;
    font-family: inherit;
}

.shareKeywordModal__deleteBtn:hover {
    background-color: #fef2f2;
    border-color: #f87171;
}

.shareKeywordModal__deleteBtn:active {
    background-color: #fee2e2;
}

.shareKeywordModal__deleteBtn svg {
    width: 16px;
    height: 16px;
}

.shareKeywordModal__content {
    transition:
        opacity 0.18s ease,
        transform 0.18s ease;
}

.shareKeywordModal.shareKeywordModal--content-hidden
    .shareKeywordModal__content {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: scale(0.99);
}

.shareKeywordModal__deleteBtn:disabled,
.shareKeywordModal__deleteBtn.is-disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background: #f9fafb;
    border-color: #e5e7eb;
    color: #9ca3af;
    box-shadow: none;
}

/* Temporarily hide modal when confirmation is shown */
.shareKeywordModal.shareKeywordModal--hidden {
    display: none !important;
}

/* ============================================
   Delete Confirmation Modal
   ============================================ */
.shareKeywordDeleteConfirm {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000001; /* above main share modal */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
        opacity 0.18s ease,
        visibility 0.18s ease;
}

.shareKeywordDeleteConfirm.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.shareKeywordDeleteConfirm__overlay {
    display: none; /* use main modal overlay; keep this unchanged */
}

.shareKeywordDeleteConfirm__content {
    position: relative;
    z-index: 1;
    width: min(440px, calc(100% - 48px));
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.15),
        0 4px 20px rgba(0, 0, 0, 0.12);
    color: #111827;
    font-family: var(
        --font-family,
        'Inter',
        -apple-system,
        BlinkMacSystemFont,
        'Segoe UI',
        Roboto,
        sans-serif
    );
    opacity: 0;
    transform: translateY(8px) scale(0.995);
    transition:
        opacity 0.2s ease,
        transform 0.2s ease;
}

.shareKeywordDeleteConfirm.active .shareKeywordDeleteConfirm__content {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.shareKeywordDeleteConfirm__title {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 700;
    color: #111827;
}

.shareKeywordDeleteConfirm__text {
    margin: 0 0 20px 0;
    font-size: 14px;
    line-height: 1.5;
    color: #4b5563;
}

.shareKeywordDeleteConfirm__actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.shareKeywordDeleteConfirm__btn {
    min-width: 110px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease,
        box-shadow 0.15s ease;
    font-family: inherit;
}

.shareKeywordDeleteConfirm__btn--secondary {
    background: #f3f4f6;
    color: #1f2937;
    border-color: #e5e7eb;
}

.shareKeywordDeleteConfirm__btn--secondary:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}

.shareKeywordDeleteConfirm__btn--danger {
    background: #dc2626;
    color: #ffffff;
    border-color: #dc2626;
    box-shadow: 0 10px 20px rgba(220, 38, 38, 0.2);
}

.shareKeywordDeleteConfirm__btn--danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

.shareKeywordDeleteConfirm__btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    box-shadow: none;
}

@media screen and (max-width: 575px) {
    .shareKeywordDeleteConfirm__content {
        width: calc(100% - 32px);
        padding: 20px;
    }
}

/* ============================================
   Responsive Styles
   ============================================ */

@media screen and (max-width: 575px) {
    .shareKeywordModal__content {
        padding: 12px 24px 20px 24px;
        margin: 16px;
        width: calc(100% - 32px);
        max-width: none;
    }

    .shareKeywordModal__title {
        font-size: 20px;
    }

    .shareKeywordModal__icon {
        width: 56px;
        height: 56px;
    }

    .shareKeywordModal__icon svg {
        width: 28px;
        height: 28px;
    }

    .shareKeywordModal__input {
        padding: 10px 0;
        font-size: 13px;
    }

    .shareKeywordModal__btn {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        /* Ensure buttons are visible on mobile devices */
        -webkit-tap-highlight-color: transparent;
    }

    .shareKeywordModal__btn svg {
        width: 18px;
        height: 18px;
    }

    .shareButtonDropdown {
        min-width: 180px;
    }
}
