/* admin-traffic.css — Traffic Source Attribution dashboard */
/* Uses theme variables from admin-styles.css for light/dark mode support */

#traffic-view { padding: 0; }
#traffic-view h1 { margin-bottom: 0.5rem; }

.traffic-loading, .traffic-error, .traffic-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary, #4B5563);
}
.traffic-error { color: var(--danger, #FF6F61); }

/* Toolbar */
.traffic-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.traffic-range {
    display: inline-flex;
    background: var(--card, #fff);
    border: 1px solid var(--border, rgba(0,0,0,0.1));
    border-radius: 8px;
    overflow: hidden;
}
.traffic-range-btn {
    background: transparent;
    color: var(--text-secondary, #4B5563);
    border: 0;
    padding: 0.5rem 1rem;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}
.traffic-range-btn:hover { color: var(--text, #1A2D33); background: rgba(0,0,0,0.04); }
.traffic-range-btn.active {
    background: var(--gold, #D4AF37);
    color: #003B46;
    font-weight: 600;
}

/* KPI strip */
.traffic-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.traffic-kpi {
    background: var(--card, #fff);
    border: 1px solid var(--border, rgba(0,0,0,0.1));
    border-radius: 12px;
    padding: 1rem 1.25rem;
    text-align: center;
}
.traffic-kpi-num {
    font-size: 2rem;
    font-weight: 600;
    color: var(--gold, #D4AF37);
    line-height: 1;
    font-family: 'Frank Ruhl Libre', serif;
}
.traffic-kpi-label {
    margin-top: 0.4rem;
    font-size: 0.78rem;
    color: var(--text-secondary, #4B5563);
}

/* Panels + rows */
.traffic-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}
.traffic-panel {
    background: var(--card, #fff);
    border: 1px solid var(--border, rgba(0,0,0,0.1));
    border-radius: 12px;
    padding: 1.25rem;
}
.traffic-panel h3 {
    margin: 0 0 1rem;
    color: var(--text, #1A2D33);
    font-family: 'Frank Ruhl Libre', serif;
    font-size: 1.05rem;
}
.traffic-hint {
    color: var(--text-secondary, #4B5563);
    font-size: 0.75rem;
    font-weight: normal;
    font-family: 'Heebo', sans-serif;
}

/* Bars */
.traffic-bars { display: flex; flex-direction: column; gap: 0.5rem; }
.traffic-bar-row {
    display: grid;
    grid-template-columns: 140px 1fr 90px;
    gap: 0.75rem;
    align-items: center;
}
.traffic-bar-label {
    font-size: 0.85rem;
    color: var(--text, #1A2D33);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: ltr;
    text-align: right;
}
.traffic-bar-track {
    height: 20px;
    background: rgba(0,59,70,0.08);
    border-radius: 4px;
    overflow: hidden;
}
.traffic-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--muted-teal, #00606B), var(--gold, #D4AF37));
    border-radius: 4px;
    transition: width 0.3s ease-out;
}
.traffic-bar-val {
    font-size: 0.78rem;
    color: var(--text-secondary, #4B5563);
    text-align: left;
    direction: ltr;
}

/* Funnel table */
.traffic-funnel-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.traffic-funnel-table th {
    text-align: right;
    padding: 0.6rem 0.75rem;
    background: rgba(0,59,70,0.06);
    color: var(--text-secondary, #4B5563);
    font-weight: 600;
    border-bottom: 1px solid var(--border, rgba(0,0,0,0.1));
}
.traffic-funnel-table td {
    text-align: right;
    padding: 0.6rem 0.75rem;
    color: var(--text, #1A2D33);
    border-bottom: 1px solid var(--border, rgba(0,0,0,0.06));
}
.traffic-funnel-table .pct { color: var(--text-secondary, #4B5563); font-size: 0.78rem; }
.traffic-funnel-table tbody tr:hover { background: rgba(212, 175, 55, 0.06); }

/* Device donut (list variant) */
.traffic-donut { display: flex; flex-direction: column; gap: 0.5rem; }
.traffic-donut-row {
    display: grid;
    grid-template-columns: 14px 100px 50px 50px;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border, rgba(0,0,0,0.06));
}
.traffic-donut-row .dot {
    width: 10px; height: 10px; border-radius: 50%;
}
.traffic-donut-row .dot.mobile  { background: var(--gold, #D4AF37); }
.traffic-donut-row .dot.desktop { background: var(--muted-teal, #00606B); }
.traffic-donut-row .dot.tablet  { background: #8B6914; }
.traffic-donut-row .label { color: var(--text, #1A2D33); font-size: 0.85rem; }
.traffic-donut-row .val { color: var(--gold, #D4AF37); font-weight: 600; }
.traffic-donut-row .count { color: var(--text-secondary, #4B5563); font-size: 0.78rem; direction: ltr; }

/* Geo list */
.traffic-geo-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 260px;
    overflow-y: auto;
}
.traffic-geo-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.5rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border, rgba(0,0,0,0.06));
    font-size: 0.88rem;
}
.traffic-geo-city { color: var(--text, #1A2D33); }
.traffic-geo-country { color: var(--text-secondary, #4B5563); font-size: 0.78rem; }
.traffic-geo-count {
    color: var(--gold, #D4AF37);
    font-weight: 600;
    min-width: 30px;
    text-align: left;
}

/* Recent rows table */
.traffic-recent-wrap { overflow-x: auto; }
.traffic-recent-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.traffic-recent-table th {
    text-align: right;
    padding: 0.6rem 0.75rem;
    background: rgba(0,59,70,0.06);
    color: var(--text-secondary, #4B5563);
    font-weight: 600;
    white-space: nowrap;
}
.traffic-recent-table td {
    padding: 0.55rem 0.75rem;
    color: var(--text, #1A2D33);
    border-bottom: 1px solid var(--border, rgba(0,0,0,0.06));
}
.traffic-tag {
    background: rgba(212, 175, 55, 0.12);
    color: var(--gold, #D4AF37);
    padding: 0.15rem 0.55rem;
    border-radius: 10px;
    font-size: 0.72rem;
    font-family: 'Courier New', monospace;
}

.traffic-footnote {
    margin-top: 2rem;
    padding: 1rem 1.25rem;
    background: rgba(212, 175, 55, 0.06);
    border: 1px dashed rgba(212, 175, 55, 0.3);
    border-radius: 8px;
    color: var(--text-secondary, #4B5563);
    font-size: 0.82rem;
    line-height: 1.5;
}
.traffic-footnote code {
    background: rgba(0,59,70,0.08);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    color: var(--gold, #D4AF37);
}

/* Source badge — shows medium (paid/organic) */
.traffic-source-medium {
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 6px;
    margin-right: 0.3rem;
    font-weight: 600;
}
.traffic-source-medium.paid { background: rgba(212,175,55,0.15); color: var(--gold, #D4AF37); }
.traffic-source-medium.organic { background: rgba(39,174,96,0.12); color: #27ae60; }
.traffic-source-medium.unknown { background: rgba(0,0,0,0.05); color: var(--text-secondary, #4B5563); }

@media (max-width: 900px) {
    .traffic-row { grid-template-columns: 1fr; }
    .traffic-bar-row { grid-template-columns: 100px 1fr 80px; }
}
