/* ==========================================================================
   MAADRE.Store.WEBAdmin - Store Dashboard Enterprise UI/UX Stylesheet
   Strict English Naming Conventions - Zero Scroll Viewport Lock
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Desktop Layout Reset & Viewport Lock
   -------------------------------------------------------------------------- */
@media (min-width: 992px) {
    html, body {
        height: 100vh !important;
        max-height: 100vh !important;
        overflow: hidden !important;
    }

    .rz-layout {
        height: 100vh !important;
        max-height: 100vh !important;
        overflow: hidden !important;
    }

    /* Target RadzenBody and eliminate outer padding / scrolling when viewing dashboard */
    .rz-body:has(.dashboard-body-wrapper),
    .rz-body:has(.store-dashboard-container),
    body:has(.store-dashboard-container) .rz-body {
        height: calc(100vh - var(--rz-header-height, 56px)) !important;
        max-height: calc(100vh - var(--rz-header-height, 56px)) !important;
        overflow: hidden !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .dashboard-body-wrapper {
        height: calc(100vh - var(--rz-header-height, 56px)) !important;
        max-height: calc(100vh - var(--rz-header-height, 56px)) !important;
        overflow: hidden !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100%;
        display: flex;
        flex-direction: column;
    }

    .store-dashboard-container {
        width: 100%;
        height: 100% !important;
        max-height: 100% !important;
        display: flex;
        flex-direction: column;
        overflow: hidden !important;
        padding: 0.45rem 0.75rem 0.35rem 0.75rem !important;
        background-color: #f8fafc;
        box-sizing: border-box;
    }
}

/* --------------------------------------------------------------------------
   2. KPI Metric Strip Section (Compact Unified Row)
   -------------------------------------------------------------------------- */
.dashboard-kpi-section {
    flex: 0 0 auto;
    margin-bottom: 0.45rem;
    width: 100%;
}

.kpi-metric-strip {
    width: 100%;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 0.45rem;
    width: 100%;
}

/* KPI Micro-Card (Pill) */
.kpi-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.55rem;
    height: 56px;
    box-sizing: border-box;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02), 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    min-width: 0;
    overflow: hidden;
}

.kpi-pill:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
}

.kpi-pill-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.kpi-pill-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    justify-content: center;
}

.kpi-pill-label {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.1;
    margin-bottom: 2px;
}

.kpi-pill-value {
    font-size: 1rem;
    font-weight: 800;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.15;
}

/* Vibrancy Gradients for Financial KPIs */
.kpi-pill-purple {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%) !important;
    border: none !important;
    box-shadow: 0 3px 8px rgba(79, 70, 229, 0.18) !important;
}
.kpi-pill-purple .kpi-pill-label { color: rgba(255, 255, 255, 0.85) !important; }
.kpi-pill-purple .kpi-pill-value { color: #ffffff !important; }
.kpi-pill-purple .kpi-pill-icon { background: rgba(255, 255, 255, 0.2) !important; color: #ffffff !important; }

.kpi-pill-emerald {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%) !important;
    border: none !important;
    box-shadow: 0 3px 8px rgba(16, 185, 129, 0.18) !important;
}
.kpi-pill-emerald .kpi-pill-label { color: rgba(255, 255, 255, 0.85) !important; }
.kpi-pill-emerald .kpi-pill-value { color: #ffffff !important; }
.kpi-pill-emerald .kpi-pill-icon { background: rgba(255, 255, 255, 0.2) !important; color: #ffffff !important; }

.kpi-pill-blue {
    background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%) !important;
    border: none !important;
    box-shadow: 0 3px 8px rgba(59, 130, 246, 0.18) !important;
}
.kpi-pill-blue .kpi-pill-label { color: rgba(255, 255, 255, 0.85) !important; }
.kpi-pill-blue .kpi-pill-value { color: #ffffff !important; }
.kpi-pill-blue .kpi-pill-icon { background: rgba(255, 255, 255, 0.2) !important; color: #ffffff !important; }

.kpi-pill-amber {
    background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%) !important;
    border: none !important;
    box-shadow: 0 3px 8px rgba(245, 158, 11, 0.18) !important;
}
.kpi-pill-amber .kpi-pill-label { color: rgba(255, 255, 255, 0.85) !important; }
.kpi-pill-amber .kpi-pill-value { color: #ffffff !important; }
.kpi-pill-amber .kpi-pill-icon { background: rgba(255, 255, 255, 0.2) !important; color: #ffffff !important; }

/* Operational KPIs */
.kpi-pill-neutral .kpi-pill-icon { background: #f1f5f9; }
.kpi-pill-danger { background: #fef2f2 !important; border-color: #fecaca !important; }
.kpi-pill-danger .kpi-pill-icon { background: #fee2e2 !important; }

/* --------------------------------------------------------------------------
   3. Workspace Grid Layout
   -------------------------------------------------------------------------- */
.dashboard-workspace {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.workspace-grid {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 0.55rem;
    height: 100%;
}

.workspace-column-left,
.workspace-column-right {
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.workspace-column-right {
    display: grid;
    grid-template-rows: 1fr 1fr;
    gap: 0.55rem;
    height: 100%;
}

/* --------------------------------------------------------------------------
   4. Enterprise Panel Card
   -------------------------------------------------------------------------- */
.dashboard-panel {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.65rem 0.85rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02), 0 1px 2px rgba(0, 0, 0, 0.02);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.panel-header {
    flex: 0 0 auto;
}

.panel-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: #1e293b;
    letter-spacing: -0.01em;
}

.panel-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 9999px;
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

/* --------------------------------------------------------------------------
   5. Sales Trends Component & Vertical Dual Stack
   -------------------------------------------------------------------------- */
.trends-panel {
    height: 100%;
}

.trend-tabs {
    display: inline-flex;
    padding: 2px;
    background: #f1f5f9;
    border-radius: 6px;
    gap: 2px;
}

.trend-tab-btn {
    border: none;
    background: transparent;
    padding: 0.2rem 0.55rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: #64748b;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1.2;
}

.trend-tab-btn.active {
    background: #ffffff;
    color: #4f46e5;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.trend-tab-btn:hover:not(.active) {
    color: #1e293b;
    background: rgba(255, 255, 255, 0.5);
}

.dual-vertical-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.dual-chart-section {
    min-height: 0;
    height: calc(50% - 4px);
    display: flex;
    flex-direction: column;
}

/* --------------------------------------------------------------------------
   6. Top Products Grid Component
   -------------------------------------------------------------------------- */
.top-products-panel {
    height: 100%;
}

.top-products-table-wrapper {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
    max-height: calc(100% - 28px);
}

.table-light-header th {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    padding: 0.3rem 0.45rem;
}

.product-avatar {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    background: #ede9fe;
    color: #6366f1;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.product-name {
    font-size: 0.78rem;
    line-height: 1.2;
}

.badge-units {
    font-size: 0.7rem;
    font-weight: 700;
    background: #f1f5f9;
    color: #334155;
    padding: 0.15rem 0.4rem;
    border-radius: 5px;
}

/* --------------------------------------------------------------------------
   7. Payment Methods Component
   -------------------------------------------------------------------------- */
.payment-methods-panel {
    height: 100%;
}

.payment-methods-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
}

.payment-chart-box {
    width: 45%;
    height: 100%;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.payment-table-box {
    width: 55%;
    overflow-y: auto;
    max-height: 100%;
}

.payment-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

/* --------------------------------------------------------------------------
   8. Utility Helpers
   -------------------------------------------------------------------------- */
.text-indigo { color: #4f46e5 !important; }
.text-success { color: #10b981 !important; }
.text-gold { color: #d97706 !important; }
.text-emerald { color: #10b981 !important; }
.text-slate-800 { color: #1e293b !important; }
.font-medium { font-weight: 500; }
.font-bold { font-weight: 700; }
.font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

.bg-indigo-light { background-color: #ede9fe !important; color: #6366f1 !important; }
.bg-success-light { background-color: #ecfdf5 !important; color: #10b981 !important; }
.bg-gold-light { background-color: #fef3c7 !important; color: #d97706 !important; }
.bg-info-light { background-color: #e0f2fe !important; color: #0284c7 !important; }
.bg-slate-light { background-color: #f1f5f9 !important; }

/* Pulse animation */
.animate-pulse {
    animation: kpiPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes kpiPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.85; transform: scale(1.02); }
}

/* --------------------------------------------------------------------------
   9. Detail Drill-Down Views (Month, Week, Day) - Zero-Scroll Viewport Lock
   -------------------------------------------------------------------------- */
.detail-view-container {
    width: 100%;
    height: 100% !important;
    max-height: 100% !important;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* Compact Header */
.detail-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.65rem;
    margin-bottom: 0.45rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.detail-breadcrumbs {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 500;
}

.breadcrumb-item {
    color: #64748b;
}

.breadcrumb-item.active {
    color: #1e293b;
    font-weight: 700;
}

.detail-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.01em;
}

/* Compact 3-KPI Row */
.detail-kpi-row {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
    margin-bottom: 0.45rem;
    width: 100%;
}

.detail-kpi-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.75rem;
    height: 54px;
    box-sizing: border-box;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
    min-width: 0;
}

.detail-kpi-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.detail-kpi-label {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.1;
    margin-bottom: 2px;
}

.detail-kpi-value {
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.15;
}

.detail-kpi-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    flex-shrink: 0;
}

/* Workspace area for charts or tables */
.detail-workspace {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.detail-workspace-grid {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
    height: 100%;
    overflow: hidden;
}

.detail-chart-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.55rem 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.detail-chart-header {
    flex: 0 0 auto;
    margin-bottom: 0.35rem;
}

.detail-chart-body {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    width: 100%;
    position: relative;
    overflow: hidden;
}

/* Day Detail Table & Badges */
.product-dim {
    font-size: 0.70rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    background-color: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    white-space: nowrap;
    display: inline-block;
    letter-spacing: 0.02em;
}

.product-title {
    font-size: 0.86rem;
    color: #1e293b;
}

.day-detail-grid {
    border: none !important;
    box-shadow: none !important;
}

.day-detail-grid .rz-grid-table thead th {
    position: sticky !important;
    top: 0 !important;
    z-index: 2 !important;
    background-color: #f8fafc !important;
    font-size: 0.70rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    color: #64748b !important;
    letter-spacing: 0.04em !important;
    border-bottom: 2px solid #e2e8f0 !important;
    padding: 0.45rem 0.6rem !important;
}

.day-detail-grid .rz-data-row {
    transition: background-color 0.15s ease !important;
}

.day-detail-grid .rz-data-row:hover {
    background-color: #f8fafc !important;
}

.day-detail-grid .rz-data-row td {
    padding: 0.45rem 0.6rem !important;
    vertical-align: middle !important;
    border-bottom: 1px solid #f1f5f9 !important;
}

.bg-warning-light {
    background-color: #fef3c7 !important;
    color: #d97706 !important;
}

.bg-danger-light {
    background-color: #fee2e2 !important;
    color: #dc2626 !important;
}

/* Day detail view: aggressively hide and remove any chart tooltips */
.day-detail-view ~ .rz-chart-tooltip,
.store-dashboard-container:has(.day-detail-view) .rz-chart-tooltip,
body:has(.day-detail-view) .rz-chart-tooltip {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

/* --------------------------------------------------------------------------
   10. Radzen Chart Tooltip Global Fix (Zero Clutter & No Event Hijacking)
   -------------------------------------------------------------------------- */
.rz-chart-tooltip,
.rz-chart-tooltip * {
    pointer-events: none !important;
    user-select: none !important;
}

.rz-chart-tooltip {
    z-index: 1050 !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18) !important;
    border-radius: 8px !important;
    padding: 6px 12px !important;
    font-size: 0.75rem !important;
    font-weight: 500 !important;
    transition: opacity 0.12s ease-in-out !important;
}

/* --------------------------------------------------------------------------
   11. Mobile & Tablet Responsiveness
   -------------------------------------------------------------------------- */
@media (max-width: 1200px) {
    .kpi-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0.45rem;
    }
}

@media (max-width: 991px) {
    .store-dashboard-container {
        height: auto !important;
        min-height: calc(100vh - 4.5rem) !important;
        max-height: none !important;
        overflow-y: auto !important;
        padding: 0.75rem !important;
    }

    .detail-view-container {
        height: auto !important;
        max-height: none !important;
        overflow-y: auto !important;
    }

    .detail-kpi-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .detail-workspace-grid {
        display: flex;
        flex-direction: column;
        height: auto;
        gap: 0.75rem;
    }

    .detail-chart-card {
        min-height: 350px;
        height: auto;
    }

    .detail-chart-body {
        min-height: 280px;
    }

    .workspace-grid {
        display: flex;
        flex-direction: column;
        height: auto;
    }

    .workspace-column-left {
        min-height: 400px;
    }

    .workspace-column-right {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        height: auto;
    }

    .dashboard-panel {
        min-height: 260px;
    }

    .payment-methods-content {
        flex-direction: column;
    }

    .payment-chart-box,
    .payment-table-box {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .store-dashboard-container {
        padding: 0.5rem !important;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.4rem;
    }

    .kpi-pill {
        padding: 0.35rem 0.5rem;
    }

    .kpi-pill-value {
        font-size: 0.92rem;
    }

    .kpi-pill-label {
        font-size: 0.6rem;
    }

    .workspace-column-left,
    .dashboard-panel {
        min-height: 280px;
    }
}
