/* =====================================================
   POSTS ANALYSIS STYLES - Version Screenshot/Tableau
   SOS Storytelling 2026
   ===================================================== */

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

.pa-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 9999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 30px 20px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

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

.pa-modal {
    background: white;
    border-radius: 20px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 1100px;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    transform: translateY(-30px);
    transition: transform 0.3s;
}

.pa-modal-overlay.active .pa-modal {
    transform: translateY(0);
}

/* ==========================================
   LAYOUT PRINCIPAL
   ========================================== */

.posts-analysis-module {
    padding: 30px;
}

.pa-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.pa-title h2 {
    margin: 0 0 5px 0;
    font-size: 1.6em;
    color: #333;
}

.pa-title p {
    margin: 0;
    color: #666;
    font-size: 0.9em;
}

.pa-close-btn {
    background: #f5f7ff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2em;
    cursor: pointer;
    color: #667;
    transition: all 0.2s;
    flex-shrink: 0;
}

.pa-close-btn:hover {
    background: #e8ecff;
    color: #333;
    transform: rotate(90deg);
}

/* ==========================================
   STATS CARDS
   ========================================== */

.pa-stats-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.pa-stat-card {
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f4ff 100%);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.pa-stat-card.pa-stat-best {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.pa-stat-value {
    display: block;
    font-size: 1.8em;
    font-weight: 700;
    margin-bottom: 5px;
}

.pa-stat-card:not(.pa-stat-best) .pa-stat-value {
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.pa-stat-label {
    font-size: 0.8em;
    opacity: 0.8;
}

/* ==========================================
   UPLOAD SECTION
   ========================================== */

.pa-upload-section {
    background: #f8f9ff;
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 30px;
    border: 2px dashed rgba(102, 126, 234, 0.3);
}

.pa-upload-section h3 {
    margin: 0 0 8px 0;
    font-size: 1.1em;
    color: #333;
}

.pa-upload-hint {
    margin: 0 0 15px 0;
    font-size: 0.85em;
    color: #666;
}

.pa-upload-area {
    background: white;
    border-radius: 12px;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px dashed #ddd;
}

.pa-upload-area:hover {
    border-color: #667eea;
    background: #fafbff;
}

.pa-upload-placeholder {
    text-align: center;
    color: #888;
}

.pa-upload-icon {
    font-size: 2.5em;
    display: block;
    margin-bottom: 10px;
}

/* Preview */
.pa-preview {
    position: relative;
    padding: 15px;
    width: 100%;
}

.pa-preview-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    display: block;
    margin: 0 auto;
}

.pa-preview-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1em;
}

.pa-preview-remove:hover {
    background: #e74c3c;
}

.pa-analyze-btn {
    display: block;
    width: calc(100% - 30px);
    margin: 15px auto 0;
    padding: 15px 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.pa-analyze-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.pa-analyze-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Spinner */
.pa-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: pa-spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

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

/* ==========================================
   ENGAGEMENT CHART
   ========================================== */

.pa-chart-section {
    background: white;
    border-radius: 16px;
    padding: 20px 25px;
    margin-bottom: 25px;
    border: 1px solid #eee;
}

.pa-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.pa-chart-header h3 {
    margin: 0;
    font-size: 1em;
    color: #333;
}

.pa-chart-avg {
    font-size: 0.85em;
    color: #667eea;
    font-weight: 600;
    background: #f0f4ff;
    padding: 5px 12px;
    border-radius: 20px;
}

.pa-chart-container {
    position: relative;
    height: 160px;
    padding-bottom: 30px;
}

.pa-chart-bars {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    height: 130px;
    gap: 8px;
}

.pa-chart-bar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    max-width: 80px;
    height: 100%;
}

.pa-chart-bar {
    width: 100%;
    min-width: 30px;
    max-width: 50px;
    background: linear-gradient(180deg, #a5b4fc 0%, #818cf8 100%);
    border-radius: 6px 6px 0 0;
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 5px;
}

.pa-chart-bar:hover {
    background: linear-gradient(180deg, #818cf8 0%, #667eea 100%);
    transform: scaleY(1.02);
}

.pa-chart-bar-current {
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
}

.pa-chart-value {
    font-size: 0.7em;
    font-weight: 600;
    color: white;
    opacity: 0;
    transition: opacity 0.2s;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.pa-chart-bar:hover .pa-chart-value {
    opacity: 1;
}

.pa-chart-label {
    font-size: 0.75em;
    color: #888;
    margin-top: 8px;
    white-space: nowrap;
}

.pa-chart-baseline {
    position: absolute;
    bottom: 30px;
    left: 0;
    right: 0;
    height: 1px;
    background: #e5e7eb;
}

.pa-chart-trend {
    text-align: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #f0f0f0;
}

.pa-trend {
    font-size: 0.9em;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 20px;
}

.pa-trend-up {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #059669;
}

.pa-trend-down {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #dc2626;
}

.pa-trend-stable {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    color: #4f46e5;
}

@media (max-width: 600px) {
    .pa-chart-bars {
        gap: 4px;
    }

    .pa-chart-bar {
        min-width: 20px;
    }

    .pa-chart-label {
        font-size: 0.65em;
    }

    .pa-chart-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
}

/* ==========================================
   AI INSIGHTS SECTION
   ========================================== */

.pa-ai-insights-section {
    background: linear-gradient(135deg, #f0f4ff 0%, #faf5ff 100%);
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 30px;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.pa-ai-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.pa-ai-header h3 {
    margin: 0;
    font-size: 1.1em;
    color: #333;
}

.pa-generate-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pa-generate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.pa-generate-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.pa-ai-placeholder {
    text-align: center;
    padding: 20px;
    color: #666;
}

.pa-ai-placeholder p {
    margin: 0;
}

.pa-insights-age {
    font-size: 0.8em;
    color: #888;
    margin: 0 0 15px 0;
    font-style: italic;
}

.pa-ai-insights-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.pa-insight-block {
    background: white;
    border-radius: 12px;
    padding: 18px 20px;
    border-left: 4px solid #667eea;
}

.pa-insight-block h4 {
    margin: 0 0 10px 0;
    font-size: 1em;
    color: #333;
}

.pa-insight-block p {
    margin: 0;
    color: #555;
    line-height: 1.6;
}

.pa-insight-block ul {
    margin: 0;
    padding-left: 20px;
    color: #555;
}

.pa-insight-block li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.pa-insight-block li:last-child {
    margin-bottom: 0;
}

.pa-insight-summary {
    border-left-color: #667eea;
}

.pa-insight-success {
    border-left-color: #10B981;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
}

.pa-insight-warning {
    border-left-color: #F59E0B;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
}

.pa-insight-tips {
    border-left-color: #3B82F6;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
}

.pa-insight-time {
    border-left-color: #8B5CF6;
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
}

.pa-insight-ideas {
    border-left-color: #EC4899;
    background: linear-gradient(135deg, #fdf2f8 0%, #fce7f3 100%);
}

/* ==========================================
   TABLE SECTION
   ========================================== */

.pa-table-section {
    margin-bottom: 30px;
}

.pa-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 15px;
}

.pa-table-header h3 {
    margin: 0;
    font-size: 1.1em;
    color: #333;
}

.pa-table-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.pa-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85em;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.pa-select:hover {
    border-color: #667eea;
}

.pa-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.pa-table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid #eee;
}

.pa-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.pa-table thead {
    background: #f8f9ff;
}

.pa-table th {
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #eee;
    white-space: nowrap;
}

.pa-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.pa-table tbody tr:hover {
    background: #fafbff;
}

.pa-td-date {
    color: #888;
    font-size: 0.9em;
    white-space: nowrap;
}

.pa-td-platform {
    font-size: 1.3em;
    text-align: center;
}

.pa-td-content {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #444;
}

.pa-td-stat {
    text-align: center;
    font-weight: 500;
    color: #555;
}

.pa-td-engagement {
    text-align: center;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 20px;
}

.pa-engagement-top {
    background: rgba(16, 185, 129, 0.15);
    color: #059669;
}

.pa-engagement-good {
    background: rgba(59, 130, 246, 0.15);
    color: #2563eb;
}

.pa-engagement-avg {
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
}

.pa-engagement-low {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

.pa-td-actions {
    text-align: center;
}

.pa-btn-delete-small {
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
    font-size: 1em;
}

.pa-btn-delete-small:hover {
    opacity: 1;
}

/* ==========================================
   EMPTY STATE
   ========================================== */

.pa-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #888;
}

.pa-empty-icon {
    font-size: 3em;
    margin-bottom: 15px;
    opacity: 0.5;
}

.pa-empty-state h3 {
    margin: 0 0 10px 0;
    color: #555;
}

.pa-empty-state p {
    margin: 0;
    font-size: 0.9em;
    max-width: 400px;
    margin: 0 auto;
}

/* ==========================================
   INSIGHTS SECTION
   ========================================== */

.pa-insights-section {
    background: linear-gradient(135deg, #f0f4ff 0%, #faf5ff 100%);
    border-radius: 16px;
    padding: 25px;
}

.pa-insights-section h3 {
    margin: 0 0 15px 0;
    font-size: 1.1em;
    color: #333;
}

.pa-insights-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pa-insight-card {
    background: white;
    border-radius: 10px;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 4px solid #667eea;
}

.pa-insight-card.success {
    border-left-color: #10B981;
}

.pa-insight-card.tip {
    border-left-color: #F59E0B;
}

.pa-insight-card.info {
    border-left-color: #3B82F6;
}

.pa-insight-icon {
    font-size: 1.3em;
}

.pa-insight-text {
    color: #444;
    font-size: 0.95em;
}

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

@media (max-width: 768px) {
    .posts-analysis-module {
        padding: 20px;
    }

    .pa-stats-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .pa-table {
        font-size: 0.8em;
    }

    .pa-table th,
    .pa-table td {
        padding: 10px 8px;
    }

    .pa-td-content {
        max-width: 120px;
    }

    .pa-header {
        flex-direction: column;
        gap: 15px;
    }

    .pa-close-btn {
        position: absolute;
        right: 20px;
        top: 20px;
    }
}

@media (max-width: 480px) {
    .pa-stats-cards {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .pa-stat-card {
        padding: 15px;
    }

    .pa-stat-value {
        font-size: 1.4em;
    }
}
