/**
 * BlackOasis ERP — Premium Dashboard
 * Visual layer only. Requires design-system.css + main.css.
 */

.dash-page {
    animation: dash-fade-in 0.4s var(--ease-out, ease) both;
}

@keyframes dash-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ——— Hero header ——— */
.dash-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4, 16px);
    margin-bottom: var(--space-6, 24px);
    padding: var(--space-6, 24px);
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 48%, #eff6ff 100%);
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: var(--radius-xl, 20px);
    box-shadow: var(--shadow-md);
}

.dash-hero-main h1 {
    font-size: clamp(1.5rem, 2.5vw, 1.875rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 4px;
}

.dash-hero-main p {
    color: var(--text-secondary);
    font-size: var(--text-sm, 0.8125rem);
    max-width: 520px;
    line-height: 1.6;
}

.dash-hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.dash-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: var(--radius-full, 9999px);
    font-size: var(--text-xs, 0.75rem);
    font-weight: 600;
    background: var(--card-bg, #fff);
    border: 1px solid var(--border);
    color: var(--gray-700, #334155);
}

.dash-hero-badge-primary {
    background: var(--primary-soft, #eff6ff);
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.dash-hero-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.dash-hero-search {
    display: flex;
    align-items: center;
    gap: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-full, 9999px);
    padding: 4px 4px 4px 14px;
    min-width: min(280px, 100%);
    box-shadow: var(--shadow-xs);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.dash-hero-search:focus-within {
    border-color: var(--primary);
    box-shadow: var(--shadow-focus);
}

.dash-hero-search input {
    border: none;
    background: transparent;
    flex: 1;
    min-width: 0;
    padding: 8px 8px 8px 0;
    font-size: var(--text-sm);
    font-family: inherit;
    outline: none;
}

.dash-hero-search button {
    border: none;
    background: var(--accent-gradient, linear-gradient(135deg, #2563eb, #1e40af));
    color: #fff;
    font-weight: 600;
    font-size: var(--text-xs);
    padding: 8px 16px;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-family: inherit;
}

.dash-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ——— Quick actions ——— */
.dash-quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: var(--space-6, 24px);
}

.dash-quick-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg, 16px);
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow-xs);
    transition: transform 0.2s var(--ease-out, ease), box-shadow 0.2s, border-color 0.2s;
    min-height: 96px;
}

.dash-quick-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: #bfdbfe;
    color: inherit;
}

.dash-quick-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
}

.dash-quick-icon-sale { background: #ecfdf5; color: #059669; }
.dash-quick-icon-purchase { background: #eff6ff; color: #2563eb; }
.dash-quick-icon-product { background: #f5f3ff; color: #7c3aed; }
.dash-quick-icon-expense { background: #fffbeb; color: #d97706; }
.dash-quick-icon-settlement { background: #ecfeff; color: #0891b2; }
.dash-quick-icon-report { background: #f1f5f9; color: #475569; }
.dash-quick-icon-customer { background: #fce7f3; color: #db2777; }

.dash-quick-label {
    font-size: var(--text-sm);
    font-weight: 600;
    letter-spacing: -0.01em;
}

.dash-quick-hint {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin-top: auto;
}

/* ——— Ranked daily attention & report centre ——— */
.dash-attention-center{padding:20px;border:1px solid #dbe4f0;border-radius:20px;background:linear-gradient(145deg,#fff,#f8fbff);box-shadow:var(--shadow-xs)}
.dash-priority-card{display:grid;grid-template-columns:auto 1fr auto;gap:16px;align-items:center;padding:18px;border-radius:16px;background:#fff7ed;border:1px solid #fdba74;border-left:5px solid #ea580c}.dash-priority-card.severity-critical,.dash-priority-card.severity-error{background:#fef2f2;border-color:#fca5a5;border-left-color:#dc2626}.dash-priority-rank{width:38px;height:38px;display:grid;place-items:center;border-radius:12px;background:#132b4b;color:#fff;font-weight:800}.dash-priority-content h3{margin:5px 0;color:#172033}.dash-priority-content p{margin:0;color:#4b5563}.dash-priority-meta{display:flex;gap:10px;align-items:center;font-size:.76rem;color:#64748b}.dash-attention-list{margin-top:10px}.dash-attention-row{display:grid;grid-template-columns:32px 1fr auto;gap:12px;align-items:center;padding:12px;border-bottom:1px solid #e5e7eb}.dash-attention-row p{margin:3px 0 0;color:#64748b;font-size:.82rem}.dash-attention-number{width:26px;height:26px;display:grid;place-items:center;background:#eef2f7;border-radius:8px;font-size:.75rem;font-weight:700}.dash-attention-side{display:flex;gap:10px;align-items:center;font-size:.76rem}.dash-report-centre{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:12px}.dash-report-centre>a{display:flex;flex-direction:column;min-height:126px;padding:17px;border:1px solid #dce4ef;border-radius:15px;background:#fff;color:#172033;text-decoration:none;box-shadow:var(--shadow-xs);transition:.2s}.dash-report-centre>a:hover{transform:translateY(-2px);border-color:#93c5fd;box-shadow:var(--shadow-md)}.dash-report-centre strong{font-size:.92rem}.dash-report-centre span{font-size:.77rem;color:#64748b;line-height:1.45;margin:7px 0}.dash-report-centre b{margin-top:auto;color:#1d4ed8;font-size:.86rem}
@media(max-width:700px){.dash-priority-card{grid-template-columns:auto 1fr}.dash-priority-card>a{grid-column:2}.dash-attention-row{grid-template-columns:28px 1fr}.dash-attention-side{grid-column:2;flex-wrap:wrap}}

/* ——— KPI cards premium ——— */
.dash-kpi-grid {
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 14px;
}

.dash-kpi-premium {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 18px 18px 16px;
    min-height: 118px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    transition: transform 0.22s var(--ease-out, ease), box-shadow 0.22s, border-color 0.22s;
}

.dash-kpi-premium::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--kpi-accent, var(--primary));
    opacity: 0.85;
}

.dash-kpi-premium:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: rgba(37, 99, 235, 0.2);
}

.dash-kpi-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.dash-kpi-icon-wrap {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--kpi-icon-bg, var(--primary-soft));
    color: var(--kpi-accent, var(--primary));
    flex-shrink: 0;
}

.dash-kpi-icon-wrap svg {
    width: 18px;
    height: 18px;
}

.dash-kpi-trend {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.dash-kpi-trend-up {
    background: #ecfdf5;
    color: #047857;
}

.dash-kpi-trend-down {
    background: #fef2f2;
    color: #b91c1c;
}

.dash-kpi-trend-neutral {
    background: var(--gray-100);
    color: var(--gray-500);
}

.dash-kpi-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.dash-kpi-val {
    font-size: clamp(1.25rem, 2vw, 1.5rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.dash-kpi-foot {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: auto;
}

.dash-kpi-good { --kpi-accent: var(--success); --kpi-icon-bg: #ecfdf5; }
.dash-kpi-warn { --kpi-accent: var(--warning); --kpi-icon-bg: #fffbeb; }
.dash-kpi-danger { --kpi-accent: var(--danger); --kpi-icon-bg: #fef2f2; }
.dash-kpi-info { --kpi-accent: var(--info); --kpi-icon-bg: #eff6ff; }
.dash-kpi-highlight {
    background: linear-gradient(145deg, #ecfdf5 0%, #ffffff 70%);
    border-color: #bbf7d0;
}

/* ——— Sections ——— */
.dash-section {
    margin-bottom: var(--space-8, 32px);
}

.dash-section-head h2 {
    font-size: var(--text-lg, 1.125rem);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.dash-section-period {
    background: linear-gradient(160deg, #ffffff 0%, #f8fafc 40%, #eef2ff 100%);
    border: 1px solid #e0e7ff;
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-xs);
}

.dash-section-period .dash-filter {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
}

/* ——— Widgets & alerts ——— */
.dash-widget-grid {
    gap: 18px;
}

.dash-widget {
    border-radius: var(--radius-lg);
    transition: box-shadow 0.2s;
}

.dash-widget:hover {
    box-shadow: var(--shadow-md);
}

.dash-notify-row {
    padding: 12px 0;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.dash-notify-row:hover {
    background: var(--gray-50);
    padding-left: 8px;
    padding-right: 8px;
    margin-left: -8px;
    margin-right: -8px;
}

.dash-alert-premium {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    margin-bottom: 10px;
    transition: transform 0.15s;
}

.dash-alert-premium:hover {
    transform: translateX(2px);
}

.dash-alert-premium-warn {
    background: var(--warning-soft);
    border-color: #fde68a;
    color: #92400e;
}

.dash-alert-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.6);
    flex-shrink: 0;
}

/* ——— Activity timeline ——— */
.dash-activity-timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.dash-activity-item {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    gap: 12px;
    align-items: start;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.15s;
}

.dash-activity-item:last-child {
    border-bottom: none;
}

.dash-activity-item:hover {
    background: var(--gray-50);
    margin: 0 -12px;
    padding-left: 12px;
    padding-right: 12px;
    border-radius: var(--radius-sm);
}

.dash-activity-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    background: var(--primary-soft);
    color: var(--primary);
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--border);
}

.dash-activity-dot-sale { background: #ecfdf5; color: #059669; }
.dash-activity-dot-purchase { background: #eff6ff; color: #2563eb; }

.dash-activity-body {
    min-width: 0;
}

.dash-activity-body strong {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
}

.dash-activity-body span {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.dash-activity-amt {
    font-size: var(--text-sm);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--gray-800);
}

/* ——— Charts ——— */
.dash-chart-box {
    min-height: 300px;
    border-radius: var(--radius-lg);
    position: relative;
    overflow: hidden;
}

.dash-chart-box .card-title {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 12px;
}

.dash-chart-canvas-wrap {
    position: relative;
    height: 240px;
}

.dash-chart-skeleton {
    position: absolute;
    inset: 48px 0 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    pointer-events: none;
    transition: opacity 0.3s;
}

.dash-chart-box.is-loaded .dash-chart-skeleton {
    opacity: 0;
}

.dash-chart-skeleton-bar {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.2s ease-in-out infinite;
}

.dash-chart-skeleton-bar:nth-child(1) { width: 100%; }
.dash-chart-skeleton-bar:nth-child(2) { width: 85%; }
.dash-chart-skeleton-bar:nth-child(3) { width: 70%; }
.dash-chart-skeleton-bar:nth-child(4) { width: 90%; }
.dash-chart-skeleton-bar:nth-child(5) { width: 60%; }

.dash-builder-card {
    border-radius: var(--radius-xl);
    background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
}

/* ——— Reminders ——— */
.dash-reminder {
    border-radius: var(--radius-lg);
    transition: transform 0.15s, box-shadow 0.15s;
}

.dash-reminder:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

/* ——— Tables on dashboard ——— */
.dash-panel {
    border-radius: var(--radius-lg);
}

.dash-panel .card-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dash-fit-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
}

.dash-panel .table-scroll {
    max-height: 320px;
    overflow-y: auto;
}

/* ——— AI section ——— */
.ai-insights-section .ai-score-grid {
    gap: 18px;
}

.ai-health-card {
    text-align: center;
    background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
}

.ai-health-ring {
    width: 88px;
    height: 88px;
    margin: 8px auto 12px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 800;
    border: 4px solid currentColor;
    background: rgba(255, 255, 255, 0.8);
}

/* ——— Responsive ——— */
@media (max-width: 1024px) {
    .dash-hero {
        padding: 18px;
    }

    .dash-hero-toolbar {
        width: 100%;
    }

    .dash-hero-search {
        flex: 1;
        min-width: 100%;
    }

    .dash-quick-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dash-chart-row-3 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .dash-quick-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .dash-quick-card {
        min-height: 88px;
        padding: 12px;
    }

    .dash-kpi-premium {
        min-height: 108px;
        padding: 14px;
    }

    .dash-kpi-trend {
        display: none;
    }
}

.dash-kpi-status {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
}

.dash-status-kpi {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    text-decoration: none;
    border: 1px solid rgba(15, 23, 42, 0.06);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.dash-status-kpi:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.dash-status-kpi-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    opacity: 0.85;
}

.dash-status-kpi-value {
    font-size: 1.45rem;
    line-height: 1;
}

.dash-status-kpi.order-status-pending { background: #f3f4f6; color: #374151; }
.dash-status-kpi.order-status-rtd { background: #dbeafe; color: #1d4ed8; }
.dash-status-kpi.order-status-dispatched { background: #e0e7ff; color: #4338ca; }
.dash-status-kpi.order-status-in_transit { background: #ffedd5; color: #c2410c; }
.dash-status-kpi.order-status-completed { background: #dcfce7; color: #15803d; }
.dash-status-kpi.order-status-return { background: #f3e8ff; color: #7e22ce; }
.dash-status-kpi.order-status-cancelled { background: #fee2e2; color: #b91c1c; }

@media print {
    .dash-hero-search,
    .dash-quick-grid,
    .dash-chart-skeleton {
        display: none !important;
    }
}
