/* ============================================
   UserPlat – Frontend Styles
   ============================================ */

/* Download Button Wrapper */
.userplat-download-wrapper {
    margin: 25px 0;
    text-align: center;
}

/* Download Button Base */
.userplat-btn-download {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    text-decoration: none;
    line-height: 1;
    font-family: inherit;
}

.userplat-btn-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.userplat-btn-download:active {
    transform: translateY(0);
}

.userplat-btn-download.userplat-loading {
    opacity: 0.7;
    pointer-events: none;
}

.userplat-btn-download .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
    line-height: 1;
}

/* ============================================
   MODAL OVERLAY
   ============================================ */
.userplat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2147483647; /* Maximum z-index to stay above Quiz Maker overlays */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: auto; /* Ensure clickable */
}
.userplat-overlay.active {
    opacity: 1;
}

/* Modal Card */
.userplat-modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 760px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2);
    position: relative;
    transform: translateY(30px) scale(0.95);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.userplat-modal-header {
    flex-shrink: 0;
}
.userplat-modal-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}
.userplat-modal-footer {
    flex-shrink: 0;
}
.userplat-overlay.active .userplat-modal {
    transform: translateY(0) scale(1);
}

/* Close Button */
.userplat-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    min-width: 32px !important;
    max-width: 32px !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1 !important;
    color: #666;
    transition: all 0.2s;
    z-index: 2;
}
.userplat-close:hover {
    background: #e0e0e0;
    color: #333;
}

/* Header */
.userplat-modal-header {
    padding: 20px 28px 12px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.userplat-modal-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #e8f4fd;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.userplat-modal-icon svg {
    width: 22px;
    height: 22px;
    color: #3b82f6;
}
.userplat-modal-title {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0;
    line-height: 1.3;
}
.userplat-modal-subtitle {
    font-size: 13px;
    color: #8b8fa3;
    margin: 2px 0 0;
}

/* Steps */
.userplat-steps {
    padding: 0 28px 12px;
}
.userplat-step {
    display: flex;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid #f0f1f5;
}
.userplat-step:last-child {
    border-bottom: none;
}
.userplat-step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #eef2ff;
    color: #4f6ef7;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}
.userplat-step-content {
    flex: 1;
    min-width: 0;
}
.userplat-step-text {
    font-size: 14px;
    color: #333;
    line-height: 1.5;
    margin: 0;
}

/* Keyword Box */
.userplat-keyword-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f5f7fb;
    border: 1px solid #e8ebf2;
    border-radius: 10px;
    padding: 10px 14px;
    margin-top: 10px;
}
.userplat-keyword-icon {
    color: #8b8fa3;
    flex-shrink: 0;
}
.userplat-keyword-text {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
    color: #1a1a2e;
    word-break: break-word;
}
.userplat-copy-btn {
    border: none;
    background: none;
    cursor: pointer;
    color: #a0a3b5;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s;
    flex-shrink: 0;
}
.userplat-copy-btn:hover {
    color: #4f6ef7;
    background: #e8ecff;
}
.userplat-copy-btn svg {
    width: 18px;
    height: 18px;
    display: block;
}

/* Warning Notice */
.userplat-notice {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: #fff8eb;
    border: 1px solid #fde6a8;
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: 8px;
    font-size: 12.5px;
    color: #92650c;
    line-height: 1.4;
}
.userplat-notice svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: #e6a817;
    margin-top: 1px;
}
.userplat-notice.red {
    background: #fff5f5;
    border-color: #fed7d7;
    color: #c53030;
}
.userplat-notice.red svg {
    color: #e53e3e;
}

/* Google Screenshot Mockup */
.userplat-search-preview {
    margin-top: 8px;
    border: 1px solid #e8ebf2;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}
.userplat-search-bar {
    background: #f5f7fb;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #e8ebf2;
    font-size: 12px;
    color: #666;
}
.userplat-search-bar-dots {
    display: flex;
    gap: 4px;
}
.userplat-search-bar-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ccc;
}
.userplat-search-result {
    padding: 14px;
    border: 2px solid #e53e3e;
    border-radius: 8px;
    margin: 10px;
    background: #fff;
}
.userplat-search-result-url {
    font-size: 12px;
    color: #4d5156;
    margin: 0 0 4px;
}
.userplat-search-result-title {
    font-size: 15px;
    color: #1a0dab;
    font-weight: 600;
    margin: 0 0 4px;
    text-decoration: none;
}
.userplat-search-result-desc {
    font-size: 12px;
    color: #4d5156;
    margin: 0;
    line-height: 1.4;
}

/* Identity Code */
.userplat-identity-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f5f7fb;
    border: 1px solid #e8ebf2;
    border-radius: 10px;
    padding: 10px 14px;
    margin-top: 8px;
}
.userplat-identity-label {
    font-size: 13px;
    color: #8b8fa3;
    white-space: nowrap;
}
.userplat-identity-code {
    font-size: 22px;
    font-weight: 700;
    color: #4f6ef7;
    letter-spacing: 2px;
    font-family: 'Courier New', monospace;
}

/* Bottom Bar */
.userplat-modal-footer {
    padding: 16px 28px 24px;
    display: flex;
    gap: 10px;
    align-items: center;
    border-top: 1px solid #f0f1f5;
}
.userplat-code-input {
    flex: 1;
    border: 1.5px solid #e0e3eb;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
    color: #1a1a2e;
}
.userplat-code-input:focus {
    border-color: #4f6ef7;
    box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.1);
}
.userplat-code-input::placeholder {
    color: #b0b3c6;
}
.userplat-submit-btn {
    border: none;
    background: linear-gradient(135deg, #4f6ef7 0%, #3ecf8e 100%);
    color: #fff;
    padding: 12px 22px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: all 0.25s;
}
.userplat-submit-btn:hover {
    box-shadow: 0 4px 15px rgba(79, 110, 247, 0.35);
    transform: translateY(-1px);
}
.userplat-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.userplat-submit-btn svg {
    width: 18px;
    height: 18px;
}

/* Loading spinner */
.userplat-spinner {
    border: 2px solid rgba(255,255,255,0.3);
    border-top: 2px solid #fff;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    animation: userplat-spin 0.6s linear infinite;
    display: none;
}
.userplat-submit-btn.userplat-is-loading .userplat-spinner {
    display: inline-block;
}
.userplat-submit-btn.userplat-is-loading .userplat-submit-icon,
.userplat-submit-btn.userplat-is-loading .userplat-submit-text {
    display: none;
}

/* Error message */
.userplat-error-msg {
    color: #e53e3e;
    font-size: 13px;
    padding: 0 28px 16px;
    margin: 0;
    display: none;
}
.userplat-error-msg.show {
    display: block;
}

/* Success overlay */
.userplat-success {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    border-radius: 16px;
    z-index: 150;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.4s ease;
    padding: 30px;
    box-sizing: border-box;
}
.userplat-success.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
.userplat-success.show .userplat-success-icon {
    transform: scale(1);
    opacity: 1;
}
.userplat-success.show .userplat-success-text,
.userplat-success.show .userplat-success-subtext {
    transform: translateY(0);
    opacity: 1;
}
.userplat-success-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 10px 25px rgba(16, 185, 129, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px; /* Centering fallback */
    transform: scale(0.5);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    transition-delay: 0.1s;
}
.userplat-success-icon svg {
    width: 40px;
    height: 40px;
    color: #ffffff;
}
.userplat-success-text {
    font-size: 26px;
    font-weight: 800;
    color: #059669; /* Slightly brighter green for better contrast */
    margin: 0 auto;
    padding: 0;
    line-height: 1.2;
    text-align: center;
    display: block;
    width: 100%;
    transform: translateY(15px);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    transition-delay: 0.2s;
}
.userplat-success-subtext {
    font-size: 15px;
    color: #64748b;
    margin: 12px auto 0;
    padding: 0;
    text-align: center;
    display: block;
    width: 100%;
    transform: translateY(15px);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    transition-delay: 0.25s;
}

/* Animations */
@keyframes userplat-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 560px) {
    .userplat-modal {
        max-width: 100%;
        border-radius: 12px;
    }
    .userplat-modal-header {
        padding: 15px 18px 10px;
        gap: 0;
        display: block;
        text-align: center;
    }
    .userplat-modal-icon {
        display: none !important;
    }
    .userplat-modal-title {
        font-size: 16px;
        margin-bottom: 4px;
    }
    .userplat-modal-subtitle {
        font-size: 12px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
    }

    .userplat-steps {
        padding: 0 18px 10px;
    }
    .userplat-step {
        display: block;
        padding: 8px 0;
        gap: 0;
    }
    .userplat-step-num {
        display: inline-flex;
        width: 22px;
        height: 22px;
        font-size: 12px;
        margin-right: 8px;
        vertical-align: middle;
    }
    .userplat-step-content {
        display: inline;
    }
    .userplat-step-text {
        display: inline;
        font-size: 13px;
        vertical-align: middle;
    }

    .userplat-modal-footer {
        padding: 12px 18px 18px;
        flex-direction: row;
        gap: 8px;
    }
    .userplat-code-input {
        width: auto;
        flex: 1;
        padding: 10px 14px;
        font-size: 14px;
    }
    .userplat-submit-btn {
        width: auto;
        padding: 10px 16px;
        font-size: 14px;
        justify-content: center;
    }
    .userplat-identity-code {
        font-size: 18px;
    }
}
