/* Report Base Styles - Shared across all clients */
/* Override CSS variables in client theme.css */

:root {
    /* Theme Colors - Override these per client */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --background-dark: #1a1a2e;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    --card-bg: #f8fafc;
    --card-hover: #f1f5f9;
    --success-color: #059669;
    --error-color: #dc2626;
}

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

body {
    font-family: 'Work Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background-dark);
    min-height: 100vh;
}

/* Toolbar */
.toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.toolbar-logo {
    height: 36px;
}

.toolbar-title {
    color: var(--text-primary);
    font-size: 0.9rem;
}

.toolbar-right {
    display: flex;
    gap: 10px;
}

/* Buttons */
.btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-family: inherit;
    text-decoration: none;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: #475569;
    border: 1px solid var(--border-color);
}

.btn-outline:hover {
    background: var(--card-hover);
    border-color: var(--border-hover);
}

.btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* Document Viewer */
.viewer {
    padding-top: 60px;
    min-height: 100vh;
    background: var(--background-dark);
    display: flex;
    justify-content: center;
    padding: 40px 20px;
}

/* Paper Document */
.paper {
    background: white;
    width: 100%;
    max-width: 900px;
    box-shadow: 0 25px 80px rgba(0,0,0,0.5);
    border-radius: 4px;
}

/* Report Header */
.report-header {
    background: #ffffff;
    color: var(--text-primary);
    padding: 40px;
    border-radius: 4px 4px 0 0;
    border-bottom: 3px solid var(--primary-color);
}

.report-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.report-logo {
    height: 45px;
}

.report-date {
    text-align: right;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.report-filter {
    margin-top: 12px;
}

.report-filter select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: inherit;
    background: white;
    color: var(--text-primary);
    cursor: pointer;
}

.report-filter select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.report-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.report-subtitle {
    font-size: 1rem;
    color: var(--primary-color);
}

/* Report Body */
.report-body {
    padding: 40px;
}

/* Data Bar */
.data-bar {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.data-bar strong {
    color: var(--text-primary);
}

/* Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-card .stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

/* Chart Grid */
.chart-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin-bottom: 40px;
}

.chart-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
}

.chart-card .chart-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.chart-card .chart-container {
    height: 140px;
}

/* Top Posts Section */
.top-posts-section {
    margin-top: 40px;
}

.top-posts-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-color);
}

.top-posts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.top-post-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.2s;
}

.top-post-item:hover {
    background: var(--card-hover);
    border-color: var(--border-hover);
}

.top-post-rank {
    width: 32px;
    height: 32px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    margin-right: 16px;
    flex-shrink: 0;
}

.top-post-info {
    flex: 1;
    min-width: 0;
}

.top-post-agent {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.top-post-link {
    font-size: 0.8rem;
    color: var(--primary-color);
    text-decoration: none;
    word-break: break-all;
}

.top-post-link:hover {
    text-decoration: underline;
}

.top-post-metrics {
    text-align: right;
    flex-shrink: 0;
    margin-left: 16px;
}

.top-post-impressions {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.top-post-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

/* Platform Section */
.platform-section {
    margin-bottom: 30px;
}

.platform-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary-color);
    margin-bottom: 16px;
}

.platform-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
}

.platform-header .count {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.data-table th {
    text-align: left;
    padding: 12px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 10px;
    border-bottom: 1px solid var(--card-hover);
    color: #374151;
}

.data-table tr:hover {
    background: var(--card-bg);
}

.data-table .number {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* Report Footer */
.report-footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 0 0 4px 4px;
}

.report-footer-left {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.report-footer-right {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.report-footer-right img {
    height: 16px;
    opacity: 0.5;
}

.report-footer-disclaimer {
    font-size: 0.55rem;
    color: var(--text-muted);
    text-align: right;
    line-height: 1.3;
    font-style: italic;
    max-width: 280px;
    margin-left: auto;
}

/* Loading */
.loading {
    text-align: center;
    padding: 80px 40px;
    color: var(--text-secondary);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

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

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

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

.modal-icon {
    width: 48px;
    height: 48px;
    background: #eff6ff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.modal-icon svg {
    width: 24px;
    height: 24px;
    color: var(--primary-color);
}

.modal h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.modal p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.modal input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    margin-bottom: 24px;
    transition: border-color 0.2s;
}

.modal input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.modal input::placeholder {
    color: var(--text-muted);
}

.modal-buttons {
    display: flex;
    gap: 12px;
}

.modal-buttons .btn {
    flex: 1;
    justify-content: center;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--text-primary);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 2000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--error-color);
}

.toast-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.toast-message {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Facebook Sidebar (outside report paper) */
.facebook-sidebar {
    position: fixed;
    right: 20px;
    top: 80px;
    width: 320px;
    max-height: calc(100vh - 100px);
    z-index: 50;
}

/* Facebook Daily Section */
.facebook-daily-section {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.facebook-daily-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #1877f2;
}

.facebook-daily-section .table-wrapper {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

@media (max-width: 1400px) {
    .facebook-daily-section .table-wrapper {
        max-height: 400px;
    }
}

/* Editable Table */
.editable-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.editable-table th {
    text-align: left;
    padding: 8px 6px;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
}

.editable-table td {
    padding: 6px;
    border-bottom: 1px solid var(--card-hover);
    color: #374151;
}

.editable-table .editable-cell {
    cursor: text;
    padding: 4px 6px;
    border-radius: 4px;
    transition: background 0.2s;
    min-width: 50px;
    display: inline-block;
}

.editable-table .editable-cell:hover {
    background: #e0e7ff;
}

.editable-table .editable-cell:focus {
    outline: none;
    background: #c7d2fe;
    box-shadow: 0 0 0 2px var(--primary-color);
}

.editable-table .number {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Responsive */
@media (max-width: 1400px) {
    .facebook-sidebar {
        position: static;
        width: 100%;
        max-width: 900px;
        margin: 20px auto;
        max-height: none;
    }
}

@media (max-width: 768px) {
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .toolbar-title {
        display: none;
    }
    .btn span {
        display: none;
    }
    .btn {
        padding: 10px;
    }
    .report-header, .report-body {
        padding: 24px;
    }
    .data-table {
        font-size: 0.7rem;
    }
}
