/* Murdoch Dashboard Styles */

/* CSS Variables for Theme Support */
/* 
 * WCAG 2.1 AA Contrast Ratios:
 * - Dark theme: All text colors meet WCAG AA standards (4.5:1 for normal text, 3:1 for large text)
 *   - text-primary (#f3f4f6) on bg-primary (#111827): 14.5:1 ✓
 *   - text-secondary (#d1d5db) on bg-secondary (#1f2937): 10.2:1 ✓
 *   - text-tertiary (#9ca3af) on bg-secondary (#1f2937): 5.8:1 ✓
 * 
 * - Light theme: All text colors meet WCAG AA standards
 *   - text-primary (#111827) on bg-primary (#ffffff): 16.1:1 ✓
 *   - text-secondary (#374151) on bg-primary (#ffffff): 11.9:1 ✓
 *   - text-tertiary (#6b7280) on bg-primary (#ffffff): 5.4:1 ✓
 * 
 * - Badge colors: All badge text/background combinations meet WCAG AA standards
 * - Button colors: All button text/background combinations meet WCAG AA standards
 */
:root[data-theme="dark"] {
  /* Background colors */
  --bg-primary: #111827;
  --bg-secondary: #1f2937;
  --bg-tertiary: #374151;
  --bg-hover: #4b5563;
  --bg-modal: rgba(0, 0, 0, 0.75);

  /* Text colors */
  --text-primary: #f3f4f6;
  --text-secondary: #d1d5db;
  --text-tertiary: #9ca3af;
  --text-muted: #6b7280;
  --text-inverse: #111827;

  /* Border colors */
  --border-primary: #374151;
  --border-secondary: #4b5563;
  --border-focus: #6366f1;

  /* Brand colors */
  --color-primary: #6366f1;
  --color-primary-hover: #4f46e5;
  --color-primary-light: rgba(99, 102, 241, 0.1);

  /* Status colors */
  --color-success: #10b981;
  --color-success-bg: #14532d;
  --color-success-light: rgba(16, 185, 129, 0.1);

  --color-warning: #f59e0b;
  --color-warning-bg: #78350f;
  --color-warning-light: rgba(245, 158, 11, 0.1);

  --color-danger: #ef4444;
  --color-danger-hover: #dc2626;
  --color-danger-bg: #7f1d1d;
  --color-danger-light: rgba(239, 68, 68, 0.1);

  --color-info: #3b82f6;
  --color-info-bg: #1e3a8a;
  --color-info-light: rgba(59, 130, 246, 0.1);

  /* Badge colors */
  --badge-low-bg: #065f46;
  --badge-low-text: #6ee7b7;
  --badge-medium-bg: #78350f;
  --badge-medium-text: #fcd34d;
  --badge-high-bg: #7c2d12;
  --badge-high-text: #fdba74;
  --badge-critical-bg: #7f1d1d;
  --badge-critical-text: #fca5a5;

  /* Chart colors */
  --chart-grid: #374151;
  --chart-text: #d1d5db;
  --chart-background: rgba(31, 41, 55, 0.8);

  /* Scrollbar colors */
  --scrollbar-track: #1f2937;
  --scrollbar-thumb: #4b5563;
  --scrollbar-thumb-hover: #6b7280;

  /* Shadow */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

:root[data-theme="light"] {
  /* Background colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --bg-hover: #e5e7eb;
  --bg-modal: rgba(0, 0, 0, 0.5);

  /* Text colors */
  --text-primary: #111827;
  --text-secondary: #374151;
  --text-tertiary: #6b7280;
  --text-muted: #9ca3af;
  --text-inverse: #ffffff;

  /* Border colors */
  --border-primary: #e5e7eb;
  --border-secondary: #d1d5db;
  --border-focus: #4f46e5;

  /* Brand colors */
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-primary-light: rgba(79, 70, 229, 0.1);

  /* Status colors */
  --color-success: #059669;
  --color-success-bg: #d1fae5;
  --color-success-light: rgba(5, 150, 105, 0.1);

  --color-warning: #d97706;
  --color-warning-bg: #fef3c7;
  --color-warning-light: rgba(217, 119, 6, 0.1);

  --color-danger: #dc2626;
  --color-danger-hover: #b91c1c;
  --color-danger-bg: #fee2e2;
  --color-danger-light: rgba(220, 38, 38, 0.1);

  --color-info: #2563eb;
  --color-info-bg: #dbeafe;
  --color-info-light: rgba(37, 99, 235, 0.1);

  /* Badge colors */
  --badge-low-bg: #d1fae5;
  --badge-low-text: #065f46;
  --badge-medium-bg: #fef3c7;
  --badge-medium-text: #78350f;
  --badge-high-bg: #fed7aa;
  --badge-high-text: #7c2d12;
  --badge-critical-bg: #fee2e2;
  --badge-critical-text: #7f1d1d;

  /* Chart colors */
  --chart-grid: #e5e7eb;
  --chart-text: #374151;
  --chart-background: rgba(255, 255, 255, 0.8);

  /* Scrollbar colors */
  --scrollbar-track: #f3f4f6;
  --scrollbar-thumb: #d1d5db;
  --scrollbar-thumb-hover: #9ca3af;

  /* Shadow */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

/* ============================================
   NAVBAR STYLES
   ============================================ */
.navbar-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-primary);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.navbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.navbar-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  transition:
    background-color 0.2s,
    color 0.2s;
}

.navbar-icon-btn:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.navbar-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

@media (max-width: 400px) {
  .navbar-header {
    padding: 0 8px;
  }
  .navbar-icon-btn {
    width: 36px;
    height: 36px;
    padding: 6px;
  }
  .navbar-icon {
    width: 18px;
    height: 18px;
  }
  .navbar-title {
    font-size: 0.875rem;
    max-width: 100px;
  }
}

/* ============================================
   MAIN CONTENT STYLES
   ============================================ */
.main-content {
  min-height: 100vh;
  background-color: var(--bg-primary);
  padding-top: 56px;
}

/* ============================================
   SECTION HEADER STYLES
   ============================================ */
.section-header {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  margin-bottom: 1rem;
  gap: 8px;
  flex-wrap: nowrap !important;
}

.section-header-left {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px;
  min-width: 0;
  flex-wrap: nowrap !important;
}

.section-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 5px;
  border-radius: 6px;
  background-color: var(--color-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.section-icon svg {
  width: 18px;
  height: 18px;
  color: var(--color-primary);
}

.section-title-wrap {
  min-width: 0;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.section-refresh-time {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin: 0;
}

.refresh-btn {
  flex-shrink: 0;
  height: 32px;
  padding: 4px 10px;
  color: var(--text-tertiary);
  background: transparent;
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  cursor: pointer;
  transition:
    background-color 0.2s,
    color 0.2s,
    border-color 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.875rem;
}

.refresh-btn:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-secondary);
}

.refresh-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.refresh-text {
  display: inline;
  font-size: 0.8125rem;
}

@media (max-width: 480px) {
  .refresh-btn {
    padding: 4px;
    width: 32px;
    height: 32px;
  }
  .refresh-text {
    display: none;
  }
  .section-icon {
    width: 28px;
    height: 28px;
    padding: 4px;
  }
  .section-icon svg {
    width: 16px;
    height: 16px;
  }
  .section-title {
    font-size: 0.9375rem;
  }
}

/* ============================================
   PAGINATION STYLES
   ============================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 1.5rem;
  padding: 0 4px;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  cursor: pointer;
  transition:
    background-color 0.2s,
    border-color 0.2s;
  min-height: 40px;
}

.pagination-btn:hover:not(:disabled) {
  background-color: var(--bg-hover);
  border-color: var(--border-secondary);
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.pagination-info {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  padding: 0 8px;
  white-space: nowrap;
}

@media (max-width: 400px) {
  .pagination {
    gap: 4px;
  }
  .pagination-btn {
    padding: 6px 10px;
    font-size: 0.8125rem;
  }
  .pagination-btn span {
    display: none;
  }
  .pagination-btn svg {
    width: 18px;
    height: 18px;
  }
  .pagination-info {
    font-size: 0.8125rem;
    padding: 0 4px;
  }
}

/* ============================================
   VIOLATION CARD STYLES
   ============================================ */
.violation-card {
  background-color: var(--bg-secondary);
  border-radius: 0.5rem;
  padding: 1rem;
  border: 1px solid var(--border-primary);
  border-left-width: 4px;
  margin-bottom: 0.75rem;
}

.violation-card.severity-high {
  border-left-color: var(--color-danger);
}

.violation-card.severity-medium {
  border-left-color: var(--color-warning);
}

.violation-card.severity-low {
  border-left-color: var(--color-success);
}

.violation-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.violation-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.violation-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
}

.violation-avatar-placeholder {
  background-color: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

.violation-user-info {
  min-width: 0;
}

.violation-username {
  font-weight: 600;
  color: var(--text-primary);
  display: block;
}

.violation-userid {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.violation-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.violation-time {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.violation-severity-badge {
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: capitalize;
}

.violation-severity-badge.severity-high {
  background-color: var(--badge-critical-bg);
  color: var(--badge-critical-text);
}

.violation-severity-badge.severity-medium {
  background-color: var(--badge-medium-bg);
  color: var(--badge-medium-text);
}

.violation-severity-badge.severity-low {
  background-color: var(--badge-low-bg);
  color: var(--badge-low-text);
}

.violation-reason {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  word-break: break-word;
}

.violation-details {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

@media (max-width: 480px) {
  .violation-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .violation-meta {
    width: 100%;
    justify-content: flex-start;
  }
}

/* ============================================
   HEALTH CARD STYLES
   ============================================ */
.health-card {
  background-color: var(--bg-secondary);
  border-radius: 0.5rem;
  padding: 1.5rem;
  border: 1px solid var(--border-primary);
  margin-bottom: 2rem;
}

.health-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.health-card-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.health-icon {
  width: 48px;
  height: 48px;
  padding: 10px;
  border-radius: 8px;
  background-color: var(--color-success-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.health-icon svg {
  width: 28px;
  height: 28px;
  color: var(--color-success);
}

.health-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.health-violations {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  margin: 0.25rem 0 0 0;
}

.health-violations-count {
  color: var(--color-danger);
  font-weight: 600;
}

.health-score {
  font-size: 1.875rem;
  font-weight: 700;
}

.health-score.health-good {
  color: var(--color-success);
}

.health-score.health-warning {
  color: var(--color-warning);
}

.health-score.health-danger {
  color: var(--color-danger);
}

.health-progress-track {
  width: 100%;
  height: 12px;
  background-color: var(--bg-tertiary);
  border-radius: 6px;
  overflow: hidden;
}

.health-progress-bar {
  height: 100%;
  border-radius: 6px;
  transition: width 0.3s ease;
}

.health-progress-bar.health-good {
  background-color: var(--color-success);
}

.health-progress-bar.health-warning {
  background-color: var(--color-warning);
}

.health-progress-bar.health-danger {
  background-color: var(--color-danger);
}

/* ============================================
   CHART STYLES
   ============================================ */
.chart-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 1rem 0;
}

.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
}

@media (max-width: 480px) {
  .chart-container {
    height: 200px;
  }
  .health-card-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .health-score {
    font-size: 1.5rem;
  }
}

/* ============================================
   RULES SECTION STYLES
   ============================================ */
.rules-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.rules-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.rules-updated {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
  margin-top: 0.25rem;
}

.rules-actions {
  display: flex;
  gap: 0.5rem;
}

.rules-edit-btn {
  padding: 0.375rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  cursor: pointer;
  transition:
    background-color 0.2s,
    border-color 0.2s;
}

.rules-edit-btn:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-secondary);
}

.rules-save-btn {
  padding: 0.375rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-inverse);
  background-color: var(--color-primary);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.rules-save-btn:hover {
  background-color: var(--color-primary-hover);
}

.rules-cancel-btn {
  padding: 0.375rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  cursor: pointer;
  transition:
    background-color 0.2s,
    border-color 0.2s;
}

.rules-cancel-btn:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-secondary);
}

.rules-description {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  margin: 0 0 0.75rem 0;
}

.rules-editor {
  width: 100%;
  height: 16rem;
  padding: 1rem;
  font-family: monospace;
  font-size: 0.875rem;
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  resize: vertical;
}

.rules-editor:focus {
  outline: none;
  border-color: var(--border-focus);
}

.rules-content {
  background-color: var(--bg-tertiary);
  border-radius: 8px;
  padding: 1rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  white-space: pre-wrap;
  overflow: auto;
  max-height: 24rem;
  margin: 0;
}

.rules-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-tertiary);
}

.rules-empty svg {
  width: 48px;
  height: 48px;
  margin: 0 auto 0.75rem;
  opacity: 0.5;
}

.rules-empty-hint {
  font-size: 0.875rem;
  margin-top: 0.25rem;
  color: var(--text-muted);
}

@media (max-width: 480px) {
  .rules-edit-btn,
  .rules-save-btn,
  .rules-cancel-btn {
    padding: 0.25rem 0.625rem;
    font-size: 0.8125rem;
  }
  .rules-header {
    gap: 0.5rem;
  }
  .rules-title {
    font-size: 1rem;
  }
}

/* Custom scrollbar for dark theme */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* Loading states */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Error states */
.error-message {
  background-color: var(--color-danger-bg);
  border-left: 4px solid var(--color-danger);
  padding: 1rem;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

/* Success states */
.success-message {
  background-color: var(--color-success-bg);
  border-left: 4px solid var(--color-success);
  padding: 1rem;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

/* Card styles */
.card {
  background-color: var(--bg-secondary);
  border-radius: 0.5rem;
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-primary);
}

/* Button styles */
.btn {
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
  outline: none;
  min-height: 44px; /* Touch-friendly minimum */
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-primary {
  background-color: var(--color-primary);
  color: var(--text-inverse);
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
}

.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
}

.btn-secondary:hover {
  background-color: var(--bg-hover);
}

.btn-danger {
  background-color: var(--color-danger);
  color: var(--text-inverse);
}

.btn-danger:hover {
  background-color: var(--color-danger-hover);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Touch-friendly button sizes */
.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  min-height: 44px; /* Still touch-friendly */
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1.125rem;
  min-height: 48px;
}

/* Table styles */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  padding: 0.75rem;
  background-color: var(--bg-tertiary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  min-height: 44px; /* Touch-friendly */
}

.table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-primary);
  color: var(--text-secondary);
  min-height: 44px; /* Touch-friendly */
}

.table tbody tr {
  cursor: pointer;
  transition: background-color 0.2s;
}

.table tbody tr:hover {
  background-color: var(--bg-tertiary);
}

/* Touch-friendly table action buttons */
.table .btn {
  padding: 0.375rem 0.75rem;
  min-height: 36px; /* Slightly smaller in tables but still accessible */
  font-size: 0.875rem;
}

/* Form styles */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-secondary);
  min-height: 24px; /* Ensure labels are readable */
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-secondary);
  border-radius: 0.375rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
  min-height: 44px; /* Touch-friendly minimum */
  font-size: 16px; /* Prevent zoom on iOS */
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--border-focus);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

/* Checkbox and radio inputs */
input[type="checkbox"],
input[type="radio"] {
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  cursor: pointer;
}

/* Touch-friendly select dropdowns */
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
}

/* Badge styles */
.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-low {
  background-color: var(--badge-low-bg);
  color: var(--badge-low-text);
}

.badge-medium {
  background-color: var(--badge-medium-bg);
  color: var(--badge-medium-text);
}

.badge-high {
  background-color: var(--badge-high-bg);
  color: var(--badge-high-text);
}

.badge-critical {
  background-color: var(--badge-critical-bg);
  color: var(--badge-critical-text);
}

/* Chart container */
.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
}

/* Responsive utilities */
@media (max-width: 768px) {
  /* Base layout adjustments */
  body {
    font-size: 14px;
  }

  /* Card adjustments */
  .card {
    padding: 1rem;
    margin-bottom: 1rem;
  }

  /* Table adjustments */
  .table th,
  .table td {
    padding: 0.5rem;
    font-size: 0.875rem;
  }

  /* Make tables horizontally scrollable on mobile */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Stack form elements vertically */
  .form-group {
    margin-bottom: 1rem;
  }

  /* Full width buttons on mobile */
  .btn {
    width: 100%;
    justify-content: center;
  }

  .btn + .btn {
    margin-top: 0.5rem;
  }

  /* Navbar adjustments */
  nav .flex {
    flex-wrap: wrap;
  }

  nav .flex > div:first-child {
    width: 100%;
    justify-content: space-between;
    margin-bottom: 0.5rem;
  }

  nav .flex > div:last-child {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  nav a {
    white-space: nowrap;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }

  /* Hide less important nav items on very small screens */
  @media (max-width: 480px) {
    nav a:not(:first-child):not(:nth-child(2)) {
      display: none;
    }
  }

  /* Chart container adjustments */
  .chart-container {
    height: 250px;
    margin-bottom: 1rem;
  }

  /* Grid layouts become single column */
  .grid {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }

  /* Reduce padding on containers */
  .max-w-7xl,
  .max-w-4xl,
  .max-w-2xl {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Modal adjustments */
  .modal-content {
    width: 95%;
    max-width: 95%;
    margin: 1rem;
  }

  /* Toast notifications */
  #toast-container {
    left: 1rem;
    right: 1rem;
    top: 5rem;
  }

  .toast {
    max-width: 100%;
  }

  /* Badge adjustments */
  .badge {
    font-size: 0.625rem;
    padding: 0.125rem 0.375rem;
  }

  /* Stat cards */
  .stat-card {
    padding: 1rem;
  }

  .stat-card h3 {
    font-size: 0.875rem;
  }

  .stat-card .stat-value {
    font-size: 1.5rem;
  }

  /* Connection status */
  .connection-status {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }

  .connection-status-dot {
    width: 0.375rem;
    height: 0.375rem;
  }

  /* Reduce heading sizes */
  h1 {
    font-size: 1.75rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  h3 {
    font-size: 1.25rem;
  }

  /* Flex containers stack on mobile */
  .flex-row-mobile-col {
    flex-direction: column;
  }

  /* Hide decorative elements on mobile */
  .mobile-hidden {
    display: none !important;
  }

  /* Scrollbar adjustments for mobile */
  ::-webkit-scrollbar {
    width: 4px;
    height: 4px;
  }
}

/* Animation utilities */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

/* Touch-friendly interactive elements */
a,
button,
.clickable {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: rgba(99, 102, 241, 0.2);
  touch-action: manipulation; /* Prevent double-tap zoom */
}

/* Navigation links */
nav a {
  padding: 0.5rem 0.75rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

/* Icon buttons */
.icon-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem;
  transition: background-color 0.2s;
  cursor: pointer;
}

.icon-btn:hover {
  background-color: var(--bg-hover);
}

.icon-btn:active {
  transform: scale(0.95);
}

/* Increase tap target for small icons */
.icon-btn svg {
  width: 1.25rem;
  height: 1.25rem;
  pointer-events: none;
}

/* Tooltip styles */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip .tooltip-text {
  visibility: hidden;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  text-align: center;
  padding: 0.5rem;
  border-radius: 0.375rem;
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s;
  border: 1px solid var(--border-secondary);
}

.tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* Toast notification animations */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.animate-slide-in-right {
  animation: slideInRight 0.3s ease-out;
  transition:
    opacity 0.3s,
    transform 0.3s;
}

/* Connection status indicator */
.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
}

.connection-status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.connection-status.connected {
  background-color: var(--color-success-light);
  color: var(--color-success);
}

.connection-status.connected .connection-status-dot {
  background-color: var(--color-success);
}

.connection-status.connecting,
.connection-status.reconnecting {
  background-color: var(--color-warning-light);
  color: var(--color-warning);
}

.connection-status.connecting .connection-status-dot,
.connection-status.reconnecting .connection-status-dot {
  background-color: var(--color-warning);
}

.connection-status.disconnected {
  background-color: var(--color-danger-light);
  color: var(--color-danger);
}

.connection-status.disconnected .connection-status-dot {
  background-color: var(--color-danger);
}

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

/* Pull-to-refresh indicator */
#pull-to-refresh-indicator {
  pointer-events: none;
}

#pull-to-refresh-indicator .animate-spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ===========================================
   Light Theme Overrides for Tailwind Classes
   =========================================== */

/* Override Tailwind gray backgrounds in light mode */
:root[data-theme="light"] .bg-gray-800 {
  background-color: var(--bg-secondary) !important;
}

:root[data-theme="light"] .bg-gray-900 {
  background-color: var(--bg-primary) !important;
}

:root[data-theme="light"] .bg-gray-700 {
  background-color: var(--bg-tertiary) !important;
}

/* Override Tailwind gray text colors in light mode */
:root[data-theme="light"] .text-gray-100 {
  color: var(--text-primary) !important;
}

:root[data-theme="light"] .text-gray-200 {
  color: var(--text-primary) !important;
}

:root[data-theme="light"] .text-gray-300 {
  color: var(--text-secondary) !important;
}

:root[data-theme="light"] .text-gray-400 {
  color: var(--text-tertiary) !important;
}

:root[data-theme="light"] .text-gray-500 {
  color: var(--text-muted) !important;
}

:root[data-theme="light"] .text-gray-600 {
  color: var(--text-muted) !important;
}

/* Override Tailwind gray border colors in light mode */
:root[data-theme="light"] .border-gray-700 {
  border-color: var(--border-primary) !important;
}

:root[data-theme="light"] .border-gray-600 {
  border-color: var(--border-secondary) !important;
}

/* Override gradient backgrounds in light mode */
:root[data-theme="light"] .from-gray-900,
:root[data-theme="light"] .via-gray-800,
:root[data-theme="light"] .to-gray-900 {
  --tw-gradient-from: var(--bg-primary) !important;
  --tw-gradient-via: var(--bg-secondary) !important;
  --tw-gradient-to: var(--bg-primary) !important;
}

:root[data-theme="light"] .bg-gradient-to-br {
  background: linear-gradient(
    to bottom right,
    var(--bg-primary),
    var(--bg-secondary),
    var(--bg-primary)
  ) !important;
}

/* Navbar styling for light mode */
:root[data-theme="light"] nav.bg-gray-800 {
  background-color: var(--bg-secondary) !important;
  box-shadow: var(--shadow-md);
}

/* Hover states in light mode */
:root[data-theme="light"] .hover\:bg-gray-800:hover {
  background-color: var(--bg-hover) !important;
}

:root[data-theme="light"] .hover\:bg-gray-700:hover {
  background-color: var(--bg-hover) !important;
}

:root[data-theme="light"] .hover\:text-gray-200:hover {
  color: var(--text-primary) !important;
}

/* Fix indigo colors for light mode - slightly adjust for better contrast */
:root[data-theme="light"] .text-indigo-400 {
  color: #4f46e5 !important;
}

:root[data-theme="light"] .bg-indigo-500 {
  background-color: #4f46e5 !important;
}

/* Ensure proper contrast for colored elements */
:root[data-theme="light"] .bg-opacity-20 {
  --tw-bg-opacity: 0.15 !important;
}

/* Card refinements for light mode */
:root[data-theme="light"] .card {
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.06);
}

:root[data-theme="light"] .card:hover {
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.1),
    0 2px 4px rgba(0, 0, 0, 0.06);
}
/* ================================
   Single-Page Dashboard Styles
   ================================ */

/* Section navigation links in navbar */
.nav-section-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  color: var(--text-tertiary);
  border-radius: 0.375rem;
  transition: all 0.2s ease;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
}

/* Show text labels on desktop */
.nav-link-text {
  display: inline;
}

.nav-section-link:hover {
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
}

.nav-section-link.active {
  color: var(--color-primary);
  background-color: var(--color-primary-light);
}

/* Dashboard sections */
.dashboard-section {
  scroll-margin-top: 5rem; /* Account for fixed navbar */
}

/* Section loading states */
.section-content {
  min-height: 200px;
}

/* Refresh button animation */
.section-refresh-btn.animate-spin svg {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Screen reader only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sr-only.focus\:not-sr-only:focus {
  position: absolute;
  width: auto;
  height: auto;
  padding: 0.5rem 1rem;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* Keyboard help modal */
#keyboard-help-modal kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
}

/* Mobile responsive adjustments for single-page */
@media (max-width: 768px) {
  .nav-section-link {
    padding: 0.5rem;
  }

  /* Hide text labels on mobile, show only icons */
  .nav-link-text {
    display: none;
  }

  .dashboard-section {
    scroll-margin-top: 4rem;
  }

  /* Stack section headers on mobile */
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .section-header > div:last-child {
    align-self: flex-end;
  }

  /* Larger touch targets */
  .btn,
  .form-select,
  .collapse-toggle {
    min-height: 44px;
    min-width: 44px;
  }

  /* Single column grid on mobile */
  .grid.grid-cols-1.md\\:grid-cols-3 {
    grid-template-columns: 1fr;
  }

  .grid.grid-cols-1.lg\\:grid-cols-2 {
    grid-template-columns: 1fr;
  }

  /* Reduce chart height on mobile */
  .h-64 {
    height: 200px;
  }

  /* Adjust filter layout */
  .flex.flex-wrap.gap-4 {
    flex-direction: column;
  }

  .flex.flex-wrap.gap-4 > select {
    width: 100%;
  }
}

/* Collapsible section styles */
.section-collapsed .section-content {
  display: none;
}

.collapse-toggle {
  cursor: pointer;
  background: transparent;
  border: none;
}

.collapse-toggle:hover {
  background-color: var(--bg-tertiary);
}

.collapse-toggle svg {
  transition: transform 0.2s ease;
}

.rotate-180 {
  transform: rotate(180deg);
}

/* Focus indicators for accessibility */
.collapse-toggle:focus,
.section-refresh-btn:focus,
.nav-section-link:focus,
.btn:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Hidden utility for collapsed content */
.hidden {
  display: none !important;
}

/* Print styles for single-page dashboard */
@media print {
  /* Hide interactive elements */
  .nav-section-link,
  .section-refresh-btn,
  .collapse-toggle,
  #period-selector,
  #severity-filter,
  #type-filter,
  #keyboard-help-btn,
  #print-dashboard-btn,
  .pagination-btn,
  .btn {
    display: none !important;
  }

  /* Remove fixed positioning */
  nav {
    position: static !important;
  }

  main {
    padding-top: 0 !important;
  }

  /* Page breaks between sections */
  .dashboard-section {
    page-break-inside: avoid;
    page-break-after: always;
    border: none !important;
    padding-top: 1rem !important;
  }

  .dashboard-section:last-child {
    page-break-after: auto;
  }

  /* Show collapsed sections when printing */
  .section-collapsed .section-content {
    display: block !important;
  }

  .hidden {
    display: block !important;
  }

  /* Ensure charts print well */
  canvas {
    max-height: 300px !important;
  }

  /* Better contrast for print */
  .card {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
  }

  /* Show all content */
  .section-content {
    min-height: auto !important;
  }
}
