/**
 * portal.css - Theme and Styles for Portal Pages
 *
 * Dark/Light theme support for waiting-list, admin, queue management pages.
 * Uses Bootstrap 5.3's data-bs-theme attribute for automatic theme switching.
 * Include this CSS after Bootstrap CSS.
 */

/* =========================================================================
   CSS Custom Properties (Variables)
   ========================================================================= */

:root {
  /* Light mode (default) */
  --theme-bg-primary: #f5f5f5;
  --theme-bg-secondary: #ffffff;
  --theme-text-primary: #212529;
  --theme-text-secondary: #6c757d;
  --theme-text-muted: #6c757d;
  --theme-border-color: #dee2e6;
  --theme-link-color: #0d6efd;
  --theme-link-hover: #0a58ca;

  /* Card/Panel backgrounds */
  --theme-card-bg: #ffffff;
  --theme-card-border: rgba(0, 0, 0, 0.125);

  /* Code blocks */
  --theme-code-bg: #f8f9fa;
  --theme-code-color: #d63384;
  --theme-pre-bg: #1f2937;
  --theme-pre-color: #f9fafb;

  /* Status colors - same in both themes */
  --theme-success: #198754;
  --theme-warning: #ffc107;
  --theme-danger: #dc3545;
  --theme-info: #0dcaf0;
  --theme-primary: #0d6efd;

  /* Table */
  --theme-table-hover-bg: #f8f9fa;
  --theme-table-stripe-bg: rgba(0, 0, 0, 0.02);

  /* Shadows */
  --theme-shadow-sm: 0 .125rem .25rem rgba(0,0,0,.075);
  --theme-shadow: 0 .5rem 1rem rgba(0,0,0,.15);
  --theme-shadow-lg: 0 1rem 3rem rgba(0,0,0,.175);

  /* Rosie colors */
  --color-rosie-pink: #e75480;
  --color-rosie-pink-hover: #ff6390;
  --color-rosie-pink-light: #ffa3b5;
  --color-rosie-pink-dark: #b03060;
  --color-rosie-pink-border: #e75480;
  --color-rosie-pink-border-hover: #d64570;
}

/* =========================================================================
   Dark Theme Variables
   ========================================================================= */

[data-bs-theme="dark"] {
  --theme-bg-primary: #212529;
  --theme-bg-secondary: #2b3035;
  --theme-text-primary: #dee2e6;
  --theme-text-secondary: #adb5bd;
  --theme-text-muted: #6c757d;
  --theme-border-color: #495057;
  --theme-link-color: #6ea8fe;
  --theme-link-hover: #9ec5fe;

  /* Card/Panel backgrounds */
  --theme-card-bg: #2b3035;
  --theme-card-border: rgba(255, 255, 255, 0.125);

  /* Code blocks */
  --theme-code-bg: #343a40;
  --theme-code-color: #e685b5;
  --theme-pre-bg: #1a1d21;
  --theme-pre-color: #e9ecef;

  /* Table */
  --theme-table-hover-bg: #323539;
  --theme-table-stripe-bg: rgba(255, 255, 255, 0.02);

  /* Shadows - more subtle in dark mode */
  --theme-shadow-sm: 0 .125rem .25rem rgba(0,0,0,.2);
  --theme-shadow: 0 .5rem 1rem rgba(0,0,0,.3);
  --theme-shadow-lg: 0 1rem 3rem rgba(0,0,0,.4);

  /* Rosie colors - brighter in dark mode */
  --color-rosie-pink: #ff6390;
  --color-rosie-pink-hover: #ff7aa3;
  --color-rosie-pink-light: #ffa3b5;
  --color-rosie-pink-dark: #e75480;
  --color-rosie-pink-border: #ff6390;
  --color-rosie-pink-border-hover: #ff7aa3;
}

/* =========================================================================
   Bootstrap Overrides for Dark Mode
   ========================================================================= */

/* Background utilities */
[data-bs-theme="dark"] .bg-light {
  background-color: var(--theme-bg-secondary) !important;
}

[data-bs-theme="dark"] .bg-white {
  background-color: var(--theme-card-bg) !important;
}

/* Text utilities */
[data-bs-theme="dark"] .text-muted {
  color: var(--theme-text-muted) !important;
}

[data-bs-theme="dark"] .text-dark {
  color: var(--theme-text-primary) !important;
}

/* Cards */
[data-bs-theme="dark"] .card {
  background-color: var(--theme-card-bg);
  border-color: var(--theme-card-border);
}

[data-bs-theme="dark"] .card-header {
  background-color: rgba(255, 255, 255, 0.03);
  border-bottom-color: var(--theme-border-color);
}

/* Forms */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background-color: #343a40;
  border-color: var(--theme-border-color);
  color: var(--theme-text-primary);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  background-color: #3d4349;
  border-color: #6ea8fe;
  color: var(--theme-text-primary);
}

[data-bs-theme="dark"] .form-control::placeholder {
  color: var(--theme-text-muted);
}

[data-bs-theme="dark"] .input-group-text {
  background-color: #343a40;
  border-color: var(--theme-border-color);
  color: var(--theme-text-secondary);
}

/* Tables */
[data-bs-theme="dark"] .table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--theme-text-primary);
  --bs-table-border-color: var(--theme-border-color);
  --bs-table-hover-bg: var(--theme-table-hover-bg);
  --bs-table-striped-bg: var(--theme-table-stripe-bg);
}

[data-bs-theme="dark"] .table-primary {
  --bs-table-bg: rgba(13, 110, 253, 0.2);
  --bs-table-border-color: rgba(13, 110, 253, 0.3);
}

/* Modals */
[data-bs-theme="dark"] .modal-content {
  background-color: var(--theme-card-bg);
  border-color: var(--theme-border-color);
}

[data-bs-theme="dark"] .modal-header {
  border-bottom-color: var(--theme-border-color);
}

[data-bs-theme="dark"] .modal-footer {
  border-top-color: var(--theme-border-color);
}

[data-bs-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

/* Dropdowns */
[data-bs-theme="dark"] .dropdown-menu {
  background-color: var(--theme-card-bg);
  border-color: var(--theme-border-color);
}

[data-bs-theme="dark"] .dropdown-item {
  color: var(--theme-text-primary);
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
  background-color: var(--theme-table-hover-bg);
  color: var(--theme-text-primary);
}

/* Alerts */
[data-bs-theme="dark"] .alert-info {
  background-color: rgba(13, 202, 240, 0.15);
  border-color: rgba(13, 202, 240, 0.3);
  color: #6edff6;
}

[data-bs-theme="dark"] .alert-warning {
  background-color: rgba(255, 193, 7, 0.15);
  border-color: rgba(255, 193, 7, 0.3);
  color: #ffda6a;
}

[data-bs-theme="dark"] .alert-danger {
  background-color: rgba(220, 53, 69, 0.15);
  border-color: rgba(220, 53, 69, 0.3);
  color: #ea868f;
}

[data-bs-theme="dark"] .alert-success {
  background-color: rgba(25, 135, 84, 0.15);
  border-color: rgba(25, 135, 84, 0.3);
  color: #75b798;
}

/* Nav tabs */
[data-bs-theme="dark"] .nav-tabs {
  border-bottom-color: var(--theme-border-color);
}

[data-bs-theme="dark"] .nav-tabs .nav-link {
  color: var(--theme-text-secondary);
}

[data-bs-theme="dark"] .nav-tabs .nav-link:hover {
  border-color: var(--theme-border-color) var(--theme-border-color) transparent;
}

[data-bs-theme="dark"] .nav-tabs .nav-link.active {
  color: var(--theme-text-primary);
  background-color: var(--theme-card-bg);
  border-color: var(--theme-border-color) var(--theme-border-color) var(--theme-card-bg);
}

/* List groups */
[data-bs-theme="dark"] .list-group-item {
  background-color: var(--theme-card-bg);
  border-color: var(--theme-border-color);
  color: var(--theme-text-primary);
}

[data-bs-theme="dark"] .list-group-item-action:hover {
  background-color: var(--theme-table-hover-bg);
}

/* Code */
[data-bs-theme="dark"] code {
  color: var(--theme-code-color);
  background-color: var(--theme-code-bg);
}

[data-bs-theme="dark"] pre {
  background-color: var(--theme-pre-bg);
  color: var(--theme-pre-color);
}

/* =========================================================================
   Register/Waiting List Page Styles
   ========================================================================= */

.register-card {
  max-width: 450px;
  margin: auto;
}

/* =========================================================================
   Admin Dashboard Styles
   ========================================================================= */

/* Nav tabs active state */
.nav-tabs .nav-link.active {
  font-weight: 600;
}

/* Status badges */
.badge-pending { background-color: #ffc107; color: #212529; }
.badge-approved { background-color: #198754; }
.badge-rejected { background-color: #dc3545; }
.badge-expired { background-color: #6c757d; }

/* Stats cards with colored left border */
.stats-card {
  border-left: 4px solid;
}

.stats-card.pending { border-color: #ffc107; }
.stats-card.approved { border-color: #198754; }
.stats-card.rejected { border-color: #dc3545; }
.stats-card.total { border-color: #0d6efd; }

/* Table row hover */
.table-hover tbody tr:hover {
  cursor: pointer;
}

.brand-logo {
  font-size: 2.5rem;
}

/* =========================================================================
   Theme Toggle Button Styles
   ========================================================================= */

.theme-toggle-btn {
  background: transparent;
  border: none;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  border-radius: 0.375rem;
  transition: background-color 0.2s ease;
}

.theme-toggle-btn:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

[data-bs-theme="dark"] .theme-toggle-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.theme-toggle-btn i {
  font-size: 1.25rem;
  transition: transform 0.3s ease;
}

.theme-toggle-btn:hover i {
  transform: rotate(15deg);
}

/* =========================================================================
   Portal Card Grid Styles (for portal index page)
   ========================================================================= */

.portal-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.portal-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--theme-shadow-lg) !important;
}

[data-bs-theme="dark"] .portal-card {
  background-color: var(--theme-card-bg);
  border-color: var(--theme-card-border);
}

/* Status dots */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.connected {
  background: #198754;
}

.status-dot.disconnected {
  background: #dc3545;
}

/* =========================================================================
   Queue Management Styles
   ========================================================================= */

/* Row hover in dark mode */
[data-bs-theme="dark"] tbody tr:hover {
  background-color: var(--theme-table-hover-bg) !important;
}

[data-bs-theme="dark"] tbody tr.table-primary {
  background-color: rgba(13, 110, 253, 0.25) !important;
}

/* Details cell in dark mode */
[data-bs-theme="dark"] .details-cell {
  background-color: #1e2124;
}

/* Behalf badge */
.behalf-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background-color: #fef3c7;
  color: #78350f;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid #fcd34d;
}

[data-bs-theme="dark"] .behalf-badge {
  background-color: rgba(254, 243, 199, 0.15);
  border-color: rgba(252, 211, 77, 0.4);
  color: #fcd34d;
}

/* =========================================================================
   Rosie Button Styling
   ========================================================================= */

.btn-rosie {
  background-color: var(--color-rosie-pink);
  color: #ffffff;
  border: 1px solid var(--color-rosie-pink-border);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.btn-rosie:hover {
  background-color: var(--color-rosie-pink-hover);
  border-color: var(--color-rosie-pink-border-hover);
  color: #ffffff;
}

.btn-rosie:active {
  background-color: var(--color-rosie-pink-dark);
  border-color: var(--color-rosie-pink-border-hover);
}

.btn-outline-rosie {
  color: var(--color-rosie-pink);
  border-color: var(--color-rosie-pink-border);
  background-color: transparent;
}

.btn-outline-rosie:hover {
  background-color: var(--color-rosie-pink);
  color: #ffffff;
  border-color: var(--color-rosie-pink-border);
}

/* Text color utility */
.text-rosie-pink {
  color: var(--color-rosie-pink) !important;
}

/* =========================================================================
   Rosie Heartbeat Glow Animation for Loading States
   ========================================================================= */

@keyframes rosie-heartbeat-glow {
  0% {
    box-shadow: 0 0 0 rgba(231, 84, 128, 0);
  }
  20% {
    box-shadow: 0 0 8px rgba(231, 84, 128, 0.6), 0 0 16px rgba(231, 84, 128, 0.3);
  }
  30% {
    box-shadow: 0 0 4px rgba(231, 84, 128, 0.4), 0 0 10px rgba(231, 84, 128, 0.2);
  }
  40% {
    box-shadow: 0 0 6px rgba(231, 84, 128, 0.5), 0 0 14px rgba(231, 84, 128, 0.25);
  }
  50% {
    box-shadow: 0 0 2px rgba(231, 84, 128, 0.3), 0 0 8px rgba(231, 84, 128, 0.15);
  }
  100% {
    box-shadow: 0 0 0 rgba(231, 84, 128, 0);
  }
}

/* Admin page loading state */
#adminLoading {
  animation: rosie-heartbeat-glow 2s ease-in-out infinite;
  border-radius: 8px;
  padding: 2rem;
}

/* Rosie-colored spinner */
#adminLoading .spinner-border {
  color: var(--color-rosie-pink) !important;
}

/* Dark mode adjustments */
[data-bs-theme="dark"] #adminLoading {
  animation: rosie-heartbeat-glow 2s ease-in-out infinite;
}

/* =========================================================================
   Progressive Loading - Stats Cards with Heartbeat
   ========================================================================= */

/* Shimmer animation for placeholders */
@keyframes rosie-placeholder-shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Stats card loading state with heartbeat glow */
.stats-card.loading {
  animation: rosie-heartbeat-glow 2s ease-in-out infinite;
}

/* Rosie-themed placeholder styling */
.stats-card.loading .placeholder {
  background: linear-gradient(
    90deg,
    var(--color-rosie-pink-light) 25%,
    var(--color-rosie-pink) 50%,
    var(--color-rosie-pink-light) 75%
  );
  background-size: 200% 100%;
  animation: rosie-placeholder-shimmer 1.5s ease-in-out infinite;
  opacity: 0.7;
  border-radius: 4px;
}

/* Dark mode placeholder adjustments */
[data-bs-theme="dark"] .stats-card.loading .placeholder {
  background: linear-gradient(
    90deg,
    rgba(255, 99, 144, 0.3) 25%,
    rgba(255, 99, 144, 0.6) 50%,
    rgba(255, 99, 144, 0.3) 75%
  );
  background-size: 200% 100%;
}

/* Ensure placeholder-glow works with our rosie theme */
.stats-card .placeholder-glow .placeholder {
  animation: rosie-placeholder-shimmer 1.5s ease-in-out infinite;
}

/* Generic card loading state with heartbeat glow */
.card.loading {
  animation: rosie-heartbeat-glow 2s ease-in-out infinite;
}
