/* ===== Dashboard / Home Page Styles ===== */

/* ---------- Page layout ---------- */
.home-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px 40px;
}

/* ---------- KPI Cards ---------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #fff;
    border: 1px solid #e8ecf0;
    border-radius: 8px;
    padding: 18px 20px;
    text-decoration: none;
    color: #2c3e50;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.kpi-card:hover {
    border-color: #3498db;
    box-shadow: 0 2px 10px rgba(52, 152, 219, 0.12);
}

.kpi-icon {
    font-size: 32px;
    color: #3498db;
}

.kpi-body {
    display: flex;
    flex-direction: column;
}

.kpi-value {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.2;
}

.kpi-label {
    font-size: 13px;
    color: #7f8c8d;
    margin-top: 2px;
}

/* ---------- Panels ---------- */
.home-panel {
    background: #fff;
    border: 1px solid #e8ecf0;
    border-radius: 8px;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

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

.panel-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 6px;
}

.panel-icon {
    font-size: 20px;
    color: #3498db;
}

.panel-view-all {
    font-size: 13px;
    color: #3498db;
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
}

.panel-view-all:hover {
    text-decoration: underline;
}

/* ---------- Middle Row: Chart + Activity ---------- */
.home-middle {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.chart-panel {
    flex: 3;
    min-width: 0;
}

.activity-panel {
    flex: 2;
    min-width: 0;
}

/* ---------- CSS Bar Chart ---------- */
.chart-container {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 180px;
    padding-top: 8px;
}

.chart-bar-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}

.chart-bar {
    width: 100%;
    max-width: 48px;
    background: #3498db;
    border-radius: 4px 4px 0 0;
    transition: height 0.4s ease;
    min-height: 2px;
    position: relative;
}

.chart-bar:hover {
    background: #2980b9;
}

.chart-bar-tooltip {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #2c3e50;
    color: #fff;
    font-size: 11px;
    padding: 3px 7px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}

.chart-bar:hover .chart-bar-tooltip {
    opacity: 1;
}

.chart-bar-label {
    margin-top: 6px;
    font-size: 11px;
    color: #7f8c8d;
    text-align: center;
}

.chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #95a5a6;
    font-size: 14px;
}

/* ---------- Activity Feed ---------- */
.activity-feed {
    flex: 1;
    overflow-y: auto;
    max-height: 220px;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
    color: #2c3e50;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-item .material-symbols-outlined {
    font-size: 18px;
    color: #3498db;
    margin-top: 1px;
    flex-shrink: 0;
}

.activity-text {
    flex: 1;
    min-width: 0;
    line-height: 1.4;
}

.activity-text strong {
    font-weight: 600;
}

.activity-time {
    font-size: 11px;
    color: #95a5a6;
    white-space: nowrap;
    margin-top: 1px;
}

/* ---------- Bottom Lists ---------- */
.home-bottom {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.panel-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.panel-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 6px;
    border-radius: 6px;
    font-size: 13px;
    color: #2c3e50;
    text-decoration: none;
    transition: background 0.15s;
}

.panel-list-item:hover {
    background: #f4f7f9;
}

.panel-list-primary {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
}

.panel-list-secondary {
    font-size: 12px;
    color: #7f8c8d;
    white-space: nowrap;
    margin-left: 8px;
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.panel-list-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: 8px;
}

.badge-paid       { background: #e8f5e9; color: #2e7d32; }
.badge-sent       { background: #e3f2fd; color: #1565c0; }
.badge-draft      { background: #f5f5f5; color: #757575; }
.badge-overdue    { background: #fbe9e7; color: #c62828; }
.badge-active     { background: #e8f5e9; color: #2e7d32; }
.badge-new        { background: #e3f2fd; color: #1565c0; }

.home-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 0;
    color: #95a5a6;
    font-size: 13px;
}

.home-empty {
    color: #95a5a6;
    font-size: 13px;
    text-align: center;
    padding: 24px 0;
}

/* ---------- Mobile (≤ 700px) ---------- */
@media (max-width: 700px) {
    .home-page {
        padding: 16px 12px 32px;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .kpi-card {
        padding: 14px 14px;
        gap: 10px;
    }

    .kpi-icon {
        font-size: 26px;
    }

    .kpi-value {
        font-size: 22px;
    }

    .home-middle {
        flex-direction: column;
    }

    .home-bottom {
        grid-template-columns: 1fr;
        overflow: hidden;
    }

    .home-panel {
        padding: 14px 14px;
    }

    .panel-list-item {
        padding: 7px 4px;
    }

    .panel-list-badge {
        font-size: 10px;
        padding: 2px 6px;
    }

    .chart-container {
        height: 140px;
    }

    .activity-feed {
        max-height: 260px;
    }
}
