/**
 * Custom CSS for Group Attendance Report
 * Styling with bslib and dark mode support
 */

/* Button styling */
.btn-outline-primary {
  --bs-btn-color: #585A5D;
  --bs-btn-border-color: #585A5D;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: #3E98A2;
  --bs-btn-bg: #fff;
  --bs-btn-border-radius: 6px;
}

.btn-outline-primary:hover {
  --bs-btn-bg: #f2f2f2;
  --bs-btn-active-bg: #35858D;
  --bs-btn-color: #3e3f42;
}

/* Export buttons styling */
.buttons-csv, .buttons-excel, .buttons-pdf {
  background-color: #0E5155 !important;
  color: #ffffff !important;
  border: #000; 
  border-radius: 6px !important; 
  margin: 7px;
  font-size: 12px;
}

.buttons-csv:hover, .buttons-excel:hover, .buttons-pdf:hover {
  background-color: #0b4044 !important;
}

/* Custom download button styling */
.custom-download-btn {
  background-color: #0E5155;
  color: #ffffff !important;
  margin-top: 15px;
  height: 40px;
  min-width: 200px;
  border-color: #fff;
  border-radius: 6px;
  font-size: 16px;
  --bs-btn-padding-y: 2px;
}

.custom-download-btn:hover {
  background-color: #157e84;
}

/* Header formatting */
.h4-top-format {
  font-size: 22px;
  margin-top: 10px;
  text-decoration: underline;
  color: #fff;
}

.h4-middle-format {
  font-size: 22px;
  margin-top: 30px;
  padding-bottom: 10px;
  text-decoration: underline;
  color: #fff;
}

/* Pretty switch styling */
.pretty.p-switch.p-fill input:checked~.state:before {
  background-color: #3E98A2 !important;
  border-color: #3E98A2 !important;
}

/* Checkbox styling */
.shiny-input-container .checkbox input[type='checkbox'] {
  border-radius: 4px;
}

/* Input controls styling */
.selectize-input {
  border-radius: 6px !important;
}

/* Bootstrap-select styling - Light mode (default) */
.bootstrap-select {
  background-color: transparent !important;
}

.bootstrap-select > .dropdown-toggle {
  border-radius: 6px !important;
  background-color: #ffffff !important;
  height: 38px !important;
  color: #333 !important;
  padding-top: 6px !important;
  padding-bottom: 6px !important;
  border: 1px solid #ccc !important;
}

.bootstrap-select.btn-group {
  background-color: transparent !important;
  border-radius: 6px !important;
}

.bootstrap-select.btn-group .dropdown-toggle {
  border-radius: 6px !important;
}

.bootstrap-select .dropdown-menu {
  border-radius: 6px !important;
  background-color: #ffffff !important;
  border: 1px solid #ccc !important;
  margin-top: 2px !important;
}

.bootstrap-select .dropdown-menu li a {
  color: #333 !important;
  padding: 8px 12px !important;
}

.bootstrap-select .dropdown-menu li a:hover,
.bootstrap-select .dropdown-menu li a:focus {
  background-color: #f5f5f5 !important;
}

.bootstrap-select .bs-actionsbox .btn {
  background-color: #0E5155;
  border-color: #0E5155;
  color: #FFFFFF;
  border-radius: 4px;
}

.bootstrap-select .bs-actionsbox .btn:hover {
  background-color: #0b4044;
}

.bootstrap-select > .dropdown-toggle.bs-placeholder {
  color: #999 !important;
}

/* Fix border-radius on inner button element */
.bootstrap-select.btn-group .dropdown-menu {
  border-radius: 6px !important;
}

/* Date range input styling */
.input-daterange input:first-child {
  border-radius: 6px 0 0 6px !important;
}

.input-daterange input:last-child {
  border-radius: 0 6px 6px 0 !important;
}

/* Navbar styling */
.navbar {
  --bslib-page-sidebar-title-bg: #0E5155 !important;
  --bslib-page-sidebar-title-color: white;
  max-height: 65px !important;
  min-height: 65px !important;
  height: 65px !important;
  --bs-navbar-brand-font-size: 26px;
  background-color: #0E5155 !important;
}

.navbar a, .navbar span, .navbar .report-title span,
.navbar .flourish-link, .navbar .insights-link {
  color: white !important;
}

/* Header nav links */
.header-nav-links {
  display: flex;
  align-items: center;
}

.header-nav-links a {
  color: white;
  text-decoration: none;
  font-size: 14px;
}

/* Report title styling */
.report-title {
  position: absolute !important;
  left: 0 !important;
  right: 0 !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  text-align: center !important;
  margin: 0 !important;
  padding: 0 !important;
}

.report-title span {
  font-size: 28px !important;
}

/* bslib value box fixes */
.bslib-value-box .value-box-showcase .fas, 
.bslib-value-box .value-box-showcase .far {
  opacity: 1 !important;
}

/* Plot container and card styling */
.plot-card {
  transition: background-color 0.3s ease;
}

/* DataTable styling */
.dataTables_wrapper {
  margin-top: 15px;
}

table.dataTable {
  border-collapse: collapse !important;
  margin-top: 15px !important;
}

table.dataTable thead th {
  padding: 10px !important;
  background-color: #0E5155 !important;
  color: white !important;
  border-bottom: 1px solid #ddd !important;
}

table.dataTable tbody td {
  padding: 8px !important;
  border-bottom: 1px solid #eee;
}

table.dataTable.stripe tbody tr.odd {
  background-color: rgba(0, 0, 0, 0.03);
}

table.dataTable.hover tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.05) !important;
}

table.display.dataTable > tbody > tr.selected > *,
table.display.dataTable > tbody > tr.odd.selected > *,
table.display.dataTable > tbody > tr.selected:hover > * {
  background-color: #AAD7A5 !important;
  box-shadow: 0 0 3px #AAD7A5 !important;
}

/* Loading and error screens */
#loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.75);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: background-color 0.3s ease;
}

#error-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.95);
  z-index: 9999;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: background-color 0.3s ease;
}

.error-message {
  color: #333;
  font-size: 18px;
  margin-top: 20px;
  text-align: center;
  max-width: 600px;
  font-weight: bold;
  padding: 15px;
  background-color: #f8f9fa;
  border-radius: 10px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.error-message a {
  color: #0E5155;
  text-decoration: underline;
}

.loading-message {
  color: white;
  font-size: 18px;
  margin-top: 30px;
  text-align: center;
  max-width: 600px;
  font-weight: bold;
  padding: 15px;
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 10px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dots spinner styles */
.dots-spinner {
  width: 200px;
  height: 200px;
  position: relative;
  margin: 0 auto;
}

.dots-spinner .dot {
  width: 24px;
  height: 24px;
  background-color: #0E5155;
  border-radius: 50%;
  position: absolute;
  animation: dotFade 1.8s infinite ease-in-out both;
}

.dots-spinner .dot1 { top: 24px; left: 84px; background-color: #AAD7A5; animation-delay: -1.65s; }
.dots-spinner .dot2 { top: 32px; left: 112px; background-color: #3E98A2; animation-delay: -1.5s; }
.dots-spinner .dot3 { top: 64px; left: 120px; background-color: #0E5155; animation-delay: -1.35s; }
.dots-spinner .dot4 { top: 96px; left: 112px; background-color: #78C2C8; animation-delay: -1.2s; }
.dots-spinner .dot5 { top: 104px; left: 84px; background-color: #3E98A2; animation-delay: -1.05s; }
.dots-spinner .dot6 { top: 96px; left: 56px; background-color: #AAD7A5; animation-delay: -0.9s; }
.dots-spinner .dot7 { top: 64px; left: 48px; background-color: #0E5155; animation-delay: -0.75s; }
.dots-spinner .dot8 { top: 32px; left: 56px; background-color: #78C2C8; animation-delay: -0.6s; }

@keyframes dotFade {
  0%, 100% { opacity: 0.3; transform: scale(0.7); }
  50% { opacity: 1; transform: scale(1); }
}

/* Dark mode styles */
html.dark-mode-html {
  color-scheme: dark;
}

:root {
  --dark-bg-color: #121212;
  --dark-card-bg: #1e1e1e;
  --dark-surface: #242424;
  --dark-border: #333333;
  --dark-text-primary: #e0e0e0;
  --dark-text-secondary: #a0a0a0;
  --dark-primary: #0E5155;
  --dark-secondary: #3E98A2;
  --dark-success: #AAD7A5;
  --dark-hover: #2e2e2e;
}

body.dark-mode {
  background-color: var(--dark-bg-color) !important;
  color: var(--dark-text-primary) !important;
}

body.dark-mode .navbar {
  background-color: var(--dark-primary) !important;
}

body.dark-mode .sidebar {
  background-color: #333333 !important;
  border-right: 1px solid var(--dark-border);
}

body.dark-mode .form-control,
body.dark-mode .selectize-input,
body.dark-mode .bootstrap-select > .dropdown-toggle {
  background-color: var(--dark-card-bg);
  color: var(--dark-text-primary);
  border-color: var(--dark-border);
}

body.dark-mode .selectize-dropdown,
body.dark-mode .dropdown-menu {
  background-color: var(--dark-surface);
  color: var(--dark-text-primary);
  border-color: var(--dark-border);
}

/* Bootstrap-select dark mode overrides */
body.dark-mode .bootstrap-select > .dropdown-toggle {
  background-color: #262626 !important;
  color: white !important;
  border-color: var(--dark-border) !important;
}

body.dark-mode .bootstrap-select > .dropdown-toggle.bs-placeholder {
  color: #aaa !important;
}

body.dark-mode .bootstrap-select .dropdown-menu {
  background-color: #262626 !important;
  border-color: var(--dark-border) !important;
}

body.dark-mode .bootstrap-select .dropdown-menu li a {
  color: white !important;
}

body.dark-mode .bootstrap-select .dropdown-menu li a:hover,
body.dark-mode .bootstrap-select .dropdown-menu li a:focus {
  background-color: #444444 !important;
}

body.dark-mode .plot-card {
  background-color: white !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

body.dark-mode .bslib-value-box {
  background-color: var(--dark-card-bg) !important;
  border-color: var(--dark-border) !important;
}

body.dark-mode table.dataTable {
  background-color: var(--dark-card-bg) !important;
  color: var(--dark-text-primary) !important;
  border-color: var(--dark-border) !important;
}

body.dark-mode table.dataTable thead th,
body.dark-mode table.dataTable tbody td {
  border-color: var(--dark-border) !important;
  background-color: var(--dark-card-bg) !important;
  color: var(--dark-text-primary) !important;
}

body.dark-mode table.dataTable thead th {
  background-color: var(--dark-primary) !important;
}

body.dark-mode table.dataTable.stripe tbody tr.odd {
  background-color: #242424 !important;
}

body.dark-mode table.dataTable.hover tbody tr:hover {
  background-color: var(--dark-hover) !important;
}

body.dark-mode .dataTables_info,
body.dark-mode .dataTables_length,
body.dark-mode .dataTables_filter,
body.dark-mode .dataTables_paginate {
  color: var(--dark-text-secondary) !important;
}

body.dark-mode .dataTables_filter input,
body.dark-mode .dataTables_length select {
  background-color: var(--dark-card-bg);
  color: var(--dark-text-primary);
  border: 1px solid var(--dark-border);
}

body.dark-mode #loading-screen {
  background-color: rgba(18, 18, 18, 0.95) !important;
}

body.dark-mode #error-screen {
  background-color: rgba(18, 18, 18, 0.95);
}

body.dark-mode .error-message {
  color: var(--dark-text-primary);
  background-color: var(--dark-card-bg);
}

body.dark-mode .loading-message {
  color: #e0e0e0 !important;
  background-color: #1e1e1e !important;
}

/* Mobile styles */
@media (max-width: 767px) {
  .mobile-menu-btn {
    display: block !important;
  }
  
  #dark-mode-container {
    display: none !important;
  }
  
  .report-title {
    position: static !important;
    transform: none !important;
    width: 100% !important;
    text-align: center !important;
    padding: 5px 60px !important;
  }
  
  .report-title span {
    font-size: 16px !important;
  }
  
  .header-nav-links {
    display: none !important;
  }
  
  .bslib-value-box {
    margin-bottom: 10px !important;
  }
}

.mobile-menu-btn, .mobile-dropdown {
  display: none;
}

.mobile-dropdown {
  position: absolute;
  top: 65px;
  left: 0;
  width: 100%;
  background-color: #444;
  z-index: 1055;
  border-bottom: 1px solid #555;
}

.mobile-dropdown a {
  display: flex;
  align-items: center;
  padding: 12px 15px;
  color: white;
  text-decoration: none;
  border-bottom: 1px solid #555;
}