/**
 * Main styles for OpenVPN Monitor
 * Description: Contains custom styles for status indicators and UI improvements
 */

/* === Page Header === */
.display-6 {
  font-size: 2.5rem;
}

/* Dark theme: ensure subtitle is visible */
[data-bs-theme="dark"] .text-muted {
  color: #adb5bd !important;
}

/* Dark theme: improve outline button visibility */
[data-bs-theme="dark"] .btn-outline-dark {
  --bs-btn-color: #f8f9fa;
  --bs-btn-border-color: #f8f9fa;
  --bs-btn-hover-color: #212529;
  --bs-btn-hover-bg: #f8f9fa;
  --bs-btn-hover-border-color: #f8f9fa;
  --bs-btn-focus-shadow-rgb: 248, 249, 250;
}

[data-bs-theme="dark"] .btn-outline-secondary {
  --bs-btn-color: #f8f9fa;
  --bs-btn-border-color: #ced4da;
  --bs-btn-hover-color: #212529;
  --bs-btn-hover-bg: #ced4da;
  --bs-btn-hover-border-color: #ced4da;
  --bs-btn-focus-shadow-rgb: 206, 212, 218;
}

.btn-outline-dark:focus,
.btn-outline-secondary:focus {
  color: var(--bs-btn-color);
  background-color: var(--bs-btn-bg);
  border-color: var(--bs-btn-border-color);
}

body.user-is-tabbing .btn-outline-dark:focus-visible,
body.user-is-tabbing .btn-outline-secondary:focus-visible {
  color: var(--bs-btn-hover-color);
  background-color: var(--bs-btn-hover-bg);
  border-color: var(--bs-btn-hover-border-color);
}

/* Dark theme: ensure background is dark */
[data-bs-theme="dark"] body {
  background-color: #212529 !important;
  color: #f8f9fa;
}

/* Dark theme: headers and titles */
[data-bs-theme="dark"] .text-dark {
  color: #f8f9fa !important;
}

[data-bs-theme="dark"] h1,
[data-bs-theme="dark"] h2,
[data-bs-theme="dark"] h3 {
  color: #f8f9fa;
}

/* === Button Spacing === */
.gap-2 {
  gap: 0.5rem !important;
}

.gap-3 {
  gap: 1rem !important;
}

/* === Table Improvements === */
.shadow-sm {
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
  border-radius: 0.375rem;
  overflow: hidden;
}

/* === Status Indicators (Online/Offline) === */

/**
 * Base class for round status indicator
 * Used to display client state (online/offline)
 */
.status-dot {
  display: inline-block;
  width: 0.75rem;         /* Dot width */
  height: 0.75rem;        /* Dot height */
  border-radius: 50%;     /* Makes element circular */
  margin-right: 0.5rem;   /* Right margin from dot */
}

/**
 * Style for online status indicator
 * Color: green (#198754 - Bootstrap success)
 */
.status-dot-online {
  background-color: #198754;
}

/**
 * Style for offline status indicator
 * Color: red (#dc3545 - Bootstrap danger)
 */
.status-dot-offline {
  background-color: #dc3545;
}

/* === Styles for accordion client list === */

/**
 * Container for list item with accordion
 * Removes padding so button and collapse panel fill entire element
 */
#clientsList .list-group-item {
  padding: 0;
  transition: background-color 0.15s ease-in-out;
}

/**
 * Client header button in accordion
 * Styling for better visual representation
 */
#clientsList .list-group-item .btn-link {
  color: inherit;
  border: none;
  background: none;
  transition: background-color 0.15s ease-in-out;
}

/**
 * Hover effect for header button
 */
#clientsList .list-group-item .btn-link:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

/**
 * Dark theme: hover effect
 */
[data-bs-theme="dark"] #clientsList .list-group-item .btn-link:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

/**
 * Active (expanded) header button
 */
#clientsList .list-group-item .btn-link:not(.collapsed) {
  background-color: rgba(0, 0, 0, 0.1);
}

/**
 * Focus for header button
 */
#clientsList .list-group-item .btn-link:focus {
  box-shadow: none;
  outline: none;
}

/**
 * Collapse panel with client details
 * Adds smooth expand/collapse animation
 */
#clientsList .collapse {
  transition: height 0.35s ease;
}

/**
 * Content inside collapse panel
 * Adds top spacing to separate from header
 */
#clientsList .collapse .border-top {
  padding-top: 1rem;
  margin-top: 0.5rem;
}

/**
 * Client name in light theme
 */
.client-name {
  color: #212529;
  font-weight: 500;
}

/**
 * Client name in dark theme
 */
.bg-dark .client-name,
.modal-content.bg-dark .client-name {
  color: #f8f9fa !important;
}

/**
 * Client subtitle in dark theme
 */
.bg-dark .client-subtitle,
.modal-content.bg-dark .client-subtitle {
  color: #adb5bd !important;
}

/**
 * Border for client details in dark theme
 */
.bg-dark .client-details-content,
.modal-content.bg-dark .client-details-content {
  border-color: #495057 !important;
}

/**
 * List group items in dark theme
 */
.bg-dark .list-group-item,
.modal-content.bg-dark .list-group-item {
  background-color: #212529;
  border-color: #495057;
  color: #f8f9fa;
}

/**
 * Active accordion panel in dark theme
 */
.bg-dark #clientsList .list-group-item .btn-link:not(.collapsed),
.modal-content.bg-dark #clientsList .list-group-item .btn-link:not(.collapsed) {
  background-color: rgba(255, 255, 255, 0.2);
}

/**
 * Description list (dl) elements in client details for dark theme
 */
.bg-dark .client-details-content dt,
.modal-content.bg-dark .client-details-content dt {
  color: #adb5bd;
}

.bg-dark .client-details-content dd,
.modal-content.bg-dark .client-details-content dd {
  color: #f8f9fa;
}

/**
 * Headers and text inside client details in dark theme
 */
.bg-dark .client-details-content h6,
.modal-content.bg-dark .client-details-content h6 {
  color: #f8f9fa;
}

.bg-dark .client-details-content ul li,
.modal-content.bg-dark .client-details-content ul li {
  color: #f8f9fa;
}

.bg-dark .client-details-content strong,
.modal-content.bg-dark .client-details-content strong {
  color: #adb5bd;
}

/* === Styles for History modal window === */

/**
 * Container for history table with fixed headers
 * Ensures scrolling only for table rows
 */
.history-table-container {
  max-height: 60vh;           /* Maximum container height */
  overflow-y: auto;           /* Vertical scrolling */
  overflow-x: auto;           /* Horizontal scrolling when needed */
  position: relative;         /* For correct sticky operation */
  border: 1px solid #dee2e6; /* Container border */
  border-radius: 0.375rem;    /* Corner rounding */
}

/**
 * History table headers are fixed during scrolling
 */
.history-table-container thead th {
  position: sticky;           /* Fixes headers */
  top: 0;                     /* Pins to top of container */
  z-index: 10;                /* Above table rows */
  background-color: var(--bs-table-bg); /* Header background */
  box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.1); /* Shadow for visual separation */
}

/**
 * Table inside container without additional margins
 */
.history-table-container table {
  margin-bottom: 0;           /* Removes table bottom margin */
}

/* === Styles for traffic charts === */

/**
 * Chart statistics cards
 */
#chartStats .card {
  transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
  border: 1px solid rgba(0, 0, 0, 0.125);
}

#chartStats .card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/**
 * Statistics headers
 */
#chartStats .small.text-muted {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/**
 * Statistics values
 */
#chartStats .fw-bold {
  font-size: 1.1rem;
  color: #212529;
}

/**
 * Dark theme: statistics cards
 */
[data-bs-theme="dark"] #chartStats .card {
  background-color: #212529;
  border-color: #495057;
}

[data-bs-theme="dark"] #chartStats .fw-bold {
  color: #f8f9fa;
}

/**
 * Chart mode toggle buttons
 */
.btn-group .btn-check:checked + .btn-outline-dark {
  background-color: #212529;
  border-color: #212529;
  color: #fff;
}

/**
 * Client selection dropdown
 */
#clientSelect {
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

#clientSelect:focus {
  border-color: #6c757d;
  box-shadow: 0 0 0 0.25rem rgba(33, 37, 41, 0.25);
}

/**
 * Chart container
 */
#trafficChartModal {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 0.375rem;
  padding: 0.5rem;
}

/**
 * Dark theme: chart container
 */
[data-bs-theme="dark"] #trafficChartModal {
  background: rgba(0, 0, 0, 0.2);
}
