/* Estilos do Portal do Cliente Meta Ads | IGM Marketing */
:root {
    --bg-main: #0b0f19;
    --bg-card: rgba(15, 23, 42, 0.75);
    --bg-card-hover: rgba(30, 41, 59, 0.85);
    --card-border: rgba(255, 255, 255, 0.08);
    --primary: #0284c7;
    --primary-light: #38bdf8;
    --success: #10b981;
    --success-light: #4ade80;
    --warning: #f59e0b;
    --purple: #a855f7;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dark: #64748b;
    --radius: 12px;
    --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ================= TELA DE LOGIN ================= */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, rgba(2, 132, 199, 0.15), transparent 40%),
                radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.1), transparent 40%),
                var(--bg-main);
    padding: 1.5rem;
}

.login-container {
    width: 100%;
    max-width: 440px;
}

.login-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 2.5rem 2rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.login-logo-area {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-box {
    width: 120px;
    height: 48px;
    background: #ffffff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem auto;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.logo-img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    transform: scale(1.3);
}

.login-logo-area h2 {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 0.2rem;
}

.login-logo-area p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.login-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid #ef4444;
    color: #fca5a5;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.82rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.input-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.input-group input {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s;
}

.input-group input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-muted);
    cursor: pointer;
}

.forgot-pass {
    color: var(--primary-light);
    text-decoration: none;
}

.btn-login {
    background: linear-gradient(135deg, var(--primary), #0369a1);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 0.85rem;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(2, 132, 199, 0.3);
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(2, 132, 199, 0.4);
}

.login-demo-notice {
    background: rgba(2, 132, 199, 0.1);
    border: 1px dashed rgba(56, 189, 248, 0.3);
    border-radius: 10px;
    padding: 0.75rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-top: 0.5rem;
}

.login-demo-notice code {
    background: rgba(0, 0, 0, 0.4);
    color: var(--primary-light);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
}

.login-footer {
    margin-top: 2rem;
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-dark);
}

/* ================= HEADER DO DASHBOARD ================= */
.portal-header {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--card-border);
    padding: 0.85rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-logo-box {
    width: 90px;
    height: 36px;
    background: #ffffff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.header-logo-img {
    width: 90px;
    height: 90px;
    object-fit: contain;
    transform: scale(1.3);
}

.header-brand-info h1 {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.1;
}

.domain-tag {
    font-size: 0.68rem;
    color: var(--primary-light);
    font-weight: 600;
}

.api-status-badge {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: #6ee7b7;
    padding: 0.4rem 0.85rem;
    border-radius: 20px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
}

.status-dot.pulsing {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.sync-time {
    color: var(--text-dark);
    border-left: 1px solid rgba(255,255,255,0.1);
    padding-left: 0.5rem;
    margin-left: 0.2rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    color: #fff;
    font-weight: 800;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
}

.user-ad-account {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.btn-logout {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #fca5a5;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* ================= CONTEÚDO PRINCIPAL DO DASHBOARD ================= */
.portal-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 2rem 3rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
}

/* Barra de Filtros de Período */
.toolbar-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.toolbar-title h2 {
    font-size: 1.15rem;
    font-weight: 700;
}

.toolbar-title p {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.period-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
}

.period-buttons {
    display: flex;
    background: rgba(0, 0, 0, 0.4);
    padding: 0.25rem;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    gap: 0.2rem;
    flex-wrap: wrap;
}

.period-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.period-btn:hover {
    color: var(--text-main);
}

.period-btn.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

.custom-date-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0,0,0,0.3);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--card-border);
}

.date-input-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.date-input-group label {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.date-input-group input {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--card-border);
    color: #fff;
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
}

/* Ícone de Calendário Claro para Visualização Fácil */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1) brightness(2);
    cursor: pointer;
}

.btn-apply-date {
    background: var(--success);
    color: #fff;
    border: none;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
}

/* Grid de KPI Scorecards com Hierarquia Destaque vs Secundários */

/* Top Row - 3 Quadrados Maiores (Investimento, Receita, ROAS) */
.kpi-featured-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
}

/* Bottom Row - 5 Quadros Menores (Impressões, Cliques, Vendas, Ticket Médio, CPA) */
.kpi-secondary-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
}

.kpi-card-portal {
    background: var(--bg-card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 1.1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.kpi-card-portal:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* Quadrados Maiores (Destaque) */
.kpi-card-portal.featured {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.85), rgba(30, 41, 59, 0.75));
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 1.35rem 1.25rem;
    min-height: 105px;
}

.kpi-card-portal.featured .kpi-icon-box {
    width: 52px;
    height: 52px;
    font-size: 1.45rem;
    border-radius: 14px;
}

.kpi-card-portal.featured .kpi-value {
    font-size: 1.6rem;
    font-weight: 800;
}

.kpi-card-portal.featured .kpi-label {
    font-size: 0.76rem;
    letter-spacing: 0.5px;
}

/* Quadros Menores (Secundários) */
.kpi-card-portal.secondary {
    padding: 0.9rem 1rem;
    min-height: 85px;
}

.kpi-card-portal.secondary .kpi-icon-box {
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
    border-radius: 10px;
}

.kpi-card-portal.secondary .kpi-value {
    font-size: 1.2rem;
    font-weight: 800;
}

.kpi-card-portal.secondary .kpi-label {
    font-size: 0.68rem;
}

@media (max-width: 1100px) {
    .kpi-featured-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }
    .kpi-secondary-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

@media (max-width: 640px) {
    .kpi-featured-grid,
    .kpi-secondary-grid {
        grid-template-columns: 1fr;
    }
}

.kpi-icon-box {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.bg-blue { background: rgba(2, 132, 199, 0.15); }
.bg-purple { background: rgba(168, 85, 247, 0.15); }
.bg-indigo { background: rgba(99, 102, 241, 0.15); }
.bg-green { background: rgba(16, 185, 129, 0.15); }
.bg-teal { background: rgba(20, 184, 166, 0.15); }
.bg-amber { background: rgba(245, 158, 11, 0.15); }
.bg-emerald { background: rgba(16, 185, 129, 0.2); }

.kpi-data {
    display: flex;
    flex-direction: column;
}

.kpi-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.kpi-value {
    font-size: 1.35rem;
    font-weight: 800;
    margin: 0.1rem 0;
}

.kpi-sub {
    font-size: 0.68rem;
    color: var(--text-dark);
}

.text-blue { color: #38bdf8; }
.text-purple { color: #c084fc; }
.text-indigo { color: #818cf8; }
.text-cyan { color: #22d3ee; }
.text-green { color: #4ade80; }
.text-teal { color: #2dd4bf; }
.text-amber { color: #fbbf24; }
.text-emerald { color: #34d399; }

/* Seção de Gráficos (Expandido para 100% de Largura) */
.charts-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.chart-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.chart-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.chart-header p {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.chart-wrapper {
    position: relative;
    width: 100%;
    min-height: 380px;
}

/* Tabela de Campanhas */
.campaigns-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.table-header h3 {
    font-size: 1rem;
    font-weight: 700;
}

.table-header p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.table-filters {
    display: flex;
    gap: 0.5rem;
}

.search-input {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 0.4rem 0.75rem;
    color: #fff;
    font-size: 0.8rem;
    outline: none;
    width: 220px;
}

.filter-select {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 0.4rem 0.75rem;
    color: #fff;
    font-size: 0.8rem;
    outline: none;
}

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

.campaigns-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    text-align: left;
}

.campaigns-table th {
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-muted);
    font-weight: 700;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--card-border);
    text-transform: uppercase;
    font-size: 0.7rem;
}

.campaigns-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.campaigns-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.badge-status {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    display: inline-block;
}

.badge-status.active {
    background: rgba(16, 185, 129, 0.15);
    color: #4ade80;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-status.paused {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Utilidades */
.hidden { display: none !important; }

.channel-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 0.35rem 0.75rem;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.channel-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.channel-btn.active {
    background: var(--primary);
    border-color: var(--primary-light);
    color: #fff;
}

.info-tooltip-trigger {
    font-size: 0.7rem;
    color: var(--primary-light);
    cursor: pointer;
    margin-left: 4px;
    display: inline-block;
    transition: transform 0.2s ease;
}

.info-tooltip-trigger:hover {
    transform: scale(1.25);
}

.portal-toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #0284c7;
    color: #fff;
    padding: 0.85rem 1.25rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    animation: slideUp 0.3s ease;
}

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

/* ESTILIZAÇÃO PARA IMPRESSÃO / GERAÇÃO DE PDF Executivo */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }
    .portal-header, .period-controls, .export-buttons, .channel-filters, .table-filters, #btn-refresh-metrics, .btn-logout, #modal-admin-auth {
        display: none !important;
    }
    .card, .kpi-card-portal, .chart-card {
        background: #ffffff !important;
        border: 1px solid #e2e8f0 !important;
        color: #000000 !important;
        box-shadow: none !important;
    }
    .kpi-value, .kpi-label, .kpi-sub, h2, h3, p, td, th {
        color: #000000 !important;
    }
    .campaigns-table th {
        background: #f1f5f9 !important;
    }
}
