/*
 * DCP Leaderboard Plugin
 * Copyright (C) 2025 Joseph Galea
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

/* Filter Styling */
form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background-color: #F5F5F5;
  /* Fair Gray from gradient */
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 65, 101, 0.15);
  /* Loyal Blue tint */
  font-family: 'Montserrat', sans-serif;
  /* Free alternate to Gotham */
}

form label {
  font-weight: 600;
  margin-right: 0.25rem;
  color: #004165;
  /* Loyal Blue */
}

form select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #A9B2B1;
  /* Cool Gray */
  border-radius: 6px;
  background-color: #FFFFFF;
  font-size: 0.95rem;
  font-family: 'Montserrat', sans-serif;
  color: #004165;
  transition: border-color 0.2s;
}

form select:focus {
  border-color: #004165;
  outline: none;
}

form input[type="submit"] {
  padding: 0.5rem 1rem;
  background-color: #004165;
  /* Loyal Blue */
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: 'Montserrat', sans-serif;
  cursor: pointer;
  transition: background-color 0.2s;
}

form input[type="submit"]:hover {
  background-color: #006094;
  /* Blissful Blue gradient end */
}

.custom-table-filter {
  margin-left: auto;
}

/* Pagination Styling */
.custom-table-pagination {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Source Sans 3', sans-serif;
  /* Free alternate to Myriad Pro */
  flex-wrap: wrap;
}

.custom-table-pagination .page-numbers {
  padding: 0.4rem 0.8rem;
  text-decoration: none;
  border: 1px solid #A9B2B1;
  /* Cool Gray */
  border-radius: 6px;
  color: #004165;
  /* Loyal Blue */
  background-color: #fff;
  transition: background-color 0.2s;
}

.custom-table-pagination .page-numbers:hover {
  background-color: #e6f0ff;
  /* Soft Loyal Blue tint */
}

.custom-table-pagination .current {
  background-color: #004165;
  color: white;
  border-color: #006094;
  /* Blissful Blue */
}


/**Table Styling**/
.dt-length label {
  margin-left: 10px;
}

.custom-table-filter {
  margin-left: 10px;
}

.custom-table-filter label {
  margin-right: 5px;
}

.custom-table-filter select {
  margin-right: 10px;
}

/* Container Styling */
.modern-table-container {
  border: 1px solid #A9B2B1;
  /* Cool Gray border */
  padding: 20px;
  margin: 30px 0;
  background-color: #F5F5F5;
  /* Fair Gray background */
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 65, 101, 0.08);
  /* Toastmasters-style subtle depth */
}

/* Title Styling */
.modern-table-container h3 {
  font-size: 1.6em;
  color: #004165;
  /* Loyal Blue */
  margin-bottom: 15px;
  font-weight: 600;
}

/* Table Styling */
.modern-table-container table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Segoe UI', sans-serif;
  font-size: 0.95em;
}

/* Header Row */
.modern-table-container thead {
  background-color: #772432;
  /* True Maroon */
  color: #ffffff;
}

.modern-table-container th {
  padding: 12px 15px;
  text-align: left;
}

/* Table Body */
.modern-table-container td {
  padding: 10px 15px;
  border-bottom: 1px solid #ddd;
}

/* Row Hover */
.modern-table-container tbody tr:hover {
  background-color: #F2DF74;
  /* Happy Yellow highlight */
}

/* Zebra Striping */
.modern-table-container tbody tr:nth-child(even) {
  background-color: #ffffff;
}

.modern-table-container tbody tr:hover:nth-child(even) {
  background-color: #F2DF74;
  /* Happy Yellow highlight */
}

/* Status Column Special Styling */
.modern-table-container td:last-child {
  font-weight: bold;
  text-align: left;
  color: #004165;
  /* Loyal Blue */
}

/**goal progress bar styling**/
.bar-container {
  width: 100px;
  /* fixed width for scaling */
  height: 20px;
  background-color: #eee;
  border: 1px solid #ccc;
  position: relative;
}

.bar-fill {
  height: 100%;
  background-color: #006094;
  /* Green fill */
  transition: width 0.3s ease;
}


.progress-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  /* spacing between bar and text */
}

.progress-container {
  width: 100px;
  background-color: #eee;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 20px;
  width: 0%;
  transition: width 2s ease-in-out;
}

.progress-text {
  font-size: 0.95em;
  white-space: nowrap;
}

.promotion-marker {
  display: inline-block;
  width: 12px;
  /* Fixed width */
  text-align: right;
  /* Align text to the right inside the span */
  margin-right: 5px;
  /* Optional spacing between label and content */
}

.top-controls {
  display: flex;
  flex-direction: row;
  gap: 16px;
  /* Adjust spacing between length and search */
  margin-bottom: 20px;
  margin-top: 20px;
  position: sticky;
  top: 0;
  z-index: 2000;
  /* sit above DataTables FixedHeader clone */
  background-color: #F5F5F5;
  /* match filter background */
  padding: 0.5rem 1rem;
}

.bottom-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
  /* Adjust spacing between length and search */
  margin-bottom: 20px;
  margin-top: 20px;
}

/* On small screens, make controls non-sticky so they flow naturally */
@media (max-width: 767px) {
  .top-controls,
  .bottom-controls {
    position: static !important;
    top: auto !important;
    bottom: auto !important;
    z-index: auto !important;
    padding: 0.25rem 0 !important;
    background: transparent !important;
  }
}

.top-controls .dataTables_length,
.top-controls .dataTables_filter {
  display: block;
}

.dataTables_length {
  align-self: flex-start;
}

.dataTables_filter {
  align-self: flex-end;
}

.filter-block {
  margin-bottom: 5px;
}

table.dataTable td.child {
  width: 100%;
}

table.dataTable td.child ul.dtr-details {
  display: block;
  width: 100%;
  box-sizing: border-box;
}

table.dataTable td.child ul.dtr-details>li {
  width: 100%;
}

/* Legend styling (moved from inline) */
.leaderboard-legend {
  margin-bottom: 12px;
  font-size: 0.95rem;
  display: block;
  background: #ffffff;
  border: 1px solid #e6e6e6;
  padding: 8px 12px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.leaderboard-legend strong {
  display: block;
  margin-bottom: 8px;
  color: #004165;
}

.leaderboard-legend .legend-item {
  display: block;
  margin-bottom: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.02);
  color: #222;
}

.leaderboard-legend .legend-group {
  display: block;
  margin-bottom: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  color: #004165;
  background: rgba(0, 0, 0, 0.01);
}

/* small circular badges for series */
.legend-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
}

.badge-a {
  background: #ffbf00;
  color: #2b2b2b;
}

.badge-b {
  background: #006094;
}

.badge-c {
  background: #2e8b57;
}

.badge-d {
  background: #6c757d;
}

/* icons inside legend groups */
.leaderboard-legend .legend-icon {
  display: inline-block;
  min-width: 20px;
  text-align: center;
}

.header-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.info-icon {
  cursor: pointer;
  font-size: 14px;
}

/* Ensure Bootstrap tooltips/popovers appear above sticky controls */
.tooltip,
.bs-tooltip-top,
.bs-tooltip-auto,
.popover,
[data-popper-placement],
.popper {
  z-index: 99999 !important;
}
