/**
 * ================================================================================
 * CO-READIT - Crosspost Styles
 * ================================================================================
 * 
 * Styles for the crosspost feature including modal, thread badges, and UI elements.
 * 
 * @author      Edu Brazeal
 * @version     1.0.0
 * @since       2026-01-16
 * 
 * ================================================================================
 */

/* ========== CROSSPOST MODAL OVERLAY ========== */

.crosspost-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    padding: 1rem;
}

.crosspost-modal-overlay.crosspost-modal-visible {
    opacity: 1;
    visibility: visible;
}

/* ========== CROSSPOST MODAL ========== */

.crosspost-modal {
    background: var(--card-bg, #ffffff);
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.crosspost-modal-visible .crosspost-modal {
    transform: scale(1);
}

/* ========== MODAL HEADER ========== */

.crosspost-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.crosspost-modal-title-row {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.crosspost-modal-icon {
    width: 20px;
    height: 20px;
    opacity: 0.8;
}

.crosspost-modal-header h2 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
}

.crosspost-modal-close {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease;
}

.crosspost-modal-close:hover {
    background-color: var(--hover-bg, #f0f0f0);
}

.crosspost-modal-close img {
    width: 18px;
    height: 18px;
    opacity: 0.6;
}

/* ========== MODAL BODY ========== */

.crosspost-modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

/* ========== ORIGINAL THREAD PREVIEW ========== */

.crosspost-original-preview {
    margin-bottom: 1.5rem;
}

.crosspost-preview-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary, #666666);
    margin-bottom: 0.5rem;
}

.crosspost-preview-content {
    background: var(--bg-secondary, #f5f5f5);
    border-radius: 8px;
    padding: 0.875rem;
    border: 1px solid var(--border-color, #e0e0e0);
}

.crosspost-preview-meta {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--text-secondary, #666666);
    margin-bottom: 0.375rem;
}

.crosspost-preview-location {
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
}

.crosspost-preview-separator {
    opacity: 0.5;
}

.crosspost-preview-author {
    color: var(--text-secondary, #666666);
}

.crosspost-preview-title {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary, #1a1a1a);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.crosspost-preview-media {
    margin-top: 0.625rem;
    border-radius: 6px;
    overflow: hidden;
    max-height: 120px;
}

.crosspost-preview-media img {
    width: 100%;
    height: auto;
    max-height: 120px;
    object-fit: cover;
}

/* ========== DESTINATION SELECTION ========== */

.crosspost-destination {
    margin-bottom: 1.5rem;
}

.crosspost-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
    margin-bottom: 0.625rem;
}

.crosspost-destination-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 240px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

/* ========== DESTINATION OPTIONS ========== */

.crosspost-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: var(--card-bg, #ffffff);
}

.crosspost-option:hover:not([disabled]) {
    border-color: var(--primary-color, #0079d3);
    background: var(--hover-bg, #f8f9fa);
}

.crosspost-option-selected {
    border-color: var(--primary-color, #0079d3);
    background: rgba(0, 121, 211, 0.05);
}

.crosspost-option-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.crosspost-option-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.crosspost-option-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.crosspost-option-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color, #0079d3);
    color: white;
    font-weight: 600;
    font-size: 1rem;
}

.crosspost-option-info {
    flex: 1;
    min-width: 0;
}

.crosspost-option-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crosspost-option-description {
    font-size: 0.75rem;
    color: var(--text-secondary, #666666);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crosspost-option-check {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border-color, #e0e0e0);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0;
    transition: all 0.15s ease;
}

.crosspost-option-check img {
    width: 12px;
    height: 12px;
}

.crosspost-option-selected .crosspost-option-check {
    opacity: 1;
    border-color: var(--primary-color, #0079d3);
    background: var(--primary-color, #0079d3);
}

.crosspost-option-selected .crosspost-option-check img {
    filter: brightness(0) invert(1);
}

/* No circles message */
.crosspost-no-circles {
    text-align: center;
    padding: 1.5rem 1rem;
    color: var(--text-secondary, #666666);
}

.crosspost-no-circles p {
    margin: 0 0 0.75rem;
    font-size: 0.875rem;
}

.crosspost-explore-link {
    color: var(--primary-color, #0079d3);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
}

.crosspost-explore-link:hover {
    text-decoration: underline;
}

/* ========== CUSTOM TITLE SECTION ========== */

.crosspost-title-section {
    position: relative;
}

.crosspost-optional {
    font-weight: 400;
    color: var(--text-secondary, #666666);
}

.crosspost-title-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    font-size: 0.9375rem;
    color: var(--text-primary, #1a1a1a);
    background: var(--card-bg, #ffffff);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.crosspost-title-input:focus {
    outline: none;
    border-color: var(--primary-color, #0079d3);
    box-shadow: 0 0 0 3px rgba(0, 121, 211, 0.1);
}

.crosspost-title-input::placeholder {
    color: var(--text-secondary, #999999);
}

.crosspost-title-hint {
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-secondary, #999999);
    margin-top: 0.25rem;
}

/* ========== MODAL FOOTER ========== */

.crosspost-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color, #e0e0e0);
    background: var(--bg-secondary, #f9f9f9);
    border-radius: 0 0 12px 12px;
}

/* ========== BUTTONS ========== */

.crosspost-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
}

.crosspost-btn-cancel {
    background: transparent;
    color: var(--text-secondary, #666666);
    border: 1px solid var(--border-color, #e0e0e0);
}

.crosspost-btn-cancel:hover {
    background: var(--hover-bg, #f0f0f0);
    color: var(--text-primary, #1a1a1a);
}

.crosspost-btn-submit {
    background: var(--primary-color, #0079d3);
    color: white;
}

.crosspost-btn-submit:hover:not(:disabled) {
    background: var(--primary-hover, #006cbd);
}

.crosspost-btn-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.crosspost-btn-icon {
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(1);
}

.crosspost-btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: crosspost-spin 0.8s linear infinite;
}

@keyframes crosspost-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========== CROSSPOST BADGE (Thread Cards) ========== */

.crosspost-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    background: var(--bg-secondary, #f0f0f0);
    border-radius: 4px;
    font-size: 0.6875rem;
    color: var(--text-secondary, #666666);
    text-decoration: none;
    transition: background-color 0.15s ease;
}

.crosspost-badge:hover {
    background: var(--hover-bg, #e5e5e5);
    text-decoration: none;
}

.crosspost-badge-icon {
    width: 12px;
    height: 12px;
    opacity: 0.7;
}

.crosspost-badge-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

/* ========== CROSSPOST INFO (Thread Detail) ========== */

.crosspost-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary, #f5f5f5);
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color, #e0e0e0);
}

.crosspost-info-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.crosspost-info-icon {
    width: 16px;
    height: 16px;
    opacity: 0.6;
    flex-shrink: 0;
}

.crosspost-info-label {
    font-size: 0.8125rem;
    color: var(--text-secondary, #666666);
}

.crosspost-info-source {
    color: var(--primary-color, #0079d3);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.8125rem;
}

.crosspost-info-source:hover {
    text-decoration: underline;
}

.crosspost-info-original {
    display: block;
    padding: 0.625rem;
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    text-decoration: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.crosspost-info-original:hover {
    border-color: var(--primary-color, #0079d3);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.crosspost-info-original-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.crosspost-info-original-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary, #1a1a1a);
    line-height: 1.4;
}

.crosspost-info-original-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary, #666666);
}

.crosspost-info-original-link img {
    width: 12px;
    height: 12px;
    opacity: 0.7;
}

.crosspost-info-text {
    font-size: 0.8125rem;
    color: var(--text-secondary, #666666);
}

.crosspost-info-link {
    color: var(--primary-color, #0079d3);
    text-decoration: none;
    font-weight: 500;
}

.crosspost-info-link:hover {
    text-decoration: underline;
}

/* ========== CROSSPOST COUNT INDICATOR ========== */

.crosspost-count {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary, #666666);
    cursor: pointer;
    transition: color 0.15s ease;
}

.crosspost-count:hover {
    color: var(--primary-color, #0079d3);
}

.crosspost-count-icon {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

/* ========== CROSSPOST ACTION BUTTON ========== */

.action-btn-crosspost {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

/* ========== DARK MODE SUPPORT ========== */

[data-theme="dark"] .crosspost-modal {
    background: var(--card-bg, #1a1a1b);
}

[data-theme="dark"] .crosspost-preview-content {
    background: var(--bg-secondary, #272729);
}

[data-theme="dark"] .crosspost-option {
    background: var(--card-bg, #1a1a1b);
}

[data-theme="dark"] .crosspost-option:hover:not([disabled]) {
    background: var(--hover-bg, #272729);
}

[data-theme="dark"] .crosspost-option-selected {
    background: rgba(0, 121, 211, 0.15);
}

[data-theme="dark"] .crosspost-title-input {
    background: var(--bg-secondary, #272729);
}

[data-theme="dark"] .crosspost-modal-footer {
    background: var(--bg-secondary, #272729);
}

[data-theme="dark"] .crosspost-badge {
    background: var(--bg-secondary, #272729);
}

[data-theme="dark"] .crosspost-info {
    background: var(--bg-secondary, #272729);
}

[data-theme="dark"] .crosspost-info-original {
    background: var(--bg-primary, #1a1a1b);
    border-color: var(--border-color, #343536);
}

[data-theme="dark"] .crosspost-info-original-title {
    color: var(--text-primary, #d7dadc);
}

[data-theme="dark"] .crosspost-info-original-link {
    color: var(--text-secondary, #818384);
}

/* ========== RESPONSIVE DESIGN ========== */

@media (max-width: 480px) {
    .crosspost-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }
    
    .crosspost-modal {
        max-width: 100%;
        max-height: 85vh;
        border-radius: 12px 12px 0 0;
    }
    
    .crosspost-modal-body {
        padding: 1rem;
    }
    
    .crosspost-modal-footer {
        padding: 0.875rem 1rem;
    }
    
    .crosspost-btn {
        flex: 1;
    }
    
    .crosspost-destination-list {
        max-height: 200px;
    }
}
