/* ===== GlykoGuard Medical Dashboard Styles ===== */

/* CSS Custom Properties for consistent theming */
:root {
  /* Medical Color Palette */
  --primary-blue: #2c5282;
  --light-blue: #e6f3ff;
  --success-green: #38a169;
  --warning-orange: #ff8c00;
  --danger-red: #e53e3e;
  --critical-red: #c53030;
  --light-coral: #ffb3b3;
  --neutral-gray: #718096;
  --light-gray: #f7fafc;
  --dark-gray: #2d3748;
  
  /* Theme Colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f7fafc;
  --bg-tertiary: #e2e8f0;
  --text-primary: #2d3748;
  --text-secondary: #718096;
  --border-color: #e2e8f0;
  --shadow-color: rgba(0, 0, 0, 0.1);
  
  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  
  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  
  /* Border Radius */
  --border-radius-sm: 0.375rem;
  --border-radius-md: 0.5rem;
  --border-radius-lg: 0.75rem;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 var(--shadow-color);
  --shadow-md: 0 4px 6px -1px var(--shadow-color), 0 2px 4px -1px var(--shadow-color);
  --shadow-lg: 0 10px 15px -3px var(--shadow-color), 0 4px 6px -2px var(--shadow-color);
}

/* Dark Mode Variables */
body.dark-mode {
  --bg-primary: #1a202c;
  --bg-secondary: #2d3748;
  --bg-tertiary: #4a5568;
  --text-primary: #f7fafc;
  --text-secondary: #a0aec0;
  --border-color: #4a5568;
  --shadow-color: rgba(0, 0, 0, 0.3);
  --light-blue: #2d3748;
  --light-gray: #2d3748;
}

/* ===== Base Styles ===== */
* {
  box-sizing: border-box;
}

body.glucoboard-app {
  font-family: var(--font-family);
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
  color: var(--text-primary);
  line-height: 1.6;
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.3s ease, color 0.3s ease;
}

/* Dark mode specific backgrounds */
body.dark-mode.glucoboard-app {
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

/* ===== Loading Overlay ===== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(26, 32, 44, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.3s ease;
}

body:not(.dark-mode) .loading-overlay {
  background: rgba(255, 255, 255, 0.95);
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  text-align: center;
  color: var(--primary-blue);
}

.loading-spinner p {
  color: #e2e8f0;
}

body:not(.dark-mode) .loading-spinner p {
  color: var(--text-primary);
}

.loading-spinner i {
  font-size: 3rem;
  margin-bottom: var(--spacing-md);
  color: var(--danger-red);
}

.loading-spinner p {
  font-size: var(--font-size-lg);
  font-weight: 500;
  margin: 0;
}

/* ===== Header Styles ===== */
.glucoboard-header {
  background: linear-gradient(135deg, var(--primary-blue) 0%, #1a365d 100%);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.glucoboard-header .navbar {
  padding: var(--spacing-md) 0;
}

.glucoboard-header .navbar-brand {
  color: white !important;
  font-size: var(--font-size-2xl);
  font-weight: 700;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.glucoboard-header .navbar-brand:hover {
  color: white !important;
  opacity: 0.8;
  text-decoration: none;
}

.brand-text {
  background: linear-gradient(45deg, #ffffff, #a8e6cf);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Blood Drop Logo Icon Styles */
.blood-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  background-image: url('/icons/bloodicon.svg');
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  vertical-align: middle;
}

.blood-icon.fs-4 {
  width: 1.5rem;
  height: 1.5rem;
}

.blood-icon.fs-3 {
  width: 2rem;
  height: 2rem;
}

.blood-icon.fs-2 {
  width: 2.5rem;
  height: 2.5rem;
}

.blood-icon.fs-1 {
  width: 3rem;
  height: 3rem;
}

.blood-icon.fa-pulse {
  animation: fa-pulse 2s infinite;
}

@keyframes fa-pulse {
  0%, 100% { 
    transform: scale(1);
    opacity: 1;
  }
  50% { 
    transform: scale(1.1);
    opacity: 0.8;
  }
}

.pulse-badge {
  animation: pulse 2s infinite;
  font-size: var(--font-size-xs);
  font-weight: 600;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.current-time {
  color: white;
  font-weight: 600;
  font-size: var(--font-size-lg);
  background: rgba(255, 255, 255, 0.1);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--border-radius-md);
  backdrop-filter: blur(10px);
}

.connection-status {
  color: white;
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--border-radius-md);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
}

.connection-status.offline {
  background: rgba(229, 62, 62, 0.2);
}

.connection-status.offline i {
  color: var(--danger-red) !important;
}

/* ===== Group Filter in Header ===== */
.group-filter-container {
  position: relative;
}

.group-filter-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background: rgba(255, 255, 255, 0.12);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  color: white;
  font-size: 0.9rem;
  font-weight: 500;
  min-width: 150px;
  padding: 8px 36px 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(12px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  /* Custom dropdown arrow */
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2.5' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px 14px;
}

.group-filter-select:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
}

.group-filter-select:focus {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.15), 0 4px 12px rgba(0, 0, 0, 0.2);
  outline: none;
  transform: translateY(-1px);
}

.group-filter-select option {
  background: #2d3748;
  color: white;
  font-weight: 500;
  padding: 10px 12px;
  font-size: 0.9rem;
}

/* Dark mode - keep consistent with light mode for header */
body.dark-mode .group-filter-select {
  background: rgba(255, 255, 255, 0.12);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  /* Ensure white arrow is visible in dark mode */
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2.5' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px 14px;
}

body.dark-mode .group-filter-select:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.35);
  /* Keep arrow on hover */
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2.5' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px 14px;
}

body.dark-mode .group-filter-select:focus {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.45);
  /* Keep arrow on focus */
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2.5' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px 14px;
}

body.dark-mode .group-filter-select option {
  background: #1a202c;
  color: white;
}

/* Form Select Improvements - Better visibility */
.form-select {
  background-color: var(--bg-primary);
  border: 2px solid var(--border-color);
  color: var(--text-primary);
  transition: all 0.2s ease;
  /* Light mode arrow - dark arrow on light background */
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 12px;
  padding-right: 2.5rem;
}

.form-select:focus {
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(44, 82, 130, 0.1);
  outline: none;
}

body.dark-mode .form-select {
  background-color: var(--bg-secondary);
  border: 2px solid var(--border-color);
  color: var(--text-primary);
  /* Dark mode arrow - light arrow on dark background */
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23f7fafc' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

body.dark-mode .form-select:focus {
  background-color: var(--bg-tertiary);
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

body.dark-mode .form-select option {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

/* Smaller form selects */
.form-select-sm {
  border-width: 1.5px;
  background-position: right 0.5rem center;
  background-size: 14px 10px;
  padding-right: 2rem;
}

/* ===== Main Content ===== */
.glucoboard-main {
  flex: 1;
  padding: var(--spacing-lg) 0;
}

/* ===== Page Header ===== */
.page-header {
  background: white;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--spacing-xl);
  margin-bottom: var(--spacing-xl);
  border-left: 4px solid var(--primary-blue);
}

.page-header h1 {
  color: var(--primary-blue);
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.page-header .current-time-display {
  font-size: var(--font-size-xl);
  color: var(--success-green);
  font-weight: 600;
  background: var(--light-blue);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--border-radius-md);
}

/* ===== Filters ===== */
.filters-container {
  background: white;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 0;
  margin-bottom: var(--spacing-lg);
  border: 1px solid #e2e8f0;
  transition: all 0.3s ease;
}

.compact-filters {
  margin-bottom: var(--spacing-lg);
}

.filter-header {
  padding: var(--spacing-md);
  cursor: pointer;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
  transition: all 0.2s ease;
  user-select: none;
}

.filter-header:hover {
  background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e0 100%);
}

.filters-container.collapsed .filter-header {
  border-radius: var(--border-radius-lg);
}

.filter-header h5 {
  color: var(--primary-blue);
  font-weight: 600;
  cursor: pointer;
  margin: 0;
}

.filter-toggle {
  color: var(--primary-blue);
  transition: transform 0.3s ease;
}

.filter-toggle i {
  font-size: var(--font-size-sm);
}

.filter-content {
  padding: var(--spacing-md);
  border-top: 1px solid #e2e8f0;
  transition: all 0.3s ease;
}

.filters-container.collapsed .filter-content {
  padding: 0;
  border-top: none;
}

.filters-container h3 {
  color: var(--primary-blue);
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: var(--spacing-md);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.filter-form {
  display: flex;
  gap: var(--spacing-md);
  align-items: end;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  min-width: 160px;
}

.filter-group label {
  font-weight: 600;
  color: var(--dark-gray);
  font-size: var(--font-size-sm);
  margin-bottom: 0;
}

.filter-group select {
  padding: var(--spacing-sm) var(--spacing-md);
  border: 2px solid #e2e8f0;
  border-radius: var(--border-radius-md);
  font-size: var(--font-size-sm);
  transition: all 0.2s ease;
  background: white;
  height: 38px;
}

.filter-group select:focus {
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(44, 82, 130, 0.1);
  outline: none;
}

.filter-submit {
  background: var(--primary-blue);
  color: white;
  border: none;
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--border-radius-md);
  font-weight: 600;
  font-size: var(--font-size-sm);
  transition: all 0.2s ease;
  cursor: pointer;
  height: 38px;
  white-space: nowrap;
}

.filter-submit:hover {
  background: #1a365d;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-outline-secondary {
  height: 38px;
  font-size: var(--font-size-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  display: flex;
  align-items: center;
  white-space: nowrap;
}

/* ===== Data Table Styles ===== */
.data-table-container {
  background: var(--bg-primary);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: var(--spacing-lg);
  border: 1px solid var(--border-color);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.data-table {
  width: 100%;
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--font-size-sm);
}

.data-table thead {
  background: linear-gradient(135deg, var(--primary-blue) 0%, #1a365d 100%);
}

.data-table thead th {
  color: white;
  font-weight: 600;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--spacing-sm) var(--spacing-md);
  border: none;
  position: relative;
  height: 40px;
}

.data-table thead th a {
  color: white;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  transition: color 0.2s ease;
}

.data-table thead th a:hover {
  color: #a8e6cf;
}

.data-table thead th a::after {
  content: '↕';
  opacity: 0.6;
  font-size: var(--font-size-xs);
}

.data-table tbody tr {
  transition: all 0.2s ease;
  border-bottom: 1px solid var(--border-color);
  height: 42px;
  background: var(--bg-primary);
}

.data-table tbody tr:hover {
  background: var(--light-blue);
  transform: scale(1.005);
  box-shadow: var(--shadow-sm);
}

.data-table tbody tr:last-child {
  border-bottom: none;
}

.data-table tbody td {
  padding: var(--spacing-xs) var(--spacing-md);
  vertical-align: middle;
  font-size: var(--font-size-sm);
  line-height: 1.3;
  color: var(--text-primary);
}

/* ===== Glucose Level Styling ===== */
.glucose-value {
  font-weight: 700;
  font-size: var(--font-size-base);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--border-radius-sm);
  text-align: center;
  min-width: 70px;
  display: inline-block;
  transition: all 0.2s ease;
  line-height: 1.2;
}

.glucose-value:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}

.glucose-value a {
  color: inherit;
  text-decoration: none;
}

.glucose-value small {
  font-size: 0.7em;
  opacity: 0.9;
}

/* Glucose level colors */
.high-bg {
  background: linear-gradient(135deg, var(--warning-orange), #ff9500);
  color: white;
  animation: highlightPulse 3s infinite;
}

.low-bg {
  background: linear-gradient(135deg, var(--danger-red), var(--critical-red));
  color: white;
  animation: criticalPulse 2s infinite;
}

.low-bg-soon-bg {
  background: linear-gradient(135deg, var(--light-coral), #ffcccc);
  color: var(--critical-red);
  font-weight: 700;
  animation: warningPulse 4s infinite;
}

.invalid-bg {
  background: linear-gradient(135deg, var(--neutral-gray), #9ca3af);
  color: white;
}

.normal-bg {
  background: linear-gradient(135deg, var(--success-green), #48bb78);
  color: white;
}

/* Default glucose styling */
.data-table tbody td:nth-child(3):not(.glucose-value) {
  font-weight: 600;
  font-size: var(--font-size-lg);
}

/* ===== Trend Indicators ===== */
.trend-indicator {
  font-size: var(--font-size-sm);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  line-height: 1.2;
}

.trend-critical {
  color: var(--danger-red);
  font-weight: 700;
}

.trend-warning {
  color: var(--warning-orange);
  font-weight: 600;
}

.trend-stable {
  color: var(--text-secondary);
}

.trend-manual {
  color: var(--primary-blue);
}

/* Legacy support for old classes (keeping for compatibility) */
.trend-up {
  color: var(--warning-orange);
}

.trend-down {
  color: var(--danger-red);
}

/* ===== Time Indicators ===== */
.old-data {
  color: var(--danger-red) !important;
  font-weight: 700;
  animation: blinkWarning 2s infinite;
}

.time-fresh {
  color: var(--text-primary);
  font-weight: 400;
}

.time-moderate {
  color: var(--warning-orange);
  font-weight: 600;
}

/* ===== Animations ===== */
@keyframes criticalPulse {
  0%, 100% { box-shadow: 0 0 5px rgba(229, 62, 62, 0.5); }
  50% { box-shadow: 0 0 20px rgba(229, 62, 62, 0.8); }
}

@keyframes warningPulse {
  0%, 100% { box-shadow: 0 0 3px rgba(255, 179, 179, 0.5); }
  50% { box-shadow: 0 0 15px rgba(255, 179, 179, 0.8); }
}

@keyframes highlightPulse {
  0%, 100% { box-shadow: 0 0 3px rgba(255, 140, 0, 0.5); }
  50% { box-shadow: 0 0 15px rgba(255, 140, 0, 0.8); }
}

@keyframes blinkWarning {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ===== Two Column Layout ===== */
.two-column-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-md);
  align-items: start;
}

.column-divider {
  width: 2px;
  background: linear-gradient(to bottom, transparent, var(--primary-blue), transparent);
  margin: 0 var(--spacing-sm);
  min-height: 400px;
}

/* ===== Footer ===== */
.glucoboard-footer {
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  padding: var(--spacing-md) 0;
  margin-top: auto;
  color: var(--text-secondary);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.glucoboard-footer small {
  font-size: var(--font-size-xs);
}

#data-status.warning {
  color: var(--warning-orange);
}

#data-status.error {
  color: var(--danger-red);
}

/* ===== Notification Styles ===== */
.notification-container {
  position: fixed;
  top: 80px;
  right: var(--spacing-lg);
  z-index: 1050;
  max-width: 400px;
}

.notification {
  background: var(--bg-primary);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-md);
  border-left: 4px solid var(--primary-blue);
  animation: slideInRight 0.3s ease;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.notification.critical {
  border-left-color: var(--danger-red);
  background: var(--bg-primary);
}

.notification.warning {
  border-left-color: var(--warning-orange);
  background: var(--bg-primary);
}

.notification.success {
  border-left-color: var(--success-green);
  background: var(--bg-primary);
}

/* Dark mode notification backgrounds */
body.dark-mode .notification {
  background: #2d3748;
  color: #e2e8f0;
  opacity: 1;
}

body.dark-mode .notification.critical {
  background: #2d3748;
  border-left-color: #f56565;
}

body.dark-mode .notification.warning {
  background: #2d3748;
  border-left-color: #ed8936;
}

body.dark-mode .notification.success {
  background: #2d3748;
  border-left-color: #48bb78;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ===== Mobile Navigation Styles ===== */
.mobile-dropdown-menu {
  background: rgba(44, 82, 130, 0.95) !important;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  border-radius: var(--border-radius-lg);
  min-width: 250px;
  box-shadow: var(--shadow-lg);
  margin-top: 8px;
}

.mobile-dropdown-menu .dropdown-header {
  color: rgba(255, 255, 255, 0.8) !important;
  font-weight: 600;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: var(--spacing-sm) var(--spacing-md);
}

.mobile-dropdown-menu .dropdown-item {
  color: white !important;
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: var(--font-size-sm);
  transition: all 0.2s ease;
}

.mobile-dropdown-menu .dropdown-item:hover,
.mobile-dropdown-menu .dropdown-item:focus {
  background: rgba(255, 255, 255, 0.1) !important;
  color: white !important;
}

.mobile-dropdown-menu .dropdown-divider {
  border-color: rgba(255, 255, 255, 0.2);
  margin: var(--spacing-xs) 0;
}

.mobile-group-select {
  background: rgba(255, 255, 255, 0.1) !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  color: white !important;
  font-size: var(--font-size-sm);
}

.mobile-group-select:focus {
  background: rgba(255, 255, 255, 0.2) !important;
  border-color: rgba(255, 255, 255, 0.5) !important;
  box-shadow: none !important;
  color: white !important;
}

.mobile-group-select option {
  background: var(--primary-blue);
  color: white;
}

.connection-status-mobile {
  color: white;
  font-size: var(--font-size-sm);
}

#mobileMenuToggle {
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  background: rgba(255, 255, 255, 0.1) !important;
  color: white !important;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

#mobileMenuToggle:hover {
  background: rgba(255, 255, 255, 0.2) !important;
  border-color: rgba(255, 255, 255, 0.5) !important;
  color: white !important;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
  .two-column-layout {
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
  }
  
  .column-divider {
    display: none;
  }
  
  .glucoboard-main {
    padding: var(--spacing-sm) 0;
  }
  
  /* Header mobile optimizations - reduced height */
  .glucoboard-header .navbar {
    padding: 6px 0; /* Significantly reduced from var(--spacing-sm) */
    min-height: auto;
  }
  
  .glucoboard-header .container-fluid {
    gap: var(--spacing-xs); /* Reduced gap between elements */
  }
  
  .navbar-brand {
    font-size: var(--font-size-lg) !important; /* Smaller than 2xl */
  }
  
  .brand-text {
    font-size: var(--font-size-lg) !important; /* Smaller than 2xl */
  }
  
  /* Reduce icon sizes */
  .navbar-brand i {
    font-size: var(--font-size-base) !important;
  }
  
  /* Smaller badge */
  .pulse-badge {
    font-size: 0.65rem !important;
    padding: 1px 4px !important;
  }
  
  /* Compact time display */
  .current-time {
    font-size: var(--font-size-sm) !important;
    padding: 2px var(--spacing-xs) !important;
  }
  
  /* Compact connection status */
  .connection-status {
    padding: 2px var(--spacing-xs) !important;
    font-size: var(--font-size-sm) !important;
  }
  
  /* Smaller group filter */
  .group-filter-container {
    padding: 0;
  }
  
  .group-filter-select {
    min-width: 110px !important;
    font-size: 0.8rem !important;
    padding: 4px 28px 4px 8px !important;
    height: 32px !important;
    background-size: 12px 12px !important;
    background-position: right 6px center !important;
  }
  
  /* Compact action buttons */
  .header-actions .btn {
    width: 32px !important;
    height: 32px !important;
    padding: 4px !important;
    margin: 0 1px !important;
  }
  
  .header-actions .btn i {
    font-size: 0.8rem !important;
  }
}
  
  .page-header {
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
  }
  
  .page-header h1 {
    font-size: var(--font-size-xl);
    flex-direction: column;
    text-align: center;
    gap: var(--spacing-sm);
  }
  
  .filters-container {
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
  }
  
  .filter-form {
    flex-direction: column;
    gap: var(--spacing-sm);
  }
  
  .filter-group {
    min-width: 100%;
  }
  
  .data-table thead th,
  .data-table tbody td {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: var(--font-size-xs);
  }
  
  .data-table tbody tr {
    height: 38px;
  }
  
  .glucose-value {
    font-size: var(--font-size-sm);
    min-width: 60px;
    padding: 2px var(--spacing-xs);
  }
  
  .current-time,
  .connection-status {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-lg);
  }
  
  .group-filter-container {
    padding: var(--spacing-xs);
  }
  
  .group-filter-select {
    min-width: 140px;
    font-size: var(--font-size-sm);
  }
  
  .header-actions .btn {
    width: 40px;
    height: 40px;
  }
  
  .header-actions .btn i {
    font-size: var(--font-size-base);
  }
  
  .notification-container {
    top: 70px;
    right: var(--spacing-sm);
    max-width: 400px;
  }
}

@media (max-width: 480px) {
  .glucoboard-header .navbar {
    padding: 4px 0; /* Even more compact for very small screens */
  }
  
  .navbar-brand {
    font-size: var(--font-size-base) !important; /* Even smaller for tiny screens */
  }
  
  .brand-text {
    font-size: var(--font-size-base) !important; /* Even smaller for tiny screens */
  }
  
  /* Even smaller icons */
  .navbar-brand i {
    font-size: var(--font-size-sm) !important;
  }
  
  /* Micro badge */
  .pulse-badge {
    font-size: 0.6rem !important;
    padding: 1px 3px !important;
  }
  
  /* Ultra compact time and status */
  .current-time,
  .connection-status {
    font-size: var(--font-size-xs) !important;
    padding: 1px 2px !important;
  }
  
  /* Ultra compact filter */
  .group-filter-select {
    min-width: 90px !important;
    font-size: 0.75rem !important;
    height: 28px !important;
    padding: 2px 24px 2px 6px !important;
    background-size: 10px 10px !important;
    background-position: right 4px center !important;
  }
  
  /* Ultra compact buttons */
  .header-actions .btn {
    width: 28px !important;
    height: 28px !important;
    padding: 2px !important;
  }
  
  .header-actions .btn i {
    font-size: 0.7rem !important;
  }
  
  /* Mobile dropdown menu adjustments */
  .mobile-dropdown-menu {
    width: 240px;
    top: 50px;
  }
  
  .mobile-menu-content {
    padding: var(--spacing-md);
  }
  
  /* Table optimizations for very small screens */
  .data-table thead th,
  .data-table tbody td {
    padding: 2px 4px !important;
    font-size: 11px !important;
  }
  
  .data-table tbody tr {
    height: 32px !important;
  }
  
  .page-header h1 {
    font-size: var(--font-size-lg);
  }
  
  .notification-container {
    font-size: var(--font-size-sm);
    top: 60px;
    right: var(--spacing-xs);
    max-width: 350px;
  }
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== Focus Styles ===== */
button:focus,
select:focus,
a:focus {
  outline: 3px solid var(--primary-blue);
  outline-offset: 2px;
}

/* ===== Print Styles ===== */
@media print {
  .glucoboard-header,
  .glucoboard-footer,
  .filters-container,
  .notification-container {
    display: none;
  }
  
  .glucoboard-main {
    padding: 0;
  }
  
  .data-table-container {
    box-shadow: none;
    border: 1px solid #000;
  }
  
  .data-table tbody tr:hover {
    background: none;
    transform: none;
    box-shadow: none;
  }
}

/* ===== Badge Styling ===== */
.badge {
  font-size: var(--font-size-xs);
  padding: 0.25em 0.5em;
  line-height: 1;
}

/* Dark mode adjustments for badges */
body.dark-mode .badge.bg-secondary {
  background-color: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
}

/* ===== Dark Mode Specific Adjustments ===== */
body.dark-mode .glucose-value {
  color: inherit;
}

body.dark-mode strong {
  color: var(--text-primary);
}

body.dark-mode .time-fresh {
  color: var(--text-primary);
}

body.dark-mode .time-moderate {
  color: #f6ad55;
}

body.dark-mode .old-data {
  color: #fc8181 !important;
}

body.dark-mode .trend-critical {
  color: #fc8181;
}

body.dark-mode .trend-warning {
  color: #f6ad55;
}

body.dark-mode .trend-stable {
  color: var(--text-secondary);
}

body.dark-mode .trend-manual {
  color: #90cdf4;
}

/* ===== Header Action Buttons ===== */
.header-actions {
  gap: 0.125rem;
}

.header-actions .btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.header-actions .btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  color: white;
  transform: translateY(-1px);
}

.header-actions .btn:focus {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  color: white;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.header-actions .btn i {
  font-size: var(--font-size-base);
}

/* ===== Modal Dark Mode Styles ===== */
body.dark-mode .modal-content {
  background-color: #2d3748;
  color: #e2e8f0;
  border: 1px solid #4a5568;
}

body.dark-mode .modal-header {
  border-bottom-color: #4a5568;
}

body.dark-mode .modal-footer {
  border-top-color: #4a5568;
}

body.dark-mode .modal-title {
  color: #e2e8f0;
}

body.dark-mode .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

body.dark-mode .help-content kbd {
  background-color: #4a5568;
  color: #e2e8f0;
  border: 1px solid #718096;
}

body.dark-mode .help-content h6 {
  color: #cbd5e0;
}

body.dark-mode .help-section {
  background-color: #374151;
  border: 1px solid #4a5568;
}

body.dark-mode .text-info {
  color: #90cdf4 !important;
} 

/* ===== Mobile Navigation Styles ===== */
.mobile-dropdown-menu {
  background: rgba(44, 82, 130, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--border-radius-lg);
  min-width: 250px;
  box-shadow: var(--shadow-lg);
  margin-top: 8px;
}

.mobile-dropdown-menu .dropdown-header {
  color: rgba(255, 255, 255, 0.8);
  font-weight: 600;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: var(--spacing-sm) var(--spacing-md);
}

.mobile-dropdown-menu .dropdown-item {
  color: white;
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: var(--font-size-sm);
  transition: all 0.2s ease;
}

.mobile-dropdown-menu .dropdown-item:hover,
.mobile-dropdown-menu .dropdown-item:focus {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.mobile-dropdown-menu .dropdown-divider {
  border-color: rgba(255, 255, 255, 0.2);
  margin: var(--spacing-xs) 0;
}

.mobile-group-select {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  font-size: var(--font-size-sm);
}

.mobile-group-select:focus {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: none;
  color: white;
}

.mobile-group-select option {
  background: var(--primary-blue);
  color: white;
}

.connection-status-mobile {
  color: white;
  font-size: var(--font-size-sm);
}

/* Mobile hamburger button */
#mobileMenuToggle {
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

#mobileMenuToggle:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  color: white;
}

/* ===== Responsive Design Updates ===== */ 