/**
 * ERP Dashboard v2 — Premium widget styles (mockup-accurate)
 */

/* ── KPI Cards ── */
.erp-kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
    align-items: stretch;
}

.erp-kpi {
    background: #fff;
    border: 1px solid #E8ECF1;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    display: flex;
    flex-direction: column;
    min-height: 132px;
    position: relative;
    overflow: hidden;
}

.erp-kpi__row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.erp-kpi__icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.erp-kpi__icon--green { background: #DCFCE7; color: #16A34A; }
.erp-kpi__icon--blue { background: #DBEAFE; color: #2563EB; }
.erp-kpi__icon--orange { background: #FFEDD5; color: #EA580C; }
.erp-kpi__icon--purple { background: #EDE9FE; color: #7C3AED; }
.erp-kpi__icon--red { background: #FEE2E2; color: #DC2626; }

.erp-kpi__trend {
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 0;
}

.erp-kpi__trend--up { color: #16A34A; }
.erp-kpi__trend--down { color: #DC2626; }

.erp-kpi__label {
    font-size: 13px;
    color: #6B7280;
    margin: 14px 0 6px;
    font-weight: 500;
}

.erp-kpi__bottom {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-top: auto;
}

.erp-kpi__value {
    font-size: 26px;
    font-weight: 700;
    color: #111827;
    line-height: 1.1;
    margin: 0;
    letter-spacing: -0.02em;
}

.erp-kpi__sparkline {
    width: 72px;
    height: 32px;
    flex-shrink: 0;
    opacity: 0.9;
}

.erp-kpi__sparkline path {
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.erp-kpi__sparkline--green path { stroke: #16A34A; }
.erp-kpi__sparkline--blue path { stroke: #2563EB; }
.erp-kpi__sparkline--orange path { stroke: #EA580C; }
.erp-kpi__sparkline--purple path { stroke: #7C3AED; }
.erp-kpi__sparkline--red path { stroke: #DC2626; }

/* ── Dashboard rows ── */
.erp-dash-row {
    display: grid;
    gap: 20px;
    margin-bottom: 20px;
    align-items: stretch;
}

.erp-dash-row--2-1-1 {
    grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr) minmax(0, 1fr);
    align-items: stretch;
}

.erp-dash-row--2-1-1 .erp-dash-widget {
    min-height: 0;
    height: auto;
    padding: 14px 16px;
}

.erp-dash-row--2-1-1 .erp-dash-widget__body {
    flex: 0 1 auto;
}

.erp-dash-row--2-1-1 .erp-dash-widget__head {
    margin-bottom: 10px;
}

/* Row 3: equal-height cards (match Quick Actions) */
.erp-dash-row--row3.erp-dash-row--2-1-1 .erp-dash-widget {
    height: 100%;
}

.erp-dash-row--row3.erp-dash-row--2-1-1 .erp-dash-widget__body {
    flex: 1;
}

.erp-dash-row--row3 .erp-quick-grid {
    height: 100%;
}

.erp-dash-widget--sales {
    min-height: 0;
}

.erp-dash-widget {
    background: #fff;
    border: 1px solid #E8ECF1;
    border-radius: 16px;
    padding: 20px 22px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.erp-dash-widget__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    flex-shrink: 0;
}

.erp-dash-widget__title {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    margin: 0;
    line-height: 1.3;
}

.erp-dash-widget__sub {
    font-size: 12px;
    color: #9CA3AF;
    margin: 2px 0 0;
}

.erp-dash-widget__action select,
.erp-dash-widget__link {
    font-size: 12px;
    font-weight: 500;
    color: #2563EB;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.erp-dash-widget__link:hover {
    text-decoration: underline;
    color: #1D4ED8;
}

.erp-dash-widget__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.erp-dash-widget__foot {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #F3F4F6;
    text-align: center;
    flex-shrink: 0;
}

/* ── Sales chart ── */
.erp-sales-chart-wrap {
    flex: 0 0 auto;
    height: 170px;
    min-height: 0;
    position: relative;
}

.erp-sales-chart-wrap .highcharts-container,
.erp-sales-chart-wrap > div {
    width: 100% !important;
}

/* ── Order status donut + legend (mockup) ── */
.erp-dash-widget--status {
    overflow: hidden;
}

.erp-dash-widget--status .erp-dash-widget__body {
    padding-top: 0;
    overflow: hidden;
    flex: 1;
    min-height: 170px;
    justify-content: center;
}

.erp-status-select {
    height: 32px;
    padding: 0 28px 0 12px;
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6l6-6'/%3E%3C/svg%3E") no-repeat right 8px center;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    appearance: none;
    cursor: pointer;
    min-width: 90px;
}

.erp-status-layout {
    display: grid;
    grid-template-columns: 132px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 132px;
}

.erp-status-chart-wrap {
    position: relative;
    width: 132px;
    height: 132px;
    flex-shrink: 0;
}

.erp-status-chart,
#erp-order-status-chart {
    width: 132px !important;
    height: 132px !important;
    min-height: 0 !important;
    flex: 0 0 auto !important;
    overflow: hidden !important;
}

.erp-status-chart > div,
.erp-status-chart .highcharts-container,
.erp-status-chart svg {
    width: 132px !important;
    height: 132px !important;
    max-width: 132px !important;
    overflow: visible !important;
}

.erp-status-center {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    z-index: 2;
    line-height: 1.1;
    width: 78px;
}

.erp-status-center__num {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.03em;
}

.erp-status-center__lbl {
    display: block;
    font-size: 10px;
    font-weight: 400;
    color: #9CA3AF;
    margin-top: 2px;
    line-height: 1.2;
}

.erp-status-legend,
#erp-order-status-legend {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
    padding: 0;
    margin: 0;
    border: none;
}

.erp-status-legend__item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.erp-status-legend__left {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    overflow: hidden;
}

.erp-status-legend__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.erp-status-legend__name {
    font-size: 11px;
    font-weight: 500;
    color: #6B7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.erp-status-legend__val {
    font-size: 11px;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    text-align: right;
    flex-shrink: 0;
}

.erp-status-legend__val span {
    font-weight: 400;
    color: #9CA3AF;
    font-size: 10px;
}

#erp-sales-chart .highcharts-axis-title,
#erp-sales-chart .highcharts-title {
    display: none !important;
}
.erp-content .highcharts-button,
.erp-content .highcharts-contextbutton,
.erp-content .highcharts-exporting-group,
.erp-content .highcharts-a11y-proxy-group-after {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.erp-dash-widget--running .erp-dash-widget__body {
    flex: 0 1 auto;
}

.erp-dash-widget--running .erp-orders-table tbody tr:last-child td {
    padding-bottom: 0;
}

/* ── Running / Recent orders table ── */
.erp-orders-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.erp-orders-table thead th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #9CA3AF;
    padding: 0 0 10px;
    border-bottom: 1px solid #F3F4F6;
}

.erp-orders-table thead th:last-child {
    text-align: right;
}

.erp-orders-table tbody td {
    padding: 12px 0;
    border-bottom: 1px solid #F3F4F6;
    vertical-align: middle;
    color: #374151;
}

.erp-orders-table tbody tr:last-child td {
    border-bottom: none;
}

.erp-orders-table tbody td:last-child {
    text-align: right;
}

.erp-orders-table__id {
    font-weight: 600;
    color: #111827;
    font-size: 13px;
}

.erp-dash-row--2-1-1 .erp-orders-table thead th {
    padding: 0 0 6px;
}

.erp-dash-row--2-1-1 .erp-orders-table tbody td {
    padding: 7px 0;
    font-size: 12px;
}

.erp-dash-row--2-1-1 .erp-orders-table__id {
    font-size: 12px;
}

.erp-orders-table__meta {
    font-size: 12px;
    color: #6B7280;
    margin-top: 2px;
}

.erp-orders-table__time {
    font-size: 12px;
    color: #9CA3AF;
    white-space: nowrap;
}

.erp-orders-table__amount {
    font-weight: 600;
    color: #111827;
    font-size: 13px;
    white-space: nowrap;
}

/* ── Products table ── */
.erp-products-table {
    width: 100%;
    border-collapse: collapse;
}

.erp-products-table thead th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #9CA3AF;
    padding: 0 8px 12px 0;
    border-bottom: 1px solid #F3F4F6;
}

.erp-products-table thead th:last-child,
.erp-products-table tbody td:last-child {
    text-align: right;
}

.erp-products-table tbody td {
    padding: 14px 8px 14px 0;
    border-bottom: 1px solid #F3F4F6;
    vertical-align: middle;
    font-size: 13px;
    color: #374151;
}

.erp-products-table tbody tr:last-child td {
    border-bottom: none;
}

.erp-products-table__rank {
    width: 28px;
    color: #9CA3AF;
    font-weight: 600;
    font-size: 13px;
}

.erp-products-table__product {
    display: flex;
    align-items: center;
    gap: 12px;
}

.erp-products-table__thumb {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: cover;
    background: #F3F4F6;
    border: 1px solid #E5E7EB;
    flex-shrink: 0;
}

.erp-products-table__name {
    font-weight: 500;
    color: #111827;
    line-height: 1.3;
}

.erp-products-table__qty {
    color: #6B7280;
    white-space: nowrap;
}

.erp-products-table__rev {
    font-weight: 600;
    color: #111827;
}

/* ── Quick actions 3x3 ── */
.erp-quick-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    flex: 1;
    align-content: start;
}

.erp-quick-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 92px;
    padding: 16px 8px;
    border: 1px solid #E8ECF1;
    border-radius: 14px;
    background: #FAFBFC;
    text-decoration: none;
    color: #374151;
    font-size: 11px;
    font-weight: 500;
    text-align: center;
    line-height: 1.25;
    transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.erp-quick-tile:hover {
    background: #fff;
    border-color: #DBEAFE;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
    color: #2563EB;
    text-decoration: none;
}

.erp-quick-tile__icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.erp-quick-tile__icon--blue { background: #DBEAFE; color: #2563EB; }
.erp-quick-tile__icon--green { background: #DCFCE7; color: #16A34A; }
.erp-quick-tile__icon--orange { background: #FFEDD5; color: #EA580C; }
.erp-quick-tile__icon--purple { background: #EDE9FE; color: #7C3AED; }
.erp-quick-tile__icon--red { background: #FEE2E2; color: #DC2626; }
.erp-quick-tile__icon--gray { background: #F3F4F6; color: #6B7280; }

/* ── Today summary bar ── */
.erp-today-strip {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0;
    background: #fff;
    border: 1px solid #E8ECF1;
    border-radius: 16px;
    padding: 18px 8px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    margin-top: 4px;
}

.erp-today-strip__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-right: 1px solid #F3F4F6;
    text-align: center;
}

.erp-today-strip__item:last-child {
    border-right: none;
}

.erp-today-strip__icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #F3F4F6;
    color: #6B7280;
    display: flex;
    align-items: center;
    justify-content: center;
}

.erp-today-strip__label {
    font-size: 11px;
    font-weight: 500;
    color: #9CA3AF;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.erp-today-strip__value {
    font-size: 16px;
    font-weight: 700;
    color: #111827;
    line-height: 1.2;
}

/* ── Badges (premium pills) ── */
.erp-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.2;
}

.erp-pill--success { background: #DCFCE7; color: #15803D; }
.erp-pill--warning { background: #FFEDD5; color: #C2410C; }
.erp-pill--info { background: #DBEAFE; color: #1D4ED8; }
.erp-pill--danger { background: #FEE2E2; color: #B91C1C; }

.erp-dash-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9CA3AF;
    font-size: 13px;
    padding: 24px;
    text-align: center;
}

td.erp-dash-empty {
    display: table-cell;
    text-align: center;
    color: #9CA3AF;
    padding: 32px 16px !important;
}

@media (max-width: 1400px) {
    .erp-kpi-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 1200px) {
    .erp-dash-row--2-1-1 {
        grid-template-columns: 1fr;
    }

    .erp-dash-widget {
        min-height: 0;
    }

    .erp-status-layout {
        grid-template-columns: 112px 1fr;
        gap: 8px;
        min-height: 112px;
    }

    .erp-status-chart-wrap,
    .erp-status-chart,
    .erp-status-chart > div,
    .erp-status-chart .highcharts-container {
        width: 112px !important;
        height: 112px !important;
        max-width: 112px !important;
    }

    #erp-order-status-chart {
        width: 112px !important;
        height: 112px !important;
    }
}

@media (max-width: 768px) {
    .erp-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .erp-today-strip {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .erp-today-strip__item:nth-child(3) {
        border-right: none;
    }

    .erp-quick-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    .erp-kpi-grid {
        grid-template-columns: 1fr;
    }

    .erp-today-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
