/* ==========================================
   Social Publish Modal - NexaWeb
   ========================================== */

/* Overlay */
html.publish-modal-open,
body.publish-modal-open {
    width: 100%;
    max-width: 100%;
    overflow: hidden !important;
}

#publishOverlay,
#publishOverlay * {
    box-sizing: border-box;
    max-width: 100%;
}

.publish-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10000;
    animation: publishFadeIn 0.25s ease;
}

.publish-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes publishFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes publishSlideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Modal */
.publish-modal {
    background: #fff;
    border-radius: 20px;
    width: 95%;
    max-width: 680px;
    min-width: 0;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
    animation: publishSlideUp 0.3s ease;
    position: relative;
}

/* Header */
.publish-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 25px;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    background: #fff;
    border-radius: 20px 20px 0 0;
    z-index: 2;
}

.publish-modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #1a1a2e;
    display: flex;
    align-items: center;
    gap: 10px;
}

.publish-modal-header h3 i {
    color: #667eea;
    font-size: 22px;
}

.publish-close-btn {
    background: #f0f0f0;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: all 0.2s;
}

.publish-close-btn:hover {
    background: #e0e0e0;
    color: #333;
}

/* Post Preview */
.publish-preview {
    padding: 20px 25px;
    border-bottom: 1px solid #eee;
}

.publish-preview-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #999;
    margin-bottom: 12px;
}

.publish-preview-card {
    background: #f8f9fa;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid #eee;
}

/* Image carousel in preview */
.publish-images {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0;
}

.publish-images::-webkit-scrollbar {
    display: none;
}

.publish-images img {
    width: 100%;
    min-width: 100%;
    height: 280px;
    object-fit: contain;
    background: #fff;
    scroll-snap-align: start;
    flex-shrink: 0;
}

.publish-image-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 10px 0;
    background: #f8f9fa;
}

.publish-image-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ccc;
    transition: all 0.2s;
    cursor: pointer;
}

.publish-image-dots .dot.active {
    background: #667eea;
    width: 20px;
    border-radius: 4px;
}

.publish-preview-text {
    padding: 16px 18px;
}

.publish-preview-text .pub-title {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a2e;
    line-height: 1.4;
    margin-bottom: 8px;
}

.publish-preview-text .pub-price {
    font-size: 18px;
    font-weight: 800;
    color: #27ae60;
    margin-bottom: 6px;
}

.publish-preview-text .pub-link {
    font-size: 13px;
    color: #007bff;
    word-break: break-all;
}

.publish-preview-text .pub-hashtags {
    font-size: 13px;
    color: #667eea;
    margin-top: 8px;
    line-height: 1.5;
}

/* Caption editor */
.publish-caption-section {
    padding: 15px 25px;
    border-bottom: 1px solid #eee;
}

.publish-caption-section label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #999;
    display: block;
    margin-bottom: 8px;
}

.publish-caption-textarea {
    width: 100%;
    min-height: 80px;
    border: 2px solid #eee;
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 14px;
    font-family: inherit;
    color: #333;
    resize: vertical;
    transition: border-color 0.2s;
    line-height: 1.5;
    box-sizing: border-box;
}

.publish-caption-textarea:focus {
    outline: none;
    border-color: #667eea;
}

.publish-char-count {
    text-align: right;
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

/* Platform buttons */
.publish-platforms {
    padding: 20px 25px 25px;
}

.publish-platforms-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #999;
    margin-bottom: 15px;
}

.publish-platform-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.publish-platform-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border: 2px solid #eee;
    border-radius: 14px;
    background: #fff;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    transition: all 0.2s ease;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.publish-platform-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.publish-platform-btn:active {
    transform: translateY(0);
}

.publish-platform-btn i {
    font-size: 22px;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.publish-platform-btn .platform-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.publish-platform-btn .platform-name {
    font-weight: 700;
    font-size: 14px;
}

.publish-platform-btn .platform-action {
    font-size: 11px;
    color: #999;
    font-weight: 400;
}

/* Platform-specific colors */
.publish-platform-btn.facebook {
    border-color: #1877f220;
}
.publish-platform-btn.facebook:hover {
    background: #1877f20a;
    border-color: #1877f2;
}
.publish-platform-btn.facebook i { color: #1877f2; }

.publish-platform-btn.twitter {
    border-color: #1da1f220;
}
.publish-platform-btn.twitter:hover {
    background: #1da1f20a;
    border-color: #000;
}
.publish-platform-btn.twitter i { color: #000; }

.publish-platform-btn.pinterest {
    border-color: #e6001920;
}
.publish-platform-btn.pinterest:hover {
    background: #e600190a;
    border-color: #e60019;
}
.publish-platform-btn.pinterest i { color: #e60019; }

.publish-platform-btn.instagram {
    border-color: #e1306c20;
}
.publish-platform-btn.instagram:hover {
    background: #e1306c0a;
    border-color: #e1306c;
}
.publish-platform-btn.instagram i {
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.publish-platform-btn.tiktok {
    border-color: #00000020;
}
.publish-platform-btn.tiktok:hover {
    background: #00f2ea0a;
    border-color: #000;
}
.publish-platform-btn.tiktok i { color: #000; }

/* Full width last item if odd */
.publish-platform-grid .publish-platform-btn:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

/* Copied toast inside modal */
.publish-copied-toast {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #27ae60;
    color: #fff;
    padding: 12px 25px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(39, 174, 96, 0.4);
    z-index: 10;
    animation: publishToastIn 0.3s ease;
    pointer-events: none;
}

@keyframes publishToastIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ==========================================
   Step-by-step Instructions View
   ========================================== */

.publish-instructions {
    padding: 20px 25px 25px;
}

.publish-instructions-status {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 14px;
    margin-bottom: 20px;
}

.publish-status-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    font-size: 18px;
}

.publish-status-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.publish-status-text strong {
    font-size: 15px;
    color: #166534;
}

.publish-status-text span {
    font-size: 13px;
    color: #4ade80;
}

/* Steps */
.publish-steps {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 20px;
}

.publish-step {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-left: 3px solid #e5e7eb;
    position: relative;
    transition: all 0.2s;
}

.publish-step.done {
    border-left-color: #22c55e;
}

.publish-step-number {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #6b7280;
    flex-shrink: 0;
}

.publish-step.done .publish-step-number {
    background: #dcfce7;
    color: #22c55e;
}

.publish-step-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #374151;
    min-width: 0;
}

.publish-step-content span,
.publish-status-text span,
.publish-status-text strong,
.publish-platform-btn .platform-name,
.publish-platform-btn .platform-action {
    overflow-wrap: anywhere;
}

.publish-step-content i {
    width: 18px;
    text-align: center;
    color: #9ca3af;
    font-size: 14px;
}

.publish-step.done .publish-step-content i {
    color: #22c55e;
}

/* Caption preview */
.publish-caption-preview {
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
}

.publish-caption-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
}

.publish-recopy-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
}

.publish-recopy-btn:hover {
    background: #667eea;
    color: #fff;
    border-color: #667eea;
}

.publish-caption-preview-text {
    padding: 12px 14px;
    font-size: 13px;
    color: #374151;
    line-height: 1.6;
    white-space: pre-wrap;
    max-height: 120px;
    overflow-y: auto;
}

/* Action buttons */
.publish-action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.publish-open-platform-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 24px;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.publish-open-platform-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.publish-open-platform-btn:active {
    transform: translateY(0);
}

.publish-open-platform-btn i {
    font-size: 20px;
}

.publish-download-again-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
}

.publish-download-again-btn:hover {
    border-color: #667eea;
    color: #667eea;
    background: #f0f2ff;
}

/* Image thumbnails */
.publish-image-thumbs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.publish-image-thumbs img {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 10px;
    border: 2px solid #e5e7eb;
    flex-shrink: 0;
}

/* Mobile responsive */
@media (max-width: 600px) {
    .publish-overlay {
        width: 100dvw;
        max-width: 100dvw;
        overflow-x: hidden;
    }

    .publish-overlay.active {
        align-items: flex-end;
    }

    .publish-modal {
        width: 100dvw;
        max-width: 100dvw;
        max-height: 92dvh;
        border-radius: 16px 16px 0 0;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        animation: publishSlideUpMobile 0.3s ease;
        box-sizing: border-box;
    }

    @keyframes publishSlideUpMobile {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    .publish-modal-header {
        padding: 14px 16px;
        border-radius: 16px 16px 0 0;
    }

    .publish-modal-header h3 {
        font-size: 16px;
        gap: 8px;
    }

    .publish-modal-header h3 i {
        font-size: 18px;
    }

    .publish-close-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .publish-preview {
        padding: 12px 14px;
    }

    .publish-images img {
        height: 200px;
    }

    .publish-preview-text {
        padding: 12px 14px;
    }

    .publish-preview-text .pub-title {
        font-size: 14px;
        word-break: break-word;
    }

    .publish-preview-text .pub-hashtags {
        font-size: 12px;
        word-break: break-word;
    }

    .publish-caption-section {
        padding: 12px 14px;
    }

    .publish-caption-textarea {
        font-size: 13px;
        padding: 10px 12px;
        min-height: 60px;
        box-sizing: border-box;
        width: 100%;
    }

    .publish-platforms {
        padding: 14px 14px 20px;
    }

    .publish-platform-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .publish-platform-btn {
        padding: 12px 14px;
        gap: 10px;
        border-radius: 12px;
    }

    .publish-platform-btn i {
        font-size: 20px;
        width: 24px;
    }

    .publish-platform-btn .platform-name {
        font-size: 14px;
    }

    .publish-platform-btn .platform-action {
        font-size: 10px;
    }

    /* Instructions view mobile */
    .publish-instructions {
        padding: 14px 14px 20px;
    }

    .publish-instructions-status {
        padding: 12px 14px;
        gap: 10px;
        align-items: flex-start;
    }

    .publish-status-icon {
        width: 36px;
        height: 36px;
        font-size: 15px;
    }

    .publish-status-text strong {
        font-size: 14px;
    }

    .publish-status-text span {
        font-size: 12px;
    }

    .publish-step {
        padding: 10px 12px;
        gap: 10px;
        align-items: flex-start;
    }

    .publish-step-number {
        width: 26px;
        height: 26px;
        font-size: 12px;
    }

    .publish-step-content {
        font-size: 13px;
        gap: 8px;
        align-items: flex-start;
    }

    .publish-caption-preview-header {
        align-items: flex-start;
        gap: 8px;
        flex-direction: column;
    }

    .publish-copied-toast {
        width: calc(100% - 36px);
        max-width: 320px;
        text-align: center;
        white-space: normal;
    }

    .publish-open-platform-btn {
        padding: 14px 20px;
        font-size: 15px;
        border-radius: 12px;
    }

    .publish-download-again-btn {
        padding: 10px 16px;
        font-size: 13px;
    }

    .publish-image-thumbs img {
        width: 56px;
        height: 56px;
        border-radius: 8px;
    }

    .publish-caption-preview-text {
        font-size: 12px;
        max-height: 80px;
        padding: 10px 12px;
    }

    .publish-caption-preview-header {
        padding: 8px 12px;
        font-size: 11px;
    }

    .publish-recopy-btn {
        padding: 4px 10px;
        font-size: 11px;
    }
}
