/* Grid container */
.chart-grid-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    /* 2 columns */
    gap: 20px;
    /* Space between items */
    margin-top: 20px;
}

.chart-grid-item {
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    height: 350px;
    /* Fixed height for all grid items to maintain consistency */
}

/* Dark mode styles for charts */
[data-theme="dark"] .chart-grid-item {
    background-color: #2d2d2d;
    /* Dark background */
    border: 1px solid #555;
    /* Darker border */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    /* Darker shadow */
}

[data-theme="dark"] .chart-grid-item h3 {
    color: #f0f0f0;
    /* Lighter text in dark mode */
    border-bottom-color: #6a63f6;
    /* Keep the purple bar */
}

[data-theme="dark"] #summaryTable,
[data-theme="dark"] #summaryTable th,
[data-theme="dark"] #summaryTable td,
[data-theme="dark"] #phase2SolutionsTable,
[data-theme="dark"] #phase2SolutionsTable th,
[data-theme="dark"] #phase2SolutionsTable td {
    border-color: #555;
    /* Darker table borders */
}

[data-theme="dark"] #summaryTable th,
[data-theme="dark"] #phase2SolutionsTable th {
    background-color: #444;
    /* Darker header background */
    color: #fff;
    /* Lighter header text */
}

[data-theme="dark"] #summaryTable tr:nth-child(even),
[data-theme="dark"] #phase2SolutionsTable tr:nth-child(even) {
    background-color: #3a3a3a;
    /* Darker alternate row color */
}

.chart-grid-item h3 {
    color: #333;
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: 2px solid #6a63f6;
    padding-bottom: 10px;
    text-align: center;
    flex-shrink: 0;
    /* Don't shrink the heading */
}

/* Specific styles for the summary table */
#summaryTable {
    width: 100%;
    border-collapse: collapse;
    margin-top: auto;
    /* Pushes table to the top if content is short */
    flex-grow: 1;
    /* Allows table to grow and fill space */
    flex-shrink: 0;
    /* Don't shrink the table */
}

#summaryTable,
#summaryTable th,
#summaryTable td {
    border: 1px solid #ccc;
}

#summaryTable th,
#summaryTable td {
    padding: 8px;
    text-align: left;
    font-size: 0.9em;
    /* Slightly smaller font for table */
}

#summaryTable th {
    background-color: #f2f2f2;
    font-weight: bold;
}

#summaryTable tr:nth-child(even) {
    background-color: #f9f9f9;
}

/* Specific styles for the Phase 2 Solutions table */
#phase2SolutionsTable {
    width: 100%;
    border-collapse: collapse;
    margin-top: auto;
    /* Pushes table to the top if content is short */
    flex-grow: 1;
    /* Allows table to grow and fill space */
    flex-shrink: 0;
    /* Don't shrink the table */
}

#phase2SolutionsTable,
#phase2SolutionsTable th,
#phase2SolutionsTable td {
    border: 1px solid #ccc;
}

#phase2SolutionsTable th,
#phase2SolutionsTable td {
    padding: 8px;
    text-align: left;
    font-size: 0.9em;
    /* Slightly smaller font for table */
}

#phase2SolutionsTable th {
    background-color: #f2f2f2;
    font-weight: bold;
}

#phase2SolutionsTable tr:nth-child(even) {
    background-color: #f9f9f9;
}

/* Container for charts to allow proper sizing */
.chart-container {
    flex: 1;
    /* Take remaining space */
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 200px;
    /* Ensure there's enough space for the chart */
}

/* Apply to canvas elements */
.chart-container canvas {
    width: 100% !important;
    /* Override Chart.js width */
    max-width: 100%;
    height: 100% !important;
    /* Override Chart.js height */
    max-height: 250px;
    /* Maximum height for charts */
    margin: 0 auto;
    /* Center the chart horizontally */
    display: block;
    /* Ensure proper display */
    box-sizing: border-box;
    /* Include padding and border in width calculation */
}

/* Apply width reduction only to the two bar charts */
#problemsChart,
#techChart {
    width: 100% !important;
    max-width: 100%;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .chart-grid-container {
        grid-template-columns: 1fr;
        /* Stack items vertically on small screens */
    }

    #summaryTable {
        font-size: 0.8em;
        overflow-x: auto;
        /* Allow horizontal scroll if table is too wide */
    }

    #summaryTable th,
    #summaryTable td {
        padding: 5px;
    }

    .chart-grid-item {
        padding: 15px;
    }



    /* Additional layout for mobile - ensure proper centering when parent becomes flex container */
    .chart-2-item,
    .chart-3-item,
    .chart-4-item {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }

    /* Ensure chart containers maintain proper centering within flex parents */
    .chart-2-item .chart-container,
    .chart-3-item .chart-container,
    .chart-4-item .chart-container {
        width: 100%;
        align-self: center;
    }

    /* Extend table container vertically on mobile */
    .phase2-solutions-container {
        min-height: 450px;
        /* Further increased height to accommodate all table rows */
        height: auto;
        /* Allow it to grow as needed */
    }
}