/* =========================================================
   XERION — ANALYTICS
   ---------------------------------------------------------
   Clean analytics dashboard
   White / light XERION interface
========================================================= */


/* =========================================================
   PAGE
========================================================= */

.analytics-page {
    width: 100%;
    max-width: 1400px;

    margin: 0 auto;

    padding: 32px 34px 50px;
}


/* =========================================================
   HEADER
========================================================= */

.analytics-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;

    gap: 24px;

    margin-bottom: 28px;
}

.analytics-header-content {
    min-width: 0;
}

.analytics-header h1 {
    margin: 0;

    color: var(--black);

    font-size: 27px;
    font-weight: 700;

    line-height: 1.15;
    letter-spacing: -0.04em;
}

.analytics-header p {
    margin: 7px 0 0;

    color: var(--muted);

    font-size: 13px;
    line-height: 1.5;
}


/* =========================================================
   PERIOD SELECTOR
========================================================= */

.analytics-period {
    display: flex;
    align-items: center;

    gap: 4px;

    padding: 4px;

    border: 1px solid var(--border);
    border-radius: 10px;

    background: var(--surface-soft);

    flex-shrink: 0;
}

.analytics-period-button {
    min-height: 32px;

    padding: 0 11px;

    border: 0;
    border-radius: 7px;

    background: transparent;
    color: var(--muted);

    font-family: inherit;
    font-size: 11px;
    font-weight: 600;

    cursor: pointer;

    transition:
        background var(--transition),
        color var(--transition),
        box-shadow var(--transition);
}

.analytics-period-button:hover {
    background: var(--surface);

    color: var(--text);
}

.analytics-period-button.is-active {
    background: var(--surface);

    color: var(--blue);

    box-shadow:
        0 1px 3px rgba(15, 23, 42, 0.08);
}

.analytics-period-button:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}


/* =========================================================
   OVERVIEW
========================================================= */

.analytics-overview {
    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 12px;

    margin-bottom: 18px;
}


/* =========================================================
   STAT CARD
========================================================= */

.analytics-stat-card {
    min-width: 0;
    min-height: 132px;

    display: flex;
    flex-direction: column;
    justify-content: space-between;

    padding: 18px;

    border: 1px solid var(--border);
    border-radius: var(--radius);

    background: var(--surface);

    box-shadow:
        0 3px 12px rgba(15, 23, 42, 0.035);

    transition:
        border-color var(--transition),
        box-shadow var(--transition),
        transform var(--transition);
}

.analytics-stat-card:hover {
    border-color: var(--border-strong);

    box-shadow:
        0 6px 18px rgba(15, 23, 42, 0.055);

    transform: translateY(-1px);
}

.analytics-stat-top {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 12px;
}

.analytics-stat-label {
    min-width: 0;

    color: var(--muted);

    font-size: 10px;
    font-weight: 650;

    line-height: 1.3;

    letter-spacing: 0.04em;
}

.analytics-stat-icon {
    width: 30px;
    height: 30px;

    display: flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    border: 1px solid var(--border);
    border-radius: 8px;

    background: var(--surface-soft);
    color: var(--blue);
}

.analytics-stat-icon svg {
    width: 15px;
    height: 15px;
}

.analytics-stat-value {
    margin-top: 17px;

    color: var(--black);

    font-size: 25px;
    font-weight: 700;

    line-height: 1;

    letter-spacing: -0.04em;
}

.analytics-stat-meta {
    display: flex;
    align-items: center;

    gap: 5px;

    margin-top: 7px;

    color: var(--muted);

    font-size: 9px;
    line-height: 1.3;
}

.analytics-stat-change {
    color: var(--success);

    font-weight: 650;
}

.analytics-stat-change.is-negative {
    color: var(--danger);
}


/* =========================================================
   MAIN GRID
========================================================= */

.analytics-grid {
    display: grid;

    grid-template-columns:
        minmax(0, 1.7fr)
        minmax(280px, 0.8fr);

    gap: 18px;
}


/* =========================================================
   PANEL
========================================================= */

.analytics-panel {
    min-width: 0;

    border: 1px solid var(--border);
    border-radius: var(--radius);

    background: var(--surface);

    box-shadow:
        0 3px 12px rgba(15, 23, 42, 0.035);

    overflow: hidden;
}

.analytics-panel-full {
    grid-column: 1 / -1;
}

.analytics-panel-header {
    min-height: 64px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 15px;

    padding: 0 19px;

    border-bottom: 1px solid var(--border);
}

.analytics-panel-heading {
    min-width: 0;
}

.analytics-panel-title {
    margin: 0;

    color: var(--text);

    font-size: 13px;
    font-weight: 650;

    line-height: 1.3;
}

.analytics-panel-description {
    margin: 4px 0 0;

    color: var(--muted);

    font-size: 9px;
    line-height: 1.4;
}

.analytics-panel-action {
    flex-shrink: 0;

    padding: 4px 0;

    border: 0;

    background: transparent;
    color: var(--blue);

    font-family: inherit;
    font-size: 10px;
    font-weight: 600;

    white-space: nowrap;

    cursor: pointer;
}

.analytics-panel-action:hover {
    text-decoration: underline;
}

.analytics-panel-action:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 3px;
}

.analytics-panel-body {
    min-width: 0;

    padding: 20px;
}


/* =========================================================
   ACTIVITY CHART AREA
========================================================= */

.analytics-chart-area {
    position: relative;

    width: 100%;
    min-height: 270px;

    padding-left: 36px;
}

.analytics-chart-grid {
    position: absolute;

    top: 10px;
    right: 0;
    bottom: 30px;
    left: 36px;

    display: flex;
    flex-direction: column;
    justify-content: space-between;

    pointer-events: none;
}

.analytics-chart-grid-line {
    width: 100%;

    border-top: 1px dashed var(--border);
}

.analytics-chart-values {
    position: absolute;

    top: 10px;
    bottom: 30px;
    left: 0;

    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.analytics-chart-value {
    color: var(--muted-light);

    font-size: 8px;
    line-height: 1;
}


/* =========================================================
   BAR CHART
========================================================= */

.analytics-chart {
    position: relative;

    width: 100%;
    min-height: 270px;

    display: flex;
    align-items: flex-end;

    gap: 12px;

    padding: 10px 5px 0;
}

.analytics-chart-column {
    flex: 1;

    min-width: 0;
    height: 230px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;

    gap: 8px;
}

.analytics-chart-bar-wrapper {
    width: 100%;
    max-width: 38px;

    height: 205px;

    display: flex;
    align-items: flex-end;
    justify-content: center;

    border-bottom: 1px solid var(--border);
}

.analytics-chart-bar {
    width: 100%;

    min-height: 3px;

    border-radius: 6px 6px 2px 2px;

    background: var(--blue);

    transition:
        opacity var(--transition),
        transform var(--transition);
}

.analytics-chart-bar:hover {
    opacity: 0.82;

    transform: translateY(-2px);
}

.analytics-chart-label {
    max-width: 100%;

    overflow: hidden;

    color: var(--muted-light);

    font-size: 9px;
    font-weight: 500;

    white-space: nowrap;
    text-overflow: ellipsis;
}


/* =========================================================
   LINE / ACTIVITY CHART
========================================================= */

.analytics-activity-chart {
    position: relative;

    width: 100%;
    height: 230px;
}

.analytics-activity-svg {
    width: 100%;
    height: 100%;

    display: block;

    overflow: visible;
}

.analytics-activity-line {
    fill: none;

    stroke: var(--blue);

    stroke-width: 2.5;

    stroke-linecap: round;
    stroke-linejoin: round;
}

.analytics-activity-area {
    fill: rgba(49, 88, 168, 0.07);

    stroke: none;
}

.analytics-activity-point {
    fill: var(--white);

    stroke: var(--blue);

    stroke-width: 2;
}


/* =========================================================
   LEGEND
========================================================= */

.analytics-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;

    gap: 16px;

    margin-top: 14px;
}

.analytics-legend-item {
    display: flex;
    align-items: center;

    gap: 6px;

    color: var(--muted);

    font-size: 9px;
    line-height: 1.3;
}

.analytics-legend-dot {
    width: 7px;
    height: 7px;

    flex-shrink: 0;

    border-radius: 50%;

    background: var(--blue);
}


/* =========================================================
   BREAKDOWN
========================================================= */

.analytics-breakdown {
    display: flex;
    flex-direction: column;

    gap: 15px;
}

.analytics-breakdown-item {
    display: flex;
    flex-direction: column;

    gap: 7px;
}

.analytics-breakdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 10px;
}

.analytics-breakdown-name {
    min-width: 0;

    overflow: hidden;

    color: var(--text-soft);

    font-size: 10px;
    font-weight: 600;

    white-space: nowrap;
    text-overflow: ellipsis;
}

.analytics-breakdown-value {
    flex-shrink: 0;

    color: var(--text);

    font-size: 10px;
    font-weight: 650;
}

.analytics-breakdown-track {
    width: 100%;
    height: 6px;

    border-radius: 999px;

    background: var(--surface-soft);

    overflow: hidden;
}

.analytics-breakdown-fill {
    width: 0;
    height: 100%;

    border-radius: inherit;

    background: var(--blue);

    transition: width 400ms ease;
}


/* =========================================================
   INSIGHT
========================================================= */

.analytics-insight {
    display: flex;
    align-items: flex-start;

    gap: 12px;

    padding: 15px;

    border: 1px solid var(--border);
    border-radius: 10px;

    background: var(--surface-soft);
}

.analytics-insight-icon {
    width: 30px;
    height: 30px;

    display: flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    border-radius: 8px;

    background: var(--blue-light);
    color: var(--blue);
}

.analytics-insight-icon svg {
    width: 15px;
    height: 15px;
}

.analytics-insight-content {
    min-width: 0;
}

.analytics-insight-title {
    margin: 0;

    color: var(--text);

    font-size: 11px;
    font-weight: 650;

    line-height: 1.3;
}

.analytics-insight-text {
    margin: 4px 0 0;

    color: var(--muted);

    font-size: 9px;
    line-height: 1.55;
}


/* =========================================================
   RECENT ACTIVITY
========================================================= */

.analytics-recent-list {
    display: flex;
    flex-direction: column;
}

.analytics-recent-item {
    min-height: 57px;

    display: flex;
    align-items: center;

    gap: 12px;

    border-bottom: 1px solid var(--border);
}

.analytics-recent-item:last-child {
    border-bottom: 0;
}

.analytics-recent-icon {
    width: 30px;
    height: 30px;

    display: flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    border: 1px solid var(--border);
    border-radius: 8px;

    background: var(--surface-soft);
    color: var(--muted);
}

.analytics-recent-icon svg {
    width: 14px;
    height: 14px;
}

.analytics-recent-content {
    min-width: 0;

    flex: 1;
}

.analytics-recent-title {
    overflow: hidden;

    color: var(--text);

    font-size: 10px;
    font-weight: 600;

    line-height: 1.35;

    white-space: nowrap;
    text-overflow: ellipsis;
}

.analytics-recent-meta {
    margin-top: 3px;

    color: var(--muted-light);

    font-size: 8px;
    line-height: 1.3;
}

.analytics-recent-value {
    flex-shrink: 0;

    color: var(--text-soft);

    font-size: 9px;
    font-weight: 650;

    white-space: nowrap;
}


/* =========================================================
   EMPTY STATE
========================================================= */

.analytics-empty {
    min-height: 220px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    padding: 30px;

    text-align: center;
}

.analytics-empty-icon {
    width: 42px;
    height: 42px;

    display: flex;
    align-items: center;
    justify-content: center;

    margin-bottom: 13px;

    border: 1px solid var(--border);
    border-radius: 11px;

    background: var(--surface-soft);
    color: var(--muted);
}

.analytics-empty-icon svg {
    width: 20px;
    height: 20px;
}

.analytics-empty-title {
    margin: 0;

    color: var(--text);

    font-size: 13px;
    font-weight: 650;

    line-height: 1.3;
}

.analytics-empty-text {
    max-width: 330px;

    margin: 6px 0 0;

    color: var(--muted);

    font-size: 10px;
    line-height: 1.5;
}


/* =========================================================
   LOADING
========================================================= */

.analytics-loading {
    position: relative;

    overflow: hidden;
}

.analytics-loading::after {
    content: "";

    position: absolute;

    inset: 0;

    background:
        linear-gradient(
            90deg,
            transparent,
            rgba(255, 255, 255, 0.55),
            transparent
        );

    transform: translateX(-100%);

    animation:
        analytics-loading 1.3s infinite;

    pointer-events: none;
}

@keyframes analytics-loading {

    to {
        transform: translateX(100%);
    }

}


/* =========================================================
   ERROR
========================================================= */

.analytics-error {
    width: 100%;

    padding: 14px 16px;

    border: 1px solid #ead2d2;
    border-radius: 10px;

    background: #fff8f8;
    color: var(--danger);

    font-size: 10px;
    line-height: 1.5;
}


/* =========================================================
   RESPONSIVE — LARGE TABLET
========================================================= */

@media (max-width: 1100px) {

    .analytics-overview {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .analytics-grid {
        grid-template-columns: 1fr;
    }

}


/* =========================================================
   RESPONSIVE — TABLET
========================================================= */

@media (max-width: 800px) {

    .analytics-page {
        padding: 26px 22px 42px;
    }

    .analytics-header {
        flex-direction: column;

        gap: 16px;
    }

    .analytics-period {
        align-self: flex-start;
    }

    .analytics-panel-header {
        min-height: 60px;
    }

    .analytics-chart {
        gap: 8px;
    }

}


/* =========================================================
   RESPONSIVE — MOBILE
========================================================= */

@media (max-width: 560px) {

    .analytics-page {
        padding: 22px 16px 35px;
    }

    .analytics-header {
        margin-bottom: 22px;
    }

    .analytics-header h1 {
        font-size: 24px;
    }

    .analytics-header p {
        font-size: 11px;
    }

    .analytics-overview {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        gap: 9px;
    }

    .analytics-stat-card {
        min-height: 112px;

        padding: 14px;
    }

    .analytics-stat-value {
        font-size: 22px;
    }

    .analytics-stat-icon {
        width: 27px;
        height: 27px;
    }

    .analytics-stat-icon svg {
        width: 14px;
        height: 14px;
    }

    .analytics-panel-header {
        padding: 0 15px;
    }

    .analytics-panel-body {
        padding: 15px;
    }

    .analytics-chart-area {
        min-height: 245px;

        padding-left: 27px;
    }

    .analytics-chart-grid {
        left: 27px;
    }

    .analytics-chart-values {
        left: -2px;
    }

    .analytics-chart {
        min-height: 245px;
    }

    .analytics-chart-column {
        height: 210px;
    }

    .analytics-chart-bar-wrapper {
        height: 185px;
    }

    .analytics-chart-label {
        font-size: 8px;
    }

    .analytics-legend {
        gap: 12px;
    }

    .analytics-recent-item {
        gap: 9px;
    }

}


/* =========================================================
   RESPONSIVE — SMALL MOBILE
========================================================= */

@media (max-width: 380px) {

    .analytics-overview {
        grid-template-columns: 1fr;
    }

    .analytics-stat-card {
        min-height: 100px;
    }

    .analytics-period {
        width: 100%;
    }

    .analytics-period-button {
        flex: 1;

        padding-left: 7px;
        padding-right: 7px;
    }

    .analytics-panel-header {
        align-items: flex-start;

        padding-top: 15px;
        padding-bottom: 15px;
    }

    .analytics-panel-action {
        font-size: 9px;
    }

}


/* =========================================================
   REDUCED MOTION
========================================================= */

@media (prefers-reduced-motion: reduce) {

    .analytics-stat-card,
    .analytics-chart-bar,
    .analytics-breakdown-fill,
    .analytics-period-button {
        transition: none;
    }

    .analytics-loading::after {
        animation: none;
    }

}