/* Apply a professional, modern color scheme */
body {
    font-family: 'Roboto', sans-serif;
    background-color: #f5f7fa;
    color: #333;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Background gradient */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #e3f2fd 25%, #ffffff 100%);
    z-index: -1;
}

body.piedata-bg-dark::before {
    background: linear-gradient(135deg, #2c3e50 25%, #4ca1af 100%);
}

/* Subtle gradient background schemes */
.scheme1 {
    background: linear-gradient(45deg, #dfe9f3, #ffffff); /* Light blue */
}

.scheme2 {
    background: linear-gradient(45deg, #e6e9f0, #eef1f5); /* Light grey */
}

.scheme3 {
    background: linear-gradient(45deg, #f7f8fa, #e2ebf0); /* Light teal */
}

.scheme4 {
    background: linear-gradient(45deg, #f0f2f5, #ffffff); /* Light neutral */
}

.scheme5 {
    background: linear-gradient(45deg, #f7f7f7, #ffffff); /* Very light grey */
}

.piedata-container {
    width: 100%;
    max-width: 95%;
    margin: 0 auto;
    padding: 20px;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
}

body.piedata-bg-dark .piedata-container {
    background: rgba(52, 58, 64, 0.9);
    color: white;
}

body.piedata-bg-dark .piedata-instruction-box,
body.piedata-bg-dark .piedata-summary-container,
body.piedata-bg-dark #playerInfo,
body.piedata-bg-dark .piedata-data-table-container,
body.piedata-bg-dark .piedata-chart-container {
    background-color: #222;
    color: white;
    border-color: #555;
}

body.piedata-bg-dark .piedata-summary-content {
    background-color: #333;
}

.piedata-main-content {
    display: flex;
    width: 100%;
    margin: auto;
    overflow: hidden; /* Ensure the summary and player info boxes scroll alongside the table */
}

.piedata-summary-container,
#playerInfo {
    width: 22%;
    background-color: #ffffff; /* Ensure contrasting background */
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    padding: 1.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    color: black;
    position: sticky; /* Make the summary and player info boxes sticky */
    top: 0;
    height: 100%;
    overflow-y: auto; /* Allow scrolling */
    max-height: 400px; /* Adjust height to match content */
}

.piedata-summary-container {
    margin-right: 20px;
}

#playerInfo {
    margin-left: 20px;
}

.piedata-data-table-container {
    flex: 1;
    margin-right: 20px;
    margin-left: 20px;
    overflow: auto; /* Ensure the data table can scroll independently */
    background-color: #ffffff; /* Ensure contrasting background */
    padding: 10px;
    border-radius: 0.25rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.piedata-summary-container .piedata-summary-content,
#playerInfo .piedata-summary-content {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 0.25rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.piedata-summary-container p,
#playerInfo p {
    margin: 0.5rem 0;
    font-size: 1.1rem;
}

body.piedata-bg-dark .piedata-summary-container,
body.piedata-bg-dark #playerInfo {
    background-color: #222;
    border-color: #555;
}

body.piedata-bg-dark .piedata-summary-container .piedata-summary-content,
body.piedata-bg-dark #playerInfo .piedata-summary-content {
    background-color: #333;
    padding: 1rem;
    border-radius: 0.25rem;
    color: white;
}

body.piedata-bg-dark .piedata-summary-container p,
body.piedata-bg-dark #playerInfo p {
    color: white;
}

body.piedata-bg-dark .piedata-summary-container h3,
body.piedata-bg-dark #playerInfo h3 {
    color: white;
}

body.piedata-bg-dark .piedata-summary-container a,
body.piedata-bg-dark #playerInfo a {
    color: #00aaff;
}

.piedata-dark-mode-toggle {
    position: fixed;
    top: 10px;
    right: 10px;
}

.piedata-title {
    text-align: center;
    margin-bottom: 20px;
    font-size: 2rem;
    color: #007bff;
}

body.piedata-bg-dark .piedata-title {
    color: #66b2ff;
}

.piedata-form-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 30px;
}

.piedata-btn-primary {
    background-color: #007bff;
    border-color: #007bff;
    transition: background-color 0.3s ease-in-out, border-color 0.3s ease-in-out;
    color: white; /* Ensure text color is white */
}

.piedata-btn-primary:hover {
    background-color: #0056b3;
    border-color: #0056b3;
}

body.piedata-bg-dark .piedata-btn-primary {
    background-color: #0056b3;
    border-color: #0056b3;
    color: white; /* Ensure text color is white */
}

.piedata-btn-info {
    background-color: #17a2b8;
    border-color: #17a2b8;
    transition: background-color 0.3s ease-in-out, border-color 0.3s ease-in-out;
}

.piedata-btn-info:hover {
    background-color: #117a8b;
    border-color: #117a8b;
}

body.piedata-bg-dark .piedata-btn-info {
    background-color: #117a8b;
    border-color: #117a8b;
}

.piedata-filters-container {
    text-align: center;
    margin-bottom: 20px;
}

.piedata-filters-container label {
    margin-right: 10px;
}

.piedata-filters-container select {
    margin-right: 20px;
}

.piedata-table-responsive {
    width: 100%;
    overflow-x: auto;
}

.piedata-table {
    width: 100%;
    border-collapse: collapse;
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

body.piedata-bg-dark .piedata-table {
    background-color: #222;
    border-color: #555;
    color: white; /* Ensure text color is white in dark mode */
}

.piedata-table th,
.piedata-table td {
    padding: 12px 15px;
    border: 1px solid #dee2e6;
    text-align: left;
    color: inherit; /* Inherit color to ensure text color changes in dark mode */
}

body.piedata-bg-dark .piedata-table th,
body.piedata-bg-dark .piedata-table td {
    border-color: #555;
    color: white; /* Ensure text color is white in dark mode */
}

.piedata-table th {
    background-color: #007bff;
    color: white;
    font-weight: bold;
}

body.piedata-bg-dark .piedata-table th {
    background-color: #0056b3;
    color: white;
}

.piedata-table tbody tr {
    transition: background-color 0.3s ease;
}

.piedata-table tbody tr:hover {
    background-color: #f1f1f1;
}

body.piedata-bg-dark .piedata-table tbody tr:hover {
    background-color: #333;
}

.piedata-table tbody tr:nth-of-type(odd) {
    background-color: #f9f9f9;
}

.piedata-table tbody tr:nth-of-type(even) {
    background-color: #ffffff;
}

body.piedata-bg-dark .piedata-table tbody tr:nth-of-type(odd) {
    background-color: #2c2c2c;
}

body.piedata-bg-dark .piedata-table tbody tr:nth-of-type(even) {
    background-color: #333;
}

.piedata-canvas {
    width: 100%;
    height: 80%;
    max-height: 400px; /* Set maximum height for the chart */
    transition: all 0.5s ease-in-out;
    background-color: #ffffff !important; /* Ensure contrasting background */
    border-radius: 0.25rem;
    padding: 10px;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

body.piedata-bg-dark .piedata-canvas {
    background-color: #222 !important; /* Ensure contrasting background */
}

.piedata-chart-container {
    margin-top: 30px;
    width: 100%;
    max-width: 95%;
    margin: auto;
    background-color: #ffffff; /* Ensure contrasting background */
    border-radius: 0.25rem;
    padding: 10px;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

body.piedata-bg-dark .piedata-chart-container {
    background-color: #222; /* Ensure contrasting background */
    border-color: #555;
}

/* Loading Spinner */
.spinner-border {
    display: block;
    margin: 0 auto;
}

/* Placeholder Styles */
.placeholder {
    opacity: 0.6;
    background-color: #e0e0e0;
    animation: placeholder-pulse 1.5s infinite;
}

body.piedata-bg-dark .placeholder {
    background-color: #444;
}

.placeholder-glow .placeholder {
    display: inline-block;
    min-height: 1em;
    vertical-align: middle;
    border-radius: 4px;
}

@keyframes placeholder-pulse {
    0% {
        background-color: #e0e0e0;
    }
    50% {
        background-color: #f0f0f0;
    }
    100% {
        background-color: #e0e0e0;
    }
}

body.piedata-bg-dark @keyframes placeholder-pulse {
    0% {
        background-color: #444;
    }
    50% {
        background-color: #555;
    }
    100% {
        background-color: #444;
    }
}

/* Initial Loading Message */
#initialLoadingMessage {
    font-size: 1.2rem;
    color: #6c757d;
    margin-bottom: 20px;
}

body.piedata-bg-dark #initialLoadingMessage {
    color: #cccccc;
}

/* Instruction Box */
.piedata-instruction-box {
    background-color: #ffffff;
    border-radius: 0.25rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    margin-bottom: 30px;
    padding: 20px;
    color: #333;
}

body.piedata-bg-dark .piedata-instruction-box {
    background-color: #222;
    color: white;
}

h3 {
    color: #007bff;
}

body.piedata-bg-dark h3 {
    color: #66b2ff;
}

h2.piedata-title {
    color: #007bff;
}

body.piedata-bg-dark h2.piedata-title {
    color: #66b2ff;
}

#piedata-summaryTotals p, #piedata-summaryAverages p, #piedata-dateRange {
    font-size: 1.1rem;
}

#piedata-summaryTotals p strong, #piedata-summaryAverages p strong {
    color: #007bff;
}

body.piedata-bg-dark #piedata-summaryTotals p strong, 
body.piedata-bg-dark #piedata-summaryAverages p strong {
    color: #66b2ff;
}

table.dataTable {
    border-collapse: separate;
    border-spacing: 0;
}

table.dataTable th,
table.dataTable td {
    border-right: 1px solid #ddd;
}

body.piedata-bg-dark table.dataTable th,
body.piedata-bg-dark table.dataTable td {
    border-right: 1px solid #555;
}

table.dataTable th {
    background-color: #007bff;
    color: white;
}

body.piedata-bg-dark table.dataTable th {
    background-color: #0056b3;
    color: white;
}

table.dataTable tr:nth-child(odd) {
    background-color: #f9f9f9;
}

table.dataTable tr:nth-child(even) {
    background-color: #ffffff;
}

body.piedata-bg-dark table.dataTable tr:nth-child(odd) {
    background-color: #2c2c2c;
}

body.piedata-bg-dark table.dataTable tr:nth-child(even) {
    background-color: #333;
}

table.dataTable tr:hover {
    background-color: #e9ecef;
}

body.piedata-bg-dark table.dataTable tr:hover {
    background-color: #333;
}

/* Update the width and positioning of playerInfo to accommodate topPlayers */
#playerInfo {
    margin-left: 0;
    margin-bottom: 20px; /* Add some space between playerInfo and topPlayers */
}

#topPlayers {
    width: 22%;
    background-color: #ffffff; /* Ensure contrasting background */
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    padding: 1.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    color: black;
}

body.piedata-bg-dark #topPlayers {
    background-color: #222;
    border-color: #555;
    color: white;
}

body.piedata-bg-dark #topPlayers a {
    color: #00aaff;
}
