* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.card h2 {
    margin-bottom: 1rem;
    color: #667eea;
    font-size: 1.3rem;
}

/* Pipeline Overview */
.pipeline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.pipeline-stage {
    flex: 1;
    min-width: 100px;
    text-align: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.stage-value {
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
}

.stage-label {
    font-size: 0.9rem;
    color: #666;
    margin-top: 0.5rem;
}

.pipeline-arrow {
    font-size: 1.5rem;
    color: #999;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: #f8f9fa;
}

th {
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    color: #666;
    border-bottom: 2px solid #dee2e6;
}

td {
    padding: 0.75rem;
    border-bottom: 1px solid #dee2e6;
}

tr:hover {
    background: #f8f9fa;
}

.loading {
    text-align: center;
    color: #999;
    font-style: italic;
}

.status-approved {
    color: #28a745;
    font-weight: 600;
}

.status-rejected {
    color: #dc3545;
    font-weight: 600;
}

.status-discovered {
    color: #ffc107;
    font-weight: 600;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: #666;
    font-size: 0.9rem;
}

#last-update {
    font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
    .pipeline {
        flex-direction: column;
    }

    .pipeline-arrow {
        transform: rotate(90deg);
    }
}

/* Navigation */
.main-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: bold;
    color: white;
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-link {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.nav-link:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.nav-link.active {
    color: white;
    background: rgba(255, 255, 255, 0.2);
}

.nav-separator {
    color: rgba(255, 255, 255, 0.4);
    font-weight: 300;
    padding: 0 0.25rem;
}

/* Card header with actions */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a6fd6;
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.btn-secondary:hover {
    background: #cbd5e0;
}

.btn-danger {
    background: #fc8181;
    color: white;
}

.btn-danger:hover {
    background: #f56565;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Config cards */
.configs-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.config-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
}

.config-card.active {
    border-left: 4px solid #48bb78;
}

.config-card.paused {
    border-left: 4px solid #a0aec0;
    opacity: 0.7;
}

.config-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.config-status {
    color: #48bb78;
}

.config-card.paused .config-status {
    color: #a0aec0;
}

.config-name {
    flex: 1;
    margin: 0;
    font-size: 1rem;
}

.platform-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.platform-badge.platform-reddit {
    background: #ff4500;
    color: white;
}

.platform-badge.platform-twitter {
    background: #1da1f2;
    color: white;
}

.platform-badge.platform-threads {
    background: #000;
    color: white;
}

.config-details {
    font-size: 0.875rem;
    color: #718096;
}

.config-details p {
    margin: 0.25rem 0;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #a0aec0;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 1rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* AI results */
.ai-config-option {
    background: #f7fafc;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.ai-config-option label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Empty/loading states */
.empty-state,
.loading {
    text-align: center;
    color: #a0aec0;
    padding: 2rem;
}

.error {
    color: #e53e3e;
    text-align: center;
    padding: 1rem;
}

/* Opportunities page */
.filters {
    display: flex;
    gap: 0.5rem;
}

.filters select {
    padding: 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: white;
}

.result-count {
    color: #718096;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.opportunities-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.opportunity-card {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.2s;
}

.opportunity-card:hover {
    border-color: #667eea;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.opportunity-card .opp-link {
    flex: 1;
    text-decoration: none;
    color: inherit;
}

/* Star button for opportunities */
.star-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
    padding: 0.25rem;
    color: #ccc;
    transition: color 0.2s, transform 0.1s;
    flex-shrink: 0;
}

.star-btn:hover {
    color: #f5a623;
    transform: scale(1.1);
}

.star-btn.starred {
    color: #f5a623;
}

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

.opp-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.opp-title {
    font-weight: 500;
    flex: 1;
    margin-right: 1rem;
}

.opp-score {
    background: #667eea;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
}

.opp-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: #718096;
    flex-wrap: wrap;
}

.opp-campaign {
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    background: #e3f2fd;
    color: #1565c0;
    font-weight: 500;
}

.opp-status {
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-discovered { background: #bee3f8; color: #2b6cb0; }
.status-claimed { background: #faf089; color: #975a16; }
.status-completed { background: #c6f6d5; color: #276749; }
.status-failed { background: #fed7d7; color: #c53030; }
.status-expired { background: #e2e8f0; color: #718096; }

.opp-claimed {
    font-size: 0.75rem;
    color: #975a16;
    margin-top: 0.5rem;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.pagination button {
    padding: 0.5rem 1rem;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 4px;
    cursor: pointer;
}

.pagination button:hover {
    background: #f7fafc;
}

.page-info {
    color: #718096;
}

/* Opportunity detail page */
.back-link {
    display: inline-block;
    color: #667eea;
    text-decoration: none;
    margin-bottom: 1rem;
}

.back-link:hover {
    text-decoration: underline;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.detail-header .star-btn {
    font-size: 1.5em;
}

.detail-header .detail-title {
    margin: 0;
}

.detail-title {
    margin: 0 0 1.5rem 0;
    font-size: 1.5rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.detail-row {
    display: flex;
    flex-direction: column;
}

.detail-label {
    font-size: 0.75rem;
    color: #718096;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.detail-value {
    font-size: 1rem;
}

.detail-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
}

.detail-section h3 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
}

.content-preview {
    background: #f7fafc;
    padding: 1rem;
    border-radius: 4px;
    white-space: pre-wrap;
    font-size: 0.875rem;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.metric {
    text-align: center;
    padding: 1rem;
    background: #f7fafc;
    border-radius: 4px;
}

.metric-value {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: #2d3748;
}

.metric-label {
    font-size: 0.75rem;
    color: #718096;
}

.timeline {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.timeline-item {
    display: flex;
    flex-direction: column;
}

.timeline-label {
    font-size: 0.75rem;
    color: #718096;
}

.timeline-value {
    font-size: 0.875rem;
}

.json-view {
    background: #2d3748;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 0.75rem;
}

details summary {
    cursor: pointer;
    color: #667eea;
}

.opportunity-actions {
    margin-top: 1rem;
}

/* Status indicators */
.status-success {
    color: #48bb78;
}

.status-warning {
    color: #ed8936;
}

/* Campaign Context Banner */
.campaign-banner {
    background: #e3f2fd;
    border-bottom: 1px solid #90caf9;
    padding: 8px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.campaign-banner.hidden {
    display: none;
}

.campaign-banner span {
    font-weight: 500;
    color: #1565c0;
}

/* Warning Banner for name collisions */
.warning-banner {
    background: #fff9c4;
    border-bottom: 1px solid #fbc02d;
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #f57f17;
}

.warning-banner.hidden {
    display: none;
}

.warning-banner a {
    color: #e65100;
    text-decoration: underline;
}

.warning-banner a:hover {
    color: #bf360c;
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.badge-gray { background: #e0e0e0; color: #616161; }
.badge-green { background: #c8e6c9; color: #2e7d32; }
.badge-yellow { background: #fff9c4; color: #f57f17; }
.badge-blue { background: #bbdefb; color: #1565c0; }

/* Button variants */
.btn-small {
    padding: 4px 8px;
    font-size: 12px;
}

.btn-danger {
    background: #ef5350;
    color: white;
}

.btn-danger:hover {
    background: #e53935;
}

/* Table styles */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.data-table th {
    background: #f5f5f5;
    font-weight: 600;
}

.data-table tr.clickable:hover {
    background: #f5f5f5;
    cursor: pointer;
}

.data-table .actions {
    white-space: nowrap;
}

.data-table .truncate {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Modal small variant */
.modal-small {
    max-width: 400px;
}

/* Empty/error states */
.empty {
    text-align: center;
    padding: 40px;
    color: #757575;
}

/* Media preview for opportunity detail */
.media-preview {
    background: #f7fafc;
    padding: 1rem;
    border-radius: 4px;
}

.post-thumbnail {
    max-width: 300px;
    max-height: 200px;
    border-radius: 4px;
    display: block;
    margin-bottom: 0.5rem;
}

.link-url {
    margin: 0.5rem 0 0 0;
    font-size: 0.875rem;
    word-break: break-all;
}

.link-url a {
    color: #667eea;
}

/* Config filter badge */
.opp-config {
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    background: #f3e5f5;
    color: #7b1fa2;
    font-weight: 500;
}

/* Message status styles */
.opp-message { margin-top: 8px; font-size: 13px; }
.message-preview { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-text { color: #333; }
.message-generating { color: #0066cc; font-style: italic; }
.message-failed { color: #cc0000; }
.message-pending { color: #666; font-style: italic; }
.message-none { color: #999; }
.message-content { white-space: pre-wrap; padding: 10px; background: #f5f5f5; border-radius: 4px; margin: 10px 0; }
.message-error { color: #cc0000; padding: 10px; background: #fff5f5; border-radius: 4px; margin: 10px 0; }
.message-actions { margin-top: 10px; }

/* Badge styles for message status */
.badge-success { background: #d4edda; color: #155724; }
.badge-error { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-pending { background: #fff3cd; color: #856404; }

/* Badge styling for counts */
.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
    background: #e5e7eb;
    border-radius: 9999px;
}

/* Status badge variants for opportunities */
.status-badge.status-discovered { background: #dbeafe; color: #1e40af; }
.status-badge.status-claimed { background: #fef3c7; color: #92400e; }
.status-badge.status-completed { background: #d1fae5; color: #065f46; }
.status-badge.status-failed { background: #fee2e2; color: #991b1b; }
.status-badge.status-expired { background: #e5e7eb; color: #374151; }

/* Tune result panel */
.tune-result-panel {
    padding: 1rem;
    margin: 0.5rem 0;
    background: #f0f4ff;
    border: 1px solid #667eea;
    border-radius: 6px;
}

.tune-result-panel h4 {
    margin: 0 0 0.5rem 0;
    color: #667eea;
}

.tune-query {
    display: block;
    padding: 0.5rem;
    margin: 0.5rem 0;
    background: #1a202c;
    color: #68d391;
    border-radius: 4px;
    font-size: 0.85rem;
    word-break: break-all;
}
