/* Dashboard: acabamento visual sobre a fundacao compartilhada. */

#dashboardView {
    --dashboard-panel-border: rgba(219, 227, 236, .9);
    --dashboard-panel-shadow: 0 12px 34px rgba(11, 28, 45, .09);
}

#dashboardView .dashboard-hero {
    min-height: 244px;
    border: 1px solid rgba(255, 255, 255, .12);
    background:
        radial-gradient(circle at 88% 12%, rgba(245, 124, 0, .34), transparent 32%),
        radial-gradient(circle at 6% 110%, rgba(59, 130, 246, .18), transparent 38%),
        linear-gradient(135deg, #081a2b 0%, #153a54 64%, #10283c 100%);
}

#dashboardView .dashboard-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #fdba74;
}

#dashboardView .dashboard-kicker::before {
    content: '';
    width: 20px;
    height: 2px;
    border-radius: 999px;
    background: #f57c00;
}

#dashboardView .dashboard-hero-copy {
    font-size: clamp(14px, 1.15vw, 16px);
}

#dashboardView .dashboard-health {
    position: relative;
    overflow: hidden;
    border-color: rgba(255, 255, 255, .22);
    background: rgba(255, 255, 255, .1);
}

#dashboardView .health-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

#dashboardView .health-state {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 28px;
    padding: 5px 9px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 999px;
    background: rgba(255, 255, 255, .1);
    color: #bbf7d0;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
}

#dashboardView .health-state i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, .12);
}

#dashboardView .health-state.attention { color: #fde68a; }
#dashboardView .health-state.attention i { background: #f59e0b; box-shadow: 0 0 0 4px rgba(245, 158, 11, .13); }
#dashboardView .health-state.critical { color: #fecaca; }
#dashboardView .health-state.critical i { background: #ef4444; box-shadow: 0 0 0 4px rgba(239, 68, 68, .13); }

#dashboardView .dashboard-health[data-level='healthy'] .health-bar-fill { background: linear-gradient(90deg, #10b981, #34d399); }
#dashboardView .dashboard-health[data-level='attention'] .health-bar-fill { background: linear-gradient(90deg, #f59e0b, #f57c00); }
#dashboardView .dashboard-health[data-level='critical'] .health-bar-fill { background: linear-gradient(90deg, #ef4444, #f97316); }

#dashboardView .health-value {
    letter-spacing: -1.8px;
}

#dashboardView .health-bar {
    height: 8px;
}

#dashboardView .dashboard-section-heading {
    min-height: 44px;
}

#dashboardView .dashboard-section-heading h2 {
    color: #f8fafc;
}

#dashboardView .dashboard-live-status {
    white-space: nowrap;
}

#dashboardView .dashboard-update-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

#dashboardView .dashboard-live-status.error {
    border-color: rgba(254, 202, 202, .34);
    background: rgba(127, 29, 29, .14);
    color: #fecaca;
}

#dashboardView .dashboard-live-status.error i {
    background: #ef4444;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, .12);
}

#dashboardView .dashboard-refresh {
    display: inline-flex;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 10px;
    background: rgba(255, 255, 255, .08);
    color: #f8fafc;
    cursor: pointer;
}

#dashboardView .dashboard-refresh:hover {
    border-color: rgba(253, 186, 116, .55);
    background: rgba(245, 124, 0, .18);
    color: #fdba74;
}

#dashboardView .dashboard-refresh:disabled { cursor: wait; opacity: .72; }
#dashboardView.is-loading .dashboard-refresh i { animation: dashboard-spin .8s linear infinite; }

@keyframes dashboard-spin { to { transform: rotate(360deg); } }

#dashboardView .dashboard-metrics {
    gap: 16px;
}

#dashboardView .dashboard-section-heading-flows { margin-top: 2px; }

#dashboardView .dashboard-flow-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}

#dashboardView .dashboard-flow-card {
    --flow-accent: #f57c00;
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    align-items: center;
    gap: 14px;
    min-width: 0;
    min-height: 112px;
    padding: 18px 48px 18px 18px;
    overflow: hidden;
    border: 1px solid var(--dashboard-panel-border);
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 9px 26px rgba(11, 28, 45, .07);
}

#dashboardView .dashboard-flow-card::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--flow-accent);
}

#dashboardView .flow-inventory { --flow-accent: #2563eb; }
#dashboardView .flow-damages { --flow-accent: #dc2626; }

#dashboardView .dashboard-flow-icon {
    display: inline-flex;
    width: 46px;
    height: 46px;
    align-items: center;
    justify-content: center;
    border-radius: 13px;
    background: color-mix(in srgb, var(--flow-accent) 11%, white);
    color: var(--flow-accent);
    font-size: 17px;
}

#dashboardView .dashboard-flow-copy {
    display: grid;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 12px;
}

#dashboardView .dashboard-flow-copy > span {
    color: #526276;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .35px;
    text-transform: uppercase;
}

#dashboardView .dashboard-flow-copy > strong {
    grid-row: 1 / span 2;
    grid-column: 2;
    color: #0b1c2d;
    font-size: 30px;
    line-height: 1;
}

#dashboardView .dashboard-flow-copy > small {
    grid-column: 1;
    margin-top: 5px;
    overflow: hidden;
    color: #64748b;
    font-size: 11px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#dashboardView .dashboard-flow-copy b { color: var(--flow-accent); }

#dashboardView .metric-card {
    --metric-accent: #f57c00;
    min-height: 172px;
    border-color: var(--dashboard-panel-border);
    box-shadow: var(--dashboard-panel-shadow);
}

#dashboardView .metric-card::before {
    content: '';
    display: block;
    position: absolute;
    inset: 0 0 auto;
    width: auto;
    height: 3px;
    border-radius: 0;
    background: linear-gradient(90deg, var(--metric-accent), transparent 78%);
}

#dashboardView .metric-card.metric-events { --metric-accent: #2563eb; }
#dashboardView .metric-card.metric-movements { --metric-accent: #10b981; }
#dashboardView .metric-card.metric-value-stock { --metric-accent: #8b5cf6; }

#dashboardView .metric-card .metric-icon {
    color: var(--metric-accent);
    border: 1px solid color-mix(in srgb, var(--metric-accent) 24%, transparent);
    background: color-mix(in srgb, var(--metric-accent) 11%, white);
    box-shadow: none;
}

#dashboardView .metric-label {
    color: #526276;
}

#dashboardView .metric-value {
    color: #0b1c2d;
    font-size: clamp(28px, 2.25vw, 38px);
}

#dashboardView .metric-note {
    display: flex;
    min-height: 30px;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    padding-right: 34px;
}

#dashboardView .metric-separator {
    color: #cbd5e1;
}

#dashboardView .dashboard-link {
    line-height: 1.35;
}

#dashboardView .dashboard-panel {
    border-color: var(--dashboard-panel-border);
    box-shadow: var(--dashboard-panel-shadow);
}

#dashboardView .dashboard-panel-graficos {
    min-height: 430px;
}

#dashboardView .panel-header {
    min-height: 52px;
}

#dashboardView .panel-eyebrow {
    margin-bottom: 4px;
    color: #f57c00;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 1.15px;
    text-transform: uppercase;
}

#dashboardView .panel-title {
    font-size: 17px;
    line-height: 1.25;
    letter-spacing: -.2px;
}

#dashboardView .panel-subtitle {
    line-height: 1.45;
}

#dashboardView .dashboard-chart-header {
    align-items: center;
}

#dashboardView .chart-toggle {
    min-height: 42px;
}

#dashboardView .chart-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 32px;
}

#dashboardView .mini-chart {
    min-height: 300px;
}

#dashboardView .chart-empty {
    position: absolute;
    z-index: 2;
    inset: 22px 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    border: 1px dashed #d7e0e9;
    border-radius: 15px;
    background: rgba(248, 250, 252, .94);
    color: #64748b;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
}

#dashboardView .chart-empty[hidden] { display: none; }
#dashboardView .chart-empty i { color: #f57c00; font-size: 24px; }

#dashboardView .dashboard-chart-pane.is-empty canvas {
    display: none !important;
}

#dashboardView .dashboard-chart-pane.is-empty .chart-empty {
    inset: 0;
}

#dashboardView .insight-list {
    flex: 1;
}

#dashboardView .insight-item {
    min-height: 66px;
    border-color: #e5ebf2;
}

#dashboardView .insight-item:hover {
    border-color: #d2dce7;
    background: #f3f7fb;
}

#dashboardView .insight-item.critical {
    border-color: #fecaca;
    background: #fef2f2;
}

#dashboardView .insight-item.critical .insight-icon {
    background: #fee2e2;
    color: #b91c1c;
}

#dashboardView .insight-item.critical .insight-value { color: #b91c1c; }

#dashboardView.is-loading .metric-value,
#dashboardView.is-loading .dashboard-flow-copy > strong,
#dashboardView.is-loading .insight-list {
    opacity: .48;
}

#dashboardView .metric-value,
#dashboardView .dashboard-flow-copy > strong,
#dashboardView .insight-list {
    transition: opacity 180ms ease;
}

#dashboardView .insight-title,
#dashboardView .insight-value {
    color: #10263b;
}

#dashboardView .insight-meta {
    line-height: 1.35;
}

#dashboardView .empty-compact {
    display: flex;
    min-height: 86px;
    align-items: center;
    justify-content: center;
    border: 1px dashed #d7e0e9;
    line-height: 1.4;
}

#dashboardView .operational-base-grid .insight-item {
    min-height: 74px;
}

html[data-theme='dark'] #dashboardView {
    --dashboard-panel-border: #2d4254;
    --dashboard-panel-shadow: 0 14px 36px rgba(0, 0, 0, .24);
}

html[data-theme='dark'] #dashboardView .metric-card .metric-icon {
    border-color: color-mix(in srgb, var(--metric-accent) 32%, transparent);
    background: color-mix(in srgb, var(--metric-accent) 14%, #10202e);
}

html[data-theme='dark'] #dashboardView .metric-label,
html[data-theme='dark'] #dashboardView .metric-note,
html[data-theme='dark'] #dashboardView .panel-subtitle,
html[data-theme='dark'] #dashboardView .insight-meta {
    color: #9fb0c3;
}

html[data-theme='dark'] #dashboardView .metric-value,
html[data-theme='dark'] #dashboardView .insight-title,
html[data-theme='dark'] #dashboardView .insight-value {
    color: #f8fafc;
}

html[data-theme='dark'] #dashboardView .insight-item:hover {
    border-color: #3b5265;
    background: #182b3a;
}

html[data-theme='dark'] #dashboardView .empty-compact {
    border-color: #34495a;
}

html[data-theme='dark'] #dashboardView .dashboard-flow-card {
    border-color: var(--dashboard-panel-border);
    background: #10202e;
    box-shadow: var(--dashboard-panel-shadow);
}

html[data-theme='dark'] #dashboardView .dashboard-flow-icon {
    background: color-mix(in srgb, var(--flow-accent) 14%, #10202e);
}

html[data-theme='dark'] #dashboardView .dashboard-flow-copy > span,
html[data-theme='dark'] #dashboardView .dashboard-flow-copy > small { color: #9fb0c3; }
html[data-theme='dark'] #dashboardView .dashboard-flow-copy > strong { color: #f8fafc; }

html[data-theme='dark'] #dashboardView .chart-empty {
    border-color: #34495a;
    background: rgba(16, 32, 46, .95);
    color: #9fb0c3;
}

html[data-theme='dark'] #dashboardView .insight-item.critical {
    border-color: #71343a;
    background: #321d24;
}

html[data-theme='dark'] #dashboardView .insight-item.critical .insight-icon {
    background: #451f27;
    color: #fca5a5;
}

html[data-theme='dark'] #dashboardView .insight-item.critical .insight-value { color: #fca5a5; }

@media (max-width: 1200px) {
    #dashboardView .dashboard-hero {
        grid-template-columns: minmax(0, 1.25fr) minmax(240px, .55fr);
    }

    #dashboardView .dashboard-grid {
        grid-template-areas:
            'graficos graficos'
            'alertas eventos'
            'ultimas ultimas'
            'base base';
    }
}

@media (max-width: 900px) {
    #dashboardView .dashboard-hero {
        grid-template-columns: minmax(0, 1fr);
    }

    #dashboardView .dashboard-health {
        width: 100%;
    }

    #dashboardView .dashboard-flow-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 768px) {
    #dashboardView .dashboard-section-heading {
        align-items: center;
    }

    #dashboardView .dashboard-update-status { margin-left: auto; }

    #dashboardView .metric-card {
        min-height: 154px;
    }

    #dashboardView .dashboard-chart-header {
        align-items: stretch;
    }

    #dashboardView .chart-toggle {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #dashboardView .dashboard-panel-graficos {
        min-height: 390px;
    }

    #dashboardView .mini-chart {
        min-height: 255px;
    }
}

@media (max-width: 560px) {
    #dashboardView .dashboard-hero {
        padding: 22px;
        border-radius: 20px;
    }

    #dashboardView .dashboard-hero-title {
        font-size: clamp(27px, 9vw, 34px);
    }

    #dashboardView .dashboard-health {
        padding: 18px;
    }

    #dashboardView .health-value {
        font-size: 38px;
    }

    #dashboardView .dashboard-section-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    #dashboardView .dashboard-live-status {
        align-self: flex-start;
    }

    #dashboardView .dashboard-update-status {
        width: 100%;
        justify-content: space-between;
        margin-left: 0;
    }

    #dashboardView .dashboard-flow-card { min-height: 104px; }
    #dashboardView .dashboard-flow-copy > small { white-space: normal; }

    #dashboardView .metric-card {
        min-height: 146px;
    }

    #dashboardView .metric-note {
        padding-right: 30px;
    }

    #dashboardView .dashboard-panel {
        padding: 18px;
    }

    #dashboardView .dashboard-panel.dashboard-clickable .panel-header {
        padding-right: 46px;
    }

    #dashboardView .chart-toggle-btn {
        padding-right: 8px;
        padding-left: 8px;
        font-size: 11px;
    }

    #dashboardView .insight-item {
        align-items: center;
    }

    #dashboardView .insight-title,
    #dashboardView .insight-meta {
        white-space: normal;
    }

    #dashboardView .operational-base-grid .dashboard-clickable {
        padding-right: 50px;
    }
}

@media (max-width: 390px) {
    #dashboardView .chart-toggle-btn i {
        display: none;
    }

    #dashboardView .insight-icon {
        width: 34px;
        height: 34px;
    }

    #dashboardView .insight-value {
        font-size: 13px;
    }

    #dashboardView .dashboard-flow-card {
        grid-template-columns: 40px minmax(0, 1fr);
        gap: 11px;
        padding-left: 14px;
    }

    #dashboardView .dashboard-flow-icon {
        width: 40px;
        height: 40px;
    }

    #dashboardView .dashboard-flow-copy > strong { font-size: 26px; }
}
