/* ==========================================================
   Automated Report Widget
   Standalone responsive card
   Uses variables.css tokens only
   ========================================================== */

.automated-report-widget {
    position: relative;
    display: flex;
    width: 100%;
    min-width: 0;
    flex-direction: column;
    padding: 28px 28px 0;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    background: var(--white);
    box-shadow: var(--shadow-sm);
    container-type: inline-size;
}

.automated-report-widget--compact {
    padding: 22px 22px 0;
}

/* ==========================================================
   Header
   ========================================================== */

.automated-report-widget__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.automated-report-widget__title-group {
    min-width: 0;
    padding-bottom: 16px;
}

.automated-report-widget__heading {
    max-width: 340px;
    margin: 0;
    color: var(--color-black);
    font-size: var(--font-size-2xl);
    font-weight: var(--font-lightbold);
    line-height: 1.3;
    letter-spacing: var(--letter-spacing-tight);
}

.automated-report-widget__heading span {
    display: block;
    margin-top: 6px;
    color: var(--color-gray);
    font-size: var(--font-size-lg);
    font-weight: normal;
    line-height: var(--line-height-body);
}

.automated-report-widget__product {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 12px;
    color: var(--green-dark);
    font-size: var(--base-font-size);
    text-decoration: none;
}

.automated-report-widget__product:hover {
    color: var(--green);
}

.automated-report-widget__product:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 3px;
}

.automated-report-widget__product i {
    width: 5px;
    height: 5px;
    margin-right: 5px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--green);
}

.automated-report-widget__open {
    display: inline-flex;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--light-dim-green);
    color: var(--green-dark);
    text-decoration: none;
    transition:
        background-color 180ms ease,
        color 180ms ease,
        transform 180ms ease;
}

.automated-report-widget__open:hover {
    background: var(--green);
    color: var(--white);
    transform: translate(2px, -2px);
}

.automated-report-widget__open:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 3px;
}

.automated-report-widget__open i,
.automated-report-widget__open svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

/* ==========================================================
   Report window
   ========================================================== */

.automated-report-widget__window {
    width: 100%;
    min-width: 0;
    min-height: 400px;
    margin-top: auto;
    margin-left: 20px;
    overflow: hidden;
    border-top: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
    border-left: 1px solid var(--color-border);
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--white);
    box-shadow: var(--shadow-lg);
}

.automated-report-widget--compact .automated-report-widget__window {
    width: calc(100% + 44px);
    margin-left: -22px;
}

/* ==========================================================
   Report preview
   ========================================================== */

.automated-report-widget__report {
    padding: 17px 16px 20px;
}

.automated-report-widget__report-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.automated-report-widget__report-header h4 {
    margin: 0;
    color: var(--color-black);
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-semibold);
    line-height: 1.3;
}

.automated-report-widget__report-header span {
    color: var(--color-light-gray);
    font-size: var(--font-sm);
    white-space: nowrap;
}

.automated-report-widget__approval-line {
    width: 100%;
    height: 1px;
    margin-top: 11px;
    background: var(--green);
}

/* ==========================================================
   Metrics and chart
   ========================================================== */

.automated-report-widget__report-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 82px;
    align-items: end;
    gap: 18px;
    margin-top: 13px;
}

.automated-report-widget__metrics {
    display: grid;
    gap: 7px;
}

.automated-report-widget__metric {
    display: block;
    width: var(--metric-width);
    height: 6px;
    border-radius: 999px;
    background: var(--color-border);
}

.automated-report-widget__chart {
    display: flex;
    height: 62px;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 6px;
}

.automated-report-widget__chart-bar {
    display: block;
    width: 11px;
    height: var(--chart-height);
    min-height: 8px;
    border-radius: 2px 2px 0 0;
    background: var(--color-border);
}

.automated-report-widget__chart-bar.is-active {
    background: var(--green);
}

/* ==========================================================
   Table preview
   ========================================================== */

.automated-report-widget__table {
    display: grid;
    gap: 8px;
    margin-top: 18px;
}

.automated-report-widget__table-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px 34px;
    gap: 8px;
}

.automated-report-widget__table-row span {
    display: block;
    height: 16px;
    border-radius: 3px;
    background: var(--color-border);
}

.automated-report-widget__table-main {
    min-width: 0;
}

.automated-report-widget__placeholder {
    margin-top: 20px;
    padding-top: 12px;
    border-top: 1px solid var(--color-border);
}

.automated-report-widget__placeholder h5 {
    margin: 0;
    color: var(--color-black);
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-semibold);
}

.automated-report-widget__placeholder-lines {
    display: grid;
    gap: 7px;
    margin-top: 10px;
}

.automated-report-widget__placeholder-lines span {
    display: block;
    height: 7px;
    border-radius: 999px;
    background: var(--color-border);
}

.automated-report-widget__placeholder-lines span:nth-child(1) {
    width: 92%;
}

.automated-report-widget__placeholder-lines span:nth-child(2) {
    width: 76%;
}

.automated-report-widget__placeholder-lines span:nth-child(3) {
    width: 84%;
}

/* ==========================================================
   Medium container
   ========================================================== */

@container (max-width: 500px) {
    .automated-report-widget {
        padding: 24px 24px 0;
    }

    .automated-report-widget__window {
        width: calc(100% + 48px);
        min-height: 360px;
        margin-left: -24px;
    }

}

/* ==========================================================
   Narrow container
   ========================================================== */

@container (max-width: 380px) {
    .automated-report-widget {
        padding: 20px 20px 0;
    }

    .automated-report-widget__heading {
        font-size: var(--font-size-xl);
    }

    .automated-report-widget__window {
        width: calc(100% + 40px);
        min-height: 320px;
        margin-left: -20px;
    }

    .automated-report-widget__report {
        padding-inline: 13px;
    }

    .automated-report-widget__report-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }

    .automated-report-widget__report-content {
        grid-template-columns: minmax(0, 1fr) 62px;
        gap: 12px;
    }

    .automated-report-widget__chart {
        gap: 4px;
    }

    .automated-report-widget__chart-bar {
        width: 8px;
    }

    .automated-report-widget__table-row {
        grid-template-columns: minmax(0, 1fr) 34px 26px;
        gap: 6px;
    }
}

/* ==========================================================
   Mobile viewport fallback
   ========================================================== */

@media (max-width: 520px) {
    .automated-report-widget__open {
        width: 26px;
        height: 26px;
    }
}

/* ==========================================================
   Reduced motion
   ========================================================== */

@media (prefers-reduced-motion: reduce) {
    .automated-report-widget__product {
        transition: none;
    }
}