/* receivablesPayables.css - Professional Financial SaaS Version */

/* ===== METRICS GRID - AR/AP DUAL LAYOUT ===== */
.rp-metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.875rem;
    padding: 1.25rem 0;
}

/* ===== SECTION HEADERS FOR AR AND AP ===== */
.rp-section-header {
    grid-column: span 3;
    background: #3b82f6;
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 6px;
    margin: 0.625rem 0 0.375rem 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #2563eb;
}

.rp-section-header.ar-section {
    background: #dc2626;
    border-color: #b91c1c;
}

.rp-section-header.ap-section {
    background: #3b82f6;
    border-color: #2563eb;
}

.rp-section-header.combined-section {
    background: #10b981;
    border-color: #059669;
}

.rp-section-header h4 {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: 0.025em;
}

/* ===== METRIC CARDS ===== */
.rp-metrics-grid .metric-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 1.25rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: box-shadow 0.2s ease;
    position: relative;
}

.rp-metrics-grid .metric-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.rp-metrics-grid .metric-label {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rp-metrics-grid .metric-value {
    font-size: 1.75rem;
    font-weight: 400;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Consolas', monospace;
    font-variant-numeric: tabular-nums;
    color: #1f2937;
    line-height: 1.2;
}

.rp-metrics-grid .metric-description {
    font-size: 0.8125rem;
    color: #6b7280;
    font-style: italic;
}

/* ===== SCORE-BASED COLORING FOR METRIC CARDS ===== */
.rp-metrics-grid .metric-card.score-excellent {
    border-left: 3px solid #059669;
}

.rp-metrics-grid .metric-card.score-excellent .metric-value {
    color: #059669;
}

.rp-metrics-grid .metric-card.score-good {
    border-left: 3px solid #10b981;
}

.rp-metrics-grid .metric-card.score-good .metric-value {
    color: #10b981;
}

.rp-metrics-grid .metric-card.score-fair {
    border-left: 3px solid #f59e0b;
}

.rp-metrics-grid .metric-card.score-fair .metric-value {
    color: #d97706;
}

.rp-metrics-grid .metric-card.score-poor {
    border-left: 3px solid #dc2626;
}

.rp-metrics-grid .metric-card.score-poor .metric-value {
    color: #dc2626;
}

/* ===== INSIGHTS PANEL ===== */
.rp-insights {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 1.5rem;
    margin-bottom: 1.875rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.rp-insights h4 {
    margin: 0 0 1.25rem 0;
    color: #1f2937;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    font-size: 1.125rem;
    font-weight: 600;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0.625rem;
}

.rp-insights .insights-list {
    display: flex;
    flex-direction: column;
    gap: 0.9375rem;
}

.rp-insights .insight-card {
    display: flex;
    align-items: flex-start;
    gap: 0.9375rem;
    padding: 0.9375rem;
    border-radius: 6px;
    border-left: 3px solid #d1d5db;
    background-color: #f9fafb;
}

.rp-insights .insight-card.positive {
    border-left-color: #10b981;
    background-color: #f0fdf4;
}

.rp-insights .insight-card.warning {
    border-left-color: #f59e0b;
    background-color: #fffbeb;
}

.rp-insights .insight-card.negative {
    border-left-color: #dc2626;
    background-color: #fef2f2;
}

.rp-insights .insight-card.info {
    border-left-color: #3b82f6;
    background-color: #eff6ff;
}

.rp-insights .insight-icon {
    font-size: 1.125rem;
    font-weight: 400;
    min-width: 20px;
    text-align: center;
    margin-top: 2px;
}

.rp-insights .insight-card.positive .insight-icon {
    color: #10b981;
}

.rp-insights .insight-card.warning .insight-icon {
    color: #d97706;
}

.rp-insights .insight-card.negative .insight-icon {
    color: #dc2626;
}

.rp-insights .insight-card.info .insight-icon {
    color: #3b82f6;
}

.rp-insights .insight-content h5 {
    margin: 0 0 0.5rem 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #1f2937;
}

.rp-insights .insight-content p {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.4;
    color: #374151;
}

/* ===== CHARTS SECTION ===== */
.rp-charts-section {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 1.875rem;
    justify-content: space-around;
}

.rp-chart-wrapper {
    flex: 1 1 450px;
    min-width: 400px;
    max-width: 100%;
    height: 450px;
    padding: 1.25rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background-color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
}

.rp-chart-wrapper .chart-title {
    text-align: center;
    font-size: 1.0625rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 0.9375rem 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    flex-shrink: 0;
    padding-bottom: 0.625rem;
    border-bottom: 1px solid #e5e7eb;
}

.rp-chart-wrapper canvas {
    flex-grow: 1;
    min-height: 0;
}

/* ===== SUMMARY NOTE ===== */
.rp-summary-note {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0.9375rem;
    margin-top: 1.25rem;
    text-align: center;
}

.rp-summary-note p {
    margin: 0;
    font-size: 0.875rem;
    color: #6b7280;
    line-height: 1.4;
}

/* ===== SPECIAL VISUAL INDICATORS FOR WORKING CAPITAL ===== */
.metric-card .working-capital-indicator {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #10b981;
}

.metric-card .working-capital-indicator.neutral {
    background: #f59e0b;
}

.metric-card .working-capital-indicator.negative {
    background: #dc2626;
}

/* ===== ENHANCED TOOLTIPS FOR COMPLEX METRICS ===== */
.metric-card[data-tooltip] {
    position: relative;
    cursor: help;
}

.metric-card[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8125rem;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 5px;
}

.metric-card[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    z-index: 1000;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1024px) {
    .rp-metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .rp-section-header {
        grid-column: span 2;
    }

    .rp-chart-wrapper {
        min-width: 350px;
    }
}

@media (max-width: 768px) {
    .rp-metrics-grid {
        grid-template-columns: 1fr;
        gap: 0.9375rem;
        padding: 0.9375rem 0;
    }

    .rp-section-header {
        grid-column: span 1;
        padding: 0.625rem 0.9375rem;
    }

    .rp-section-header h4 {
        font-size: 0.9375rem;
    }

    .rp-metrics-grid .metric-card {
        padding: 0.9375rem;
    }

    .rp-metrics-grid .metric-value {
        font-size: 1.5rem;
    }

    .rp-charts-section {
        flex-direction: column;
        gap: 1.25rem;
    }

    .rp-chart-wrapper {
        min-width: unset;
        height: 350px;
    }

    .rp-insights {
        padding: 1.25rem;
    }

    .rp-insights .insight-card {
        padding: 0.75rem;
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .rp-metrics-grid {
        padding: 0.75rem 0;
    }

    .rp-section-header {
        padding: 0.5rem 0.75rem;
    }

    .rp-section-header h4 {
        font-size: 0.875rem;
    }

    .rp-metrics-grid .metric-card {
        padding: 0.75rem;
    }

    .rp-metrics-grid .metric-value {
        font-size: 1.375rem;
    }

    .rp-chart-wrapper {
        height: 300px;
        padding: 0.9375rem;
    }

    .rp-chart-wrapper .chart-title {
        font-size: 0.9375rem;
    }

    .rp-insights {
        padding: 1rem;
    }

    .rp-insights h4 {
        font-size: 1rem;
    }

    .rp-insights .insight-card {
        flex-direction: column;
        text-align: center;
        padding: 0.75rem;
    }

    .rp-insights .insight-icon {
        align-self: center;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .rp-charts-section {
        flex-direction: column;
        page-break-inside: avoid;
    }

    .rp-chart-wrapper {
        height: 300px;
        page-break-inside: avoid;
        margin-bottom: 1.25rem;
        box-shadow: none;
        border: 1px solid #d1d5db;
    }

    .rp-insights {
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid #d1d5db;
    }

    .rp-metrics-grid {
        page-break-inside: avoid;
    }

    .rp-metrics-grid .metric-card {
        page-break-inside: avoid;
        box-shadow: none;
    }

    .rp-metrics-grid .metric-card:hover {
        box-shadow: none;
    }

    .rp-section-header {
        background: #f3f4f6;
        color: #1f2937;
        border: 1px solid #d1d5db;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .rp-insights .insight-card {
        page-break-inside: avoid;
    }

    .working-capital-indicator {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ===== ACCESSIBILITY ===== */
.rp-metrics-grid .metric-card:focus-within,
.rp-insights .insight-card:focus-within,
.rp-chart-wrapper:focus-within {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}
