/* Professional Dashboard Styles */

.dashboard-container {
    min-height: 100vh;
    background: linear-gradient(to bottom, #f8fafc, #e2e8f0);
}

.dashboard-toolbar {
    position: sticky;
    top: 0;
    z-index: 40;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.7);
    border-bottom: 1px solid #e2e8f0;
    padding: 16px 0;
}

.toolbar-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.date-range-select {
    min-width: 150px;
}

.search-field {
    min-width: 220px;
}

.toolbar-icon {
    color: #64748b;
}

.dashboard-content {
    padding-top: 24px;
    padding-bottom: 48px;
}

/*
 * ============================================================
 * KPI CARD HEIGHT CONTRACT — READ BEFORE ADDING LOCAL STYLES
 * ============================================================
 * .kpi-card is a SHARED component used by every dashboard in
 * the platform (Financial, Payroll, CRM, HR, etc.).
 *
 * Fixed dimensions:
 *   height     : 120px  (!important)
 *   min-height : 120px  (!important)
 *   max-height : 120px  (!important)
 *   overflow   : hidden (!important)
 *
 * WHY these are !important:
 *   A local <style> block in a dashboard .razor file can silently
 *   override these values, causing cards across the dashboard to
 *   resize to their content and break the uniform grid layout.
 *   Using !important on the sizing properties makes any accidental
 *   local override a visible no-op, surfacing the conflict early.
 *
 * DO NOT override height / min-height / max-height / overflow
 * for .kpi-card in any dashboard-specific stylesheet or <style>
 * block. If a particular dashboard genuinely needs a different
 * card size, introduce a BEM modifier (.kpi-card--tall, etc.)
 * and document the reason here.
 * ============================================================
 */

/* KPI Cards */
.kpi-card {
    transition: all 0.25s ease;
    border-radius: 8px;
    background: white;
    border: 1px solid #e2e8f0;
    height: 120px !important;
    min-height: 120px !important;
    max-height: 120px !important;
    overflow: hidden !important;
    animation: slideIn 0.3s ease-out;
}

.kpi-card:hover {
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: translateY(-2px);
}

.kpi-card .mud-card-content {
    padding: 12px 14px !important;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.kpi-label {
    color: #64748b;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 28px);
}

.kpi-icon {
    color: #94a3b8;
    font-size: 20px;
    flex-shrink: 0;
}

.kpi-value {
    margin: 2px 0;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-trend-up {
    color: #10b981;
    font-weight: 500;
}

.kpi-trend-down {
    color: #ef4444;
    font-weight: 500;
}

.kpi-trend-neutral {
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-card .mud-typography-caption {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Specific card color accents */
.revenue-card .kpi-value {
    color: #2563eb;
}

.expenses-card .kpi-value {
    color: #ef4444;
}

.profit-card .kpi-value {
    color: #10b981;
}

.ar-card .kpi-value {
    color: #3b82f6;
}

.ap-card .kpi-value {
    color: #f59e0b;
}

.inventory-card .kpi-value {
    color: #8b5cf6;
}

.orders-card .kpi-value {
    color: #6366f1;
}

.users-card .kpi-value {
    color: #06b6d4;
}

/* Chart Cards */
.chart-card {
    border-radius: 8px;
    background: white;
    border: 1px solid #e2e8f0;
}

.chart-card .mud-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
}

.chart-card .mud-card-content {
    padding: 20px;
}

/* Recent Activity Table */
.recent-activity-table {
    font-size: 14px;
}

.recent-activity-table .mud-table-head {
    background: #f8fafc;
}

.recent-activity-table .mud-table-head .mud-table-cell {
    color: #64748b;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.recent-activity-table .mud-table-row:hover {
    background: #f8fafc;
}

/* Status Chips */
.status-posted {
    background: #ede9fe !important;
    color: #7c3aed !important;
    border: 1px solid #c4b5fd;
}

.status-approved {
    background: #d1fae5 !important;
    color: #047857 !important;
    border: 1px solid #6ee7b7;
}

.status-sent {
    background: #e0e7ff !important;
    color: #4338ca !important;
    border: 1px solid #a5b4fc;
}

.status-received {
    background: #dbeafe !important;
    color: #1e40af !important;
    border: 1px solid #93c5fd;
}

.status-due {
    background: #fef3c7 !important;
    color: #b45309 !important;
    border: 1px solid #fcd34d;
}

.status-draft {
    background: #f1f5f9 !important;
    color: #475569 !important;
    border: 1px solid #cbd5e1;
}

.status-default {
    background: #f1f5f9 !important;
    color: #64748b !important;
    border: 1px solid #cbd5e1;
}

/* Responsive adjustments */
@media (max-width: 960px) {
    .toolbar-content {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-actions {
        flex-wrap: wrap;
    }

    .search-field {
        min-width: 100%;
    }

    .chart-card .mud-card-content {
        padding: 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .chart-card .mud-chart-legend {
        font-size: 0.85rem;
        flex-wrap: wrap;
    }
}

@media (max-width: 600px) {
    .dashboard-toolbar {
        position: relative;
    }

    .toolbar-content {
        padding: 0 12px;
        gap: 10px;
    }

    .toolbar-actions {
        gap: 8px;
    }

    .date-range-select {
        min-width: 100%;
    }

    .search-field {
        min-width: 100%;
    }

    .kpi-value {
        font-size: 1.25rem !important;
    }

    .kpi-card .mud-card-content {
        padding: 10px 12px !important;
    }

    .chart-card .mud-card-content {
        padding: 8px;
    }

    .chart-card .mud-card-header {
        padding: 12px 14px;
    }

    .dashboard-content {
        padding-top: 12px;
        padding-bottom: 24px;
    }

    .recent-activity-table .mud-table-head {
        display: none;
    }

    .recent-activity-table .mud-table-row {
        display: flex;
        flex-direction: column;
        border-bottom: 1px solid #e2e8f0;
        padding: 10px 0;
    }

    .recent-activity-table .mud-table-cell {
        display: flex;
        justify-content: space-between;
        padding: 4px 12px !important;
        border-bottom: none !important;
    }

    .recent-activity-table .mud-table-cell::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 12px;
        color: #64748b;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        min-width: 90px;
    }

    .export-btn-text { display: none; }
}

/* Mobile card layout for recent activity */
.activity-card-mobile {
    display: none;
}

@media (max-width: 600px) {
    .activity-table-desktop {
        display: none;
    }

    .activity-card-mobile {
        display: block;
    }

    .activity-card-item {
        background: white;
        border: 1px solid #e2e8f0;
        border-radius: 10px;
        padding: 14px;
        margin-bottom: 10px;
        transition: box-shadow 0.2s ease;
    }

    .activity-card-item:active {
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }

    .activity-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 8px;
    }

    .activity-card-doc {
        font-weight: 700;
        font-size: 0.9rem;
        color: #1f2937;
    }

    .activity-card-detail {
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 0.82rem;
        color: #64748b;
        margin-top: 4px;
    }

    .activity-card-amount {
        font-weight: 600;
        font-size: 0.95rem;
        color: #1e40af;
    }
}

/* Touch-friendly targets */
@media (max-width: 768px) {
    .kpi-card {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .kpi-card:active {
        transform: scale(0.98);
    }
}

/* Animation keyframes */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chart-card {
    animation: slideIn 0.4s ease-out;
}
