/* Reset & Base */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #0c111d;
    color: #e2e8f0;
    min-height: 100vh;
}

/* Layout */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header */
.header {
    background: linear-gradient(135deg, #1a1f35 0%, #0f172a 100%);
    border-bottom: 1px solid rgba(59, 130, 246, 0.15);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
}

.header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header h1 {
    font-size: 22px;
    font-weight: 800;
    color: #f8fafc;
    letter-spacing: -0.5px;
}

.header h1 span {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav {
    display: flex;
    gap: 4px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid #1e293b;
    border-radius: 10px;
    padding: 4px;
}

.nav a {
    text-decoration: none;
    color: #64748b;
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.nav a:hover {
    color: #e2e8f0;
}

.nav a.active {
    color: #fff;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* Filtros */
.filters {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 24px 0;
    flex-wrap: wrap;
}

.preset-btn {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid #334155;
    color: #94a3b8;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.preset-btn:hover {
    border-color: #3b82f6;
    color: #e2e8f0;
    background: rgba(59, 130, 246, 0.1);
}

.preset-btn.active {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.date-input {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.date-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.date-separator {
    color: #475569;
    font-size: 13px;
}

.btn-apply {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border: none;
    color: #fff;
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.btn-apply:hover {
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
    transform: translateY(-1px);
}

/* Cards de resumo */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}

.card {
    background: linear-gradient(145deg, #1a2035 0%, #151b2e 100%);
    border: 1px solid rgba(51, 65, 85, 0.5);
    border-radius: 14px;
    padding: 20px;
    transition: all 0.25s;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    opacity: 0;
    transition: opacity 0.25s;
}

.card:hover {
    border-color: rgba(59, 130, 246, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.card:hover::before {
    opacity: 1;
}

.card-label {
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
    font-weight: 600;
}

.card-value {
    font-size: 22px;
    font-weight: 800;
    color: #f8fafc;
    letter-spacing: -0.5px;
}

.card-value.currency {
    color: #22c55e;
}

.card-value.blue {
    color: #60a5fa;
}

.card-value.purple {
    color: #a78bfa;
}

.card-value.orange {
    color: #fb923c;
}

/* Social cards - icone de plataforma */
.platform-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    margin-bottom: 12px;
}

.platform-icon.fb {
    background: rgba(24, 119, 242, 0.15);
    color: #1877f2;
}

.platform-icon.ig {
    background: linear-gradient(135deg, rgba(131, 58, 180, 0.15), rgba(253, 29, 29, 0.15));
    color: #e4405f;
}

/* Chart container */
.chart-section {
    background: linear-gradient(145deg, #1a2035 0%, #151b2e 100%);
    border: 1px solid rgba(51, 65, 85, 0.5);
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 28px;
}

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

.chart-title {
    font-size: 16px;
    font-weight: 700;
    color: #f8fafc;
}

.chart-canvas-wrapper {
    position: relative;
    height: 280px;
}

/* Tabela */
.table-wrapper {
    background: linear-gradient(145deg, #1a2035 0%, #151b2e 100%);
    border: 1px solid rgba(51, 65, 85, 0.5);
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 28px;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.5);
}

.table-header h2 {
    font-size: 16px;
    font-weight: 700;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: rgba(15, 23, 42, 0.6);
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: color 0.2s;
}

thead th:hover {
    color: #94a3b8;
}

thead th.sorted-asc::after { content: ' \2191'; color: #3b82f6; }
thead th.sorted-desc::after { content: ' \2193'; color: #3b82f6; }

tbody tr {
    border-bottom: 1px solid rgba(30, 41, 59, 0.5);
    transition: background 0.15s;
}

tbody tr:hover {
    background: rgba(59, 130, 246, 0.05);
}

tbody td {
    padding: 14px 16px;
    font-size: 14px;
    white-space: nowrap;
}

/* Platform badge */
.platform-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
}

.platform-badge.google {
    background: rgba(66, 133, 244, 0.1);
    color: #4285f4;
    border: 1px solid rgba(66, 133, 244, 0.2);
}

.platform-badge.meta {
    background: rgba(24, 119, 242, 0.1);
    color: #1877f2;
    border: 1px solid rgba(24, 119, 242, 0.2);
}

/* Status badge */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.enabled, .status-badge.active {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.status-badge.paused {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-badge.removed {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px;
    color: #64748b;
    font-size: 14px;
    gap: 12px;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(59, 130, 246, 0.15);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Error */
.error-banner {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    padding: 12px 20px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 13px;
}

/* Tabs Social */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid #1e293b;
    border-radius: 10px;
    padding: 4px;
    width: fit-content;
}

.tab-btn {
    background: none;
    border: none;
    color: #64748b;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-btn:hover {
    color: #e2e8f0;
}

.tab-btn.active {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #fff;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.tab-icon {
    font-size: 16px;
}

/* Grid de criativos */
.creatives-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.creative-card {
    background: linear-gradient(145deg, #1a2035 0%, #151b2e 100%);
    border: 1px solid rgba(51, 65, 85, 0.5);
    border-radius: 14px;
    overflow: hidden;
    transition: all 0.25s;
    position: relative;
}

.creative-card:hover {
    border-color: rgba(59, 130, 246, 0.3);
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.creative-thumbnail {
    width: 100%;
    height: 260px;
    object-fit: cover;
    background: rgba(15, 23, 42, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #475569;
    font-size: 13px;
    position: relative;
    overflow: hidden;
}

.creative-thumbnail img {
    width: 100%;
    height: 260px;
    object-fit: cover;
    object-position: center;
    image-rendering: auto;
}

.creative-info {
    padding: 18px;
}

.creative-name {
    font-size: 14px;
    font-weight: 700;
    color: #f8fafc;
    margin-bottom: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.creative-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.creative-metric {
    text-align: center;
    padding: 8px 4px;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 8px;
}

.creative-metric-label {
    font-size: 10px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

.creative-metric-value {
    font-size: 15px;
    font-weight: 800;
    color: #e2e8f0;
    margin-top: 3px;
}

/* Ranking badge */
.rank-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    z-index: 2;
}

.rank-badge.top {
    background: rgba(34, 197, 94, 0.9);
    color: #fff;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.4);
}

.rank-badge.bottom {
    background: rgba(239, 68, 68, 0.9);
    color: #fff;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

/* Section title */
.section-title {
    font-size: 18px;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: -0.3px;
}

/* WhatsApp button */
.btn-whatsapp {
    background: #25d366;
    border: none;
    color: #fff;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
    white-space: nowrap;
}

.btn-whatsapp:hover {
    box-shadow: 0 4px 16px rgba(37, 211, 102, 0.4);
    transform: translateY(-1px);
}

.btn-whatsapp:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    z-index: 100;
    animation: toastIn 0.3s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.toast.success {
    background: #052e16;
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #22c55e;
}

.toast.error {
    background: #450a0a;
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Sort selector */
.sort-select {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

.sort-select:focus {
    border-color: #3b82f6;
}

/* Social section divider */
.social-section {
    margin-bottom: 36px;
}

.social-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.social-section-header .section-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.social-section-header .section-icon.fb {
    background: rgba(24, 119, 242, 0.15);
}

.social-section-header .section-icon.ig {
    background: linear-gradient(135deg, rgba(131, 58, 180, 0.15), rgba(253, 29, 29, 0.15));
}

/* Two-column chart layout */
.charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

/* Account balance cards */
.balance-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.balance-card {
    background: linear-gradient(145deg, #1a2035 0%, #151b2e 100%);
    border: 1px solid rgba(51, 65, 85, 0.5);
    border-radius: 14px;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.balance-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #22c55e, #3b82f6);
}

.balance-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.balance-name {
    font-size: 13px;
    color: #94a3b8;
    font-weight: 500;
}

.balance-amount {
    margin-bottom: 16px;
}

.balance-label {
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
    margin-bottom: 4px;
}

.balance-value {
    font-size: 28px;
    font-weight: 800;
    color: #22c55e;
    letter-spacing: -0.5px;
}

.balance-details {
    border-top: 1px solid rgba(51, 65, 85, 0.5);
    padding-top: 12px;
}

.balance-detail {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.balance-detail-label {
    font-size: 12px;
    color: #64748b;
}

.balance-detail-value {
    font-size: 14px;
    font-weight: 700;
    color: #e2e8f0;
}

.balance-bar {
    width: 100%;
    height: 6px;
    background: rgba(51, 65, 85, 0.5);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}

.balance-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}

/* Breakdown cards (organico vs anuncios) */
.breakdown-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.breakdown-card {
    background: linear-gradient(145deg, #1a2035 0%, #151b2e 100%);
    border: 1px solid rgba(51, 65, 85, 0.5);
    border-radius: 14px;
    padding: 20px;
    transition: all 0.25s;
    position: relative;
    overflow: hidden;
}

.breakdown-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    opacity: 0;
    transition: opacity 0.25s;
}

.breakdown-card:hover {
    border-color: rgba(59, 130, 246, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.breakdown-card:hover::before {
    opacity: 1;
}

.breakdown-total {
    font-size: 30px;
    font-weight: 800;
    color: #f8fafc;
    letter-spacing: -0.5px;
    margin: 8px 0 14px;
}

.breakdown-total.blue { color: #60a5fa; }
.breakdown-total.orange { color: #fb923c; }
.breakdown-total.purple { color: #a78bfa; }

.breakdown-details {
    border-top: 1px solid rgba(51, 65, 85, 0.5);
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.breakdown-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.breakdown-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.breakdown-dot.organic {
    background: #22c55e;
}

.breakdown-dot.ads {
    background: #8b5cf6;
}

.breakdown-label {
    font-size: 12px;
    color: #64748b;
    flex: 1;
}

.breakdown-value {
    font-size: 14px;
    font-weight: 700;
    color: #e2e8f0;
}

/* Post badges */
.post-badges {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    gap: 6px;
    z-index: 2;
}

.post-caption {
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.5;
    margin-bottom: 14px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-link {
    color: #3b82f6;
    text-decoration: none;
    font-size: 16px;
    transition: color 0.2s;
}

.post-link:hover {
    color: #60a5fa;
}

.post-filters {
    display: flex;
    gap: 4px;
}

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

    .filters {
        flex-direction: column;
        align-items: stretch;
    }

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

    .table-wrapper {
        overflow-x: auto;
    }

    .balance-cards {
        grid-template-columns: 1fr;
    }

    .breakdown-cards {
        grid-template-columns: 1fr;
    }

    .creatives-grid {
        grid-template-columns: 1fr;
    }

    .charts-row {
        grid-template-columns: 1fr;
    }

    .card-value {
        font-size: 20px;
    }
}

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

/* === Taxas de Engajamento === */
.section-subtitle {
    color: #94a3b8;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 28px 0 14px;
}
.card-hint {
    color: #64748b;
    font-size: 11px;
    margin-top: 6px;
}
.card-trend {
    font-size: 12px;
    font-weight: 600;
    margin-top: 6px;
}
.card-trend.up { color: #22c55e; }
.card-trend.down { color: #ef4444; }
.rate-scale { margin-top: 10px; }
.rate-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.rate-low {
    color: #ef4444;
}
.rate-pill.rate-low {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.rate-good {
    color: #facc15;
}
.rate-pill.rate-good {
    background: rgba(250, 204, 21, 0.12);
    border: 1px solid rgba(250, 204, 21, 0.3);
}
.rate-excellent {
    color: #22c55e;
}
.rate-pill.rate-excellent {
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.3);
}
