/*
   Hindoong Analytics Dashboard v2.0
*/

#adminDashboard {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 20000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
    animation: dashFadeIn 0.35s ease;
}

@keyframes dashFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideUp {
    from { transform: translateY(30px) scale(0.98); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.dash-overlay {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    background: #0a0a0f;
    color: #e8e6e3;
    padding: 24px 16px 48px;
}

.dash-container {
    max-width: 1280px;
    margin: 0 auto;
}

.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.25);
}

.dash-eyebrow {
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #d4af37;
    margin: 0 0 8px;
}

.dash-title {
    font-size: clamp(24px, 4vw, 32px);
    font-weight: 700;
    margin: 0 0 8px;
    color: #fff;
}

.dash-subtitle {
    margin: 0;
    font-size: 14px;
    color: #9a958c;
}

.dash-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.dash-refresh {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #c8c4bc;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.dash-refresh:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #e8e6e3;
    border-color: rgba(255, 255, 255, 0.2);
}

.dash-refresh.spinning .dash-refresh-icon {
    animation: dashSpin 0.7s linear infinite;
}

@keyframes dashSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.dash-close {
    flex-shrink: 0;
    background: transparent;
    border: 1px solid rgba(212, 175, 55, 0.5);
    color: #d4af37;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s, color 0.2s;
}

.dash-close:hover {
    background: #d4af37;
    color: #0a0a0f;
}

.dash-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.dash-kpi {
    background: linear-gradient(145deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    padding: 18px 20px;
}

.dash-kpi-label {
    display: block;
    font-size: 12px;
    color: #9a958c;
    margin-bottom: 8px;
}

.dash-kpi-value {
    font-size: clamp(24px, 4vw, 32px);
    font-weight: 700;
    color: #fff;
    font-variant-numeric: tabular-nums;
}

.dash-kpi-scope {
    font-size: 10px;
    color: #6b6760;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.dash-kpi-delta {
    display: block;
    margin-top: 6px;
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.dash-kpi-delta.up { color: #8BA888; }
.dash-kpi-delta.down { color: #C4897A; }
.dash-kpi-delta.neutral { color: #6b6760; }

.dash-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.dash-tab {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    color: #9a958c;
    padding: 10px 16px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.dash-tab:hover {
    color: #e8e6e3;
    border-color: rgba(212, 175, 55, 0.3);
}

.dash-tab.active {
    background: rgba(212, 175, 55, 0.15);
    border-color: #d4af37;
    color: #d4af37;
    font-weight: 600;
}

.dash-panels {
    min-height: 320px;
}

.dash-panel {
    display: none;
}

.dash-panel.active {
    display: block;
}

.dash-split {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.dash-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 20px;
}

.dash-card-full {
    padding: 0;
    overflow: hidden;
}

.dash-card h3 {
    margin: 0 0 16px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
}

/* Trend hero */
.dash-trend-hero {
    margin-bottom: 16px;
    padding: 24px;
    background: linear-gradient(160deg, rgba(126, 168, 168, 0.08), rgba(255, 255, 255, 0.02));
    border-color: rgba(126, 168, 168, 0.18);
}

.dash-trend-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
}

.dash-trend-head h3 {
    margin: 0 0 4px;
}

.dash-trend-sub {
    margin: 0;
    font-size: 12px;
    color: #7a756c;
}

.dash-period-toggle {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: rgba(0, 0, 0, 0.28);
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.dash-period-btn {
    background: transparent;
    border: none;
    color: #8a857c;
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.dash-period-btn:hover {
    color: #d8d4cc;
}

.dash-period-btn.active {
    background: rgba(126, 168, 168, 0.22);
    color: #b8d8d8;
    box-shadow: inset 0 0 0 1px rgba(126, 168, 168, 0.35);
}

.dash-trend-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.dash-trend-stat {
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 12px 14px;
}

.dash-trend-stat.up .dash-trend-stat-value { color: #8BA888; }
.dash-trend-stat.down .dash-trend-stat-value { color: #C4897A; }

.dash-trend-stat-label {
    display: block;
    font-size: 10px;
    color: #7a756c;
    margin-bottom: 4px;
    letter-spacing: 0.04em;
}

.dash-trend-stat-value {
    font-size: 15px;
    font-weight: 700;
    color: #f0eeea;
    font-variant-numeric: tabular-nums;
}

.dash-trend-chart-wrap {
    position: relative;
    height: 220px;
    margin-bottom: 12px;
}

.dash-trend-chart {
    width: 100%;
    height: 100%;
}

.dash-trend-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.dash-grid-line {
    stroke: rgba(255, 255, 255, 0.06);
    stroke-width: 1;
}

.dash-grid-label,
.dash-axis-label {
    fill: #6b6760;
    font-size: 10px;
}

.dash-trend-line.visits {
    fill: none;
    stroke: #8BBFBF;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.dash-trend-line.pageviews {
    fill: none;
    stroke: #C9A86C;
    stroke-width: 2;
    stroke-dasharray: 6 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.9;
}

.dash-trend-dot.visits {
    fill: #8BBFBF;
    stroke: #0a0a0f;
    stroke-width: 1.5;
}

.dash-trend-dot.pageviews {
    fill: #C9A86C;
    stroke: #0a0a0f;
    stroke-width: 1.5;
}

.dash-trend-hit {
    fill: transparent;
    cursor: crosshair;
}

.dash-trend-tooltip {
    display: none;
    position: absolute;
    bottom: 100%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    background: rgba(12, 12, 18, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 11px;
    color: #d8d4cc;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    z-index: 2;
}

.dash-trend-tooltip strong {
    display: block;
    color: #fff;
    margin-bottom: 4px;
    font-size: 12px;
}

.dash-trend-tooltip span {
    display: block;
    margin-top: 2px;
}

.dash-trend-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 12px;
    color: #9a958c;
}

.dash-trend-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.dash-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    display: inline-block;
}

.dash-legend-dot.visits { background: #8BBFBF; }
.dash-legend-dot.pageviews { background: #C9A86C; }

.dash-insights-row {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)) !important;
    margin-bottom: 16px;
}

.dash-card-desc {
    margin: -8px 0 14px;
    font-size: 11px;
    color: #7a756c;
}

.dash-funnel {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dash-funnel-step {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dash-funnel-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #c8c4bc;
}

.dash-funnel-meta strong {
    color: #fff;
    font-variant-numeric: tabular-nums;
}

.dash-funnel-bar {
    height: 10px;
    border-radius: 999px;
    min-width: 8%;
    transition: width 0.4s ease;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}

.dash-funnel-bar.full {
    width: 100%;
}

.dash-funnel-arrow {
    text-align: center;
    font-size: 11px;
    color: #7B9BB8;
    font-weight: 600;
    padding: 2px 0;
}

/* Pie Chart Layout Extensions */
.dash-charts-row {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
}

.dash-pie-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 10px 0;
}

.dash-pie-chart {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(255, 255, 255, 0.05);
    position: relative;
}

.dash-pie-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.dash-pie-legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
}

.dash-pie-dot {
    width: 9px;
    height: 9px;
    border-radius: 3px;
    flex-shrink: 0;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
}

.dash-pie-label {
    flex: 1;
    color: #9a958c;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dash-pie-pct {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

@media (min-width: 1024px) {
    .dash-pie-wrapper {
        flex-direction: row;
        justify-content: space-around;
        padding: 10px 10px;
    }
    .dash-pie-legend {
        max-width: 140px;
    }
}

.dash-card-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 0;
}

.dash-card-head h3 {
    margin: 0;
}

.dash-search {
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    color: #fff;
    padding: 8px 12px;
    font-size: 13px;
    min-width: 200px;
}

.dash-search:focus {
    outline: none;
    border-color: #d4af37;
}

.dash-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dash-bar-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dash-bar-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    font-size: 13px;
}

.dash-bar-label {
    color: #e8e6e3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 70%;
}

.dash-bar-count {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.dash-bar-count small {
    color: #9a958c;
    font-weight: 400;
}

.dash-bar-track {
    height: 8px;
    background: rgba(255,255,255,0.06);
    border-radius: 4px;
    overflow: hidden;
}

.dash-bar-fill {
    height: 100%;
    border-radius: 4px;
    min-width: 2%;
    transition: width 0.4s ease;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
}

.dash-table-wrap {
    overflow-x: auto;
    padding: 0 0 8px;
}

.dash-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.dash-table thead {
    background: rgba(0,0,0,0.25);
}

.dash-table th {
    text-align: left;
    padding: 12px 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9a958c;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.dash-table th:hover {
    color: #d4af37;
}

.dash-table th.num,
.dash-table td.num {
    text-align: right;
}

.dash-table td {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,0.06);
    vertical-align: middle;
}

.dash-table tbody tr:hover {
    background: rgba(212, 175, 55, 0.05);
}

.dash-path {
    font-family: "SF Mono", "Consolas", monospace;
    font-size: 12px;
    color: #9a958c;
    background: rgba(0,0,0,0.3);
    padding: 2px 6px;
    border-radius: 4px;
}

.dash-badge {
    display: inline-block;
    background: rgba(212, 175, 55, 0.12);
    color: #d4af37;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
}

.dash-empty,
.dash-empty-cell {
    color: #6b6760;
    font-size: 13px;
    text-align: center;
    padding: 24px;
}

.dash-footer {
    margin-top: 28px;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #6b6760;
}

@media (max-width: 640px) {
    .dash-header {
        flex-direction: column;
    }

    .dash-header-actions {
        align-self: flex-end;
    }

    .dash-card-head {
        flex-direction: column;
        align-items: stretch;
    }

    .dash-search {
        width: 100%;
    }

    .dash-table th,
    .dash-table td {
        padding: 10px 12px;
    }
}
