/* ===== Social Listening Individual — Ricardo Estigarribia 🇵🇾 ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* --- CSS Variables --- */
:root {
    --brand-purple: #472F69;
    --brand-purple-light: #5E4087;
    --brand-purple-dark: #2D1B4E;
    --brand-mint: #2BFDB4;
    --brand-mint-dark: #1AD99A;
    --brand-purple-10: rgba(71, 47, 105, 0.10);
    --brand-purple-06: rgba(71, 47, 105, 0.06);
    --accent-blue: #3B82F6;
    --accent-indigo: #6366F1;
    --bg-primary: #F8F7FB;
    --bg-secondary: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F7F5FA;
    --border: #E8E4EF;
    --border-light: #D4CDE0;
    --text-primary: #1A1128;
    --text-secondary: #4A3F5C;
    --text-muted: #8E83A0;
    --positive: #059669;
    --positive-bg: #ECFDF5;
    --negative: #DC2626;
    --negative-bg: #FEF2F2;
    --neutral-color: #6366F1;
    --neutral-bg: #EEF2FF;
    --warning: #D97706;
    --warning-bg: #FFFBEB;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 4px;
    --shadow: 0 1px 3px rgba(71, 47, 105, 0.06), 0 1px 2px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 4px 12px rgba(71, 47, 105, 0.08), 0 2px 4px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 8px 24px rgba(71, 47, 105, 0.12), 0 2px 4px rgba(0, 0, 0, 0.03);
    --shadow-glow: 0 0 20px rgba(43, 253, 180, 0.15);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { scroll-behavior: smooth; font-size: 15px; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #F3F0F7; }
::-webkit-scrollbar-thumb { background: #C4BAD4; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--brand-purple); }

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

/* --- Header --- */
.header {
    background: linear-gradient(135deg, var(--brand-purple-dark) 0%, var(--brand-purple) 50%, var(--brand-purple-light) 100%);
    border-radius: var(--radius);
    padding: 36px 44px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
    color: white;
    box-shadow: 0 8px 32px rgba(71, 47, 105, 0.35);
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(43, 253, 180, 0.15), transparent 70%);
    animation: pulse-glow 4s ease-in-out infinite;
}

.header::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: 10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.1), transparent 70%);
}

@keyframes pulse-glow {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.1); opacity: 1; }
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 20px;
    position: relative;
    z-index: 1;
}

.header h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 6px;
    color: white;
}

.header h1 span { color: var(--brand-mint); }

.header-subtitle {
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.92rem;
    font-weight: 400;
}

.header-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

.header-meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    transition: var(--transition);
}

.header-meta-item:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-1px);
}

.header-meta-item strong { color: white; }

.header-actions {
    position: relative;
    z-index: 1;
}

/* --- Navigation --- */
.nav {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    margin-bottom: 24px;
    position: sticky;
    top: 8px;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(12px);
}

.nav-btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    position: relative;
}

.nav-btn:hover {
    background: var(--brand-purple-06);
    color: var(--brand-purple);
}

.nav-btn.active {
    background: var(--brand-purple);
    color: white;
    box-shadow: 0 2px 12px rgba(71, 47, 105, 0.4);
    transform: translateY(-1px);
}

/* --- Sections --- */
.section {
    display: none;
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.section.active { display: block; }

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

.section-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 24px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--brand-purple-10);
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
}

.section-title .icon { font-size: 1.4rem; }

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 16px;
}

/* --- Grid layouts --- */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 24px; }
.grid-1 { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 24px; }

/* --- KPI Cards --- */
.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--brand-purple), var(--brand-mint));
}

.kpi-card .kpi-icon {
    font-size: 2rem;
    margin-bottom: 12px;
    display: block;
}

.kpi-card .kpi-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.kpi-card .kpi-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.kpi-card .kpi-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.kpi-card .kpi-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    margin-top: 8px;
}

.kpi-change.positive { background: var(--positive-bg); color: var(--positive); }
.kpi-change.negative { background: var(--negative-bg); color: var(--negative); }

/* --- Source Badge --- */
.source-badge {
    display: inline-flex;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    background: var(--brand-purple-06);
    color: var(--brand-purple);
    margin-bottom: 12px;
}

/* --- Charts --- */
.chart-container { position: relative; width: 100%; }
.chart-container.large { height: 420px; }
.chart-container.medium { height: 350px; }
.chart-container.small { height: 260px; }
.chart-container canvas { max-width: 100%; }

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

.data-table thead th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.7rem;
    border-bottom: 2px solid var(--border);
    background: #F7F5FA;
}

.data-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #F1F5F9;
    color: var(--text-secondary);
}

.data-table tbody tr { transition: var(--transition); }
.data-table tbody tr:hover { background: var(--bg-card-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* --- Tags / Badges --- */
.badge {
    display: inline-flex;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge.positive-badge { background: var(--positive-bg); color: var(--positive); }
.badge.negative-badge { background: var(--negative-bg); color: var(--negative); }
.badge.neutral-badge { background: var(--neutral-bg); color: var(--neutral-color); }
.badge.primary-badge { background: var(--brand-purple-06); color: var(--brand-purple); }

/* --- Word Cloud --- */
#wordcloud-canvas {
    width: 100%;
    height: 360px;
    background: linear-gradient(135deg, #F7F5FA, #F0EDF5);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* --- Narrative / Feed Items --- */
.feed-item {
    background: #F8FAFC;
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    margin-bottom: 10px;
    border-left: 4px solid var(--brand-purple);
    font-size: 0.84rem;
    line-height: 1.6;
    color: var(--text-secondary);
    transition: var(--transition);
}

.feed-item:hover {
    background: #F0EDF5;
    border-left-color: var(--brand-mint-dark);
    transform: translateX(4px);
}

.feed-item .feed-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 6px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

/* --- Emotion Grid --- */
.emotion-card {
    text-align: center;
    padding: 20px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.emotion-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.emotion-card .emoji { font-size: 2.2rem; margin-bottom: 8px; display: block; }
.emotion-card .emotion-name { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.emotion-card .emotion-count { font-size: 1.4rem; font-weight: 800; color: var(--text-primary); }

/* --- Tema items --- */
.tema-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #F1F5F9;
}

.tema-item:last-child { border-bottom: none; }

.tema-item .tema-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    text-transform: capitalize;
}

.tema-item .tema-bar {
    flex: 1;
    margin: 0 16px;
    height: 6px;
    background: #F1F5F9;
    border-radius: 3px;
    overflow: hidden;
}

.tema-item .tema-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--brand-purple), var(--accent-indigo));
    transition: width 1s ease;
}

.tema-item .tema-count {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 60px;
    text-align: right;
}

/* --- Author Cards --- */
.author-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid #F1F5F9;
    transition: var(--transition);
}

.author-row:hover { background: var(--bg-card-hover); margin: 0 -16px; padding: 14px 16px; border-radius: var(--radius-sm); }
.author-row:last-child { border-bottom: none; }

.author-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid var(--border);
    object-fit: cover;
    flex-shrink: 0;
}

.author-info { flex: 1; }
.author-name { font-weight: 600; font-size: 0.88rem; color: var(--text-primary); }
.author-handle { font-size: 0.75rem; color: var(--text-muted); }
.author-stats { font-size: 0.75rem; color: var(--text-secondary); display: flex; gap: 16px; margin-top: 4px; }

/* --- Conclusion / Insight boxes --- */
.insight-box {
    background: linear-gradient(135deg, rgba(71, 47, 105, 0.04), rgba(99, 102, 241, 0.04));
    border: 1px solid rgba(71, 47, 105, 0.12);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
}

.insight-box h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--brand-purple);
    display: flex;
    align-items: center;
    gap: 8px;
}

.insight-box ul { padding-left: 20px; }

.insight-box li {
    margin-bottom: 8px;
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.insight-box li strong { color: var(--text-primary); }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-purple), var(--brand-purple-light));
    color: white;
    box-shadow: 0 2px 8px rgba(71, 47, 105, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(71, 47, 105, 0.4);
}

/* --- Sentiment Gauge --- */
.sent-gauge {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin: 12px 0;
}

.sent-gauge .pos { background: var(--positive); }
.sent-gauge .neg { background: var(--negative); }
.sent-gauge .neu { background: var(--neutral-color); opacity: 0.5; }

/* --- Responsive --- */
@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .dashboard { padding: 12px; }
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .header { padding: 20px; }
    .header h1 { font-size: 1.4rem; }
    .nav { overflow-x: auto; flex-wrap: nowrap; }
    .chart-container { overflow-x: auto; }
}

/* --- Content card with engagement metrics --- */
.content-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
    position: relative;
}

.content-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.content-card .content-engagement {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.content-card .eng-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.content-card .eng-stat strong {
    color: var(--text-primary);
    font-weight: 700;
}

/* --- Animated counter --- */
@keyframes countUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-in { animation: countUp 0.6s ease forwards; }

/* --- Tooltip custom --- */
.custom-tooltip {
    background: white !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    box-shadow: var(--shadow-lg) !important;
}

/* --- Print / PDF --- */
@media print {
    .nav, .header-actions { display: none; }
    .section { display: block !important; page-break-after: always; }
    .card { break-inside: avoid; }
}
