/**
 * Theme Selection System
 * 
 * Clean, cascading CSS theme system without !important statements
 * Supports multiple themes with proper specificity
 * 
 * Version: 1.0
 * Created: July 8, 2025
 */

/* Theme Base Classes */
.theme-light {
  --theme-bg: #ffffff;
  --theme-surface: #f8fafc;
  --theme-text: #1f2937;
  --theme-text-secondary: #6b7280;
  --theme-text-muted: #9ca3af;
  --theme-border: #e5e7eb;
  --theme-shadow: rgba(0, 0, 0, 0.1);
}

.theme-dark {
  --theme-bg: #1f2937;
  --theme-surface: #374151;
  --theme-text: #f9fafb;
  --theme-text-secondary: #d1d5db;
  --theme-text-muted: #9ca3af;
  --theme-border: #4b5563;
  --theme-shadow: rgba(0, 0, 0, 0.3);
}

.theme-blue {
  --theme-bg: #1e40af;
  --theme-surface: #3b82f6;
  --theme-text: #ffffff;
  --theme-text-secondary: #e0e7ff;
  --theme-text-muted: #c7d2fe;
  --theme-border: #60a5fa;
  --theme-shadow: rgba(30, 64, 175, 0.2);
}

.theme-green {
  --theme-bg: #065f46;
  --theme-surface: #10b981;
  --theme-text: #ffffff;
  --theme-text-secondary: #d1fae5;
  --theme-text-muted: #a7f3d0;
  --theme-border: #34d399;
  --theme-shadow: rgba(6, 95, 70, 0.2);
}

.theme-purple {
  --theme-bg: #581c87;
  --theme-surface: #8b5cf6;
  --theme-text: #ffffff;
  --theme-text-secondary: #e9d5ff;
  --theme-text-muted: #ddd6fe;
  --theme-border: #a78bfa;
  --theme-shadow: rgba(88, 28, 135, 0.2);
}

/* Theme Selector Widget */
.theme-selector {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: var(--z-index-top);
  background: var(--card-bg);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  border: 1px solid var(--border-color);
  transition: all var(--transition-normal);
}

/* Theme Selector Inline for Settings Page */
.theme-selector-inline {
  width: 100%;
}

.theme-selector-inline .card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-color);
}

.theme-selector-inline .card-header {
  background-color: var(--surface-bg);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-color);
}

.theme-selector-inline .card-title {
  color: var(--text-color);
  margin-bottom: 0;
}

.theme-selector-inline .card-text {
  color: var(--text-secondary);
}

.theme-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
}

.theme-option-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  border: 2px solid transparent;
  border-radius: var(--border-radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}

.theme-option-card:hover {
  border-color: var(--primary-color);
  background: var(--surface-bg);
}

.theme-option-card.active {
  border-color: var(--primary-color);
  background: var(--primary-color);
  color: white;
}

.theme-option-card .theme-option {
  width: 40px;
  height: 40px;
  margin-bottom: 0.5rem;
}

.theme-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-color);
}

.theme-option-card.active .theme-name {
  color: white;
}

/* Theme-specific styling for the theme selector cards */
.theme-light .theme-selector-inline .card {
  background-color: #ffffff;
  border-color: #e5e7eb;
  color: #1f2937;
}

.theme-light .theme-selector-inline .card-header {
  background-color: #f9fafb;
  color: #1f2937;
}

.theme-light .theme-selector-inline .card-title {
  color: #1f2937;
}

.theme-light .theme-selector-inline .card-text {
  color: #6b7280;
}

.theme-light .theme-name {
  color: #1f2937;
}

.theme-dark .theme-selector-inline .card {
  background-color: #374151;
  border-color: #4b5563;
  color: #f9fafb;
}

.theme-dark .theme-selector-inline .card-header {
  background-color: #1f2937;
  color: #f9fafb;
}

.theme-dark .theme-selector-inline .card-title {
  color: #f9fafb;
}

.theme-dark .theme-selector-inline .card-text {
  color: #9ca3af;
}

.theme-dark .theme-name {
  color: #f9fafb;
}

/* Add missing theme-specific styling for blue, green, and purple themes */
.theme-blue .theme-selector-inline .card {
  background-color: #1e40af;
  border-color: #3b82f6;
  color: #ffffff;
}

.theme-blue .theme-selector-inline .card-header {
  background-color: #1e3a8a;
  color: #ffffff;
}

.theme-blue .theme-selector-inline .card-title {
  color: #ffffff;
}

.theme-blue .theme-selector-inline .card-text {
  color: #e0e7ff;
}

.theme-blue .theme-name {
  color: #ffffff;
}

.theme-green .theme-selector-inline .card {
  background-color: #065f46;
  border-color: #10b981;
  color: #ffffff;
}

.theme-green .theme-selector-inline .card-header {
  background-color: #064e3b;
  color: #ffffff;
}

.theme-green .theme-selector-inline .card-title {
  color: #ffffff;
}

.theme-green .theme-selector-inline .card-text {
  color: #d1fae5;
}

.theme-green .theme-name {
  color: #ffffff;
}

.theme-purple .theme-selector-inline .card {
  background-color: #581c87;
  border-color: #8b5cf6;
  color: #ffffff;
}

.theme-purple .theme-selector-inline .card-header {
  background-color: #4c1d95;
  color: #ffffff;
}

.theme-purple .theme-selector-inline .card-title {
  color: #ffffff;
}

.theme-purple .theme-selector-inline .card-text {
  color: #e9d5ff;
}

.theme-purple .theme-name {
  color: #ffffff;
}

.theme-selector.minimized {
  padding: 0.5rem;
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius-circle);
  cursor: pointer;
  justify-content: center;
}

.theme-selector.minimized .theme-option {
  display: none;
}

.theme-selector.minimized .theme-toggle {
  display: block;
}

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--border-radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  display: none;
}

.theme-toggle:hover {
  color: var(--primary-color);
  background: var(--surface-bg);
}

.theme-option {
  width: 30px;
  height: 30px;
  border-radius: var(--border-radius-circle);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.theme-option:hover {
  transform: scale(1.1);
  border-color: var(--primary-color);
}

.theme-option.active {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px var(--primary-color);
}

.theme-option.light {
  background: linear-gradient(135deg, #ffffff 50%, #f8fafc 50%);
}

.theme-option.dark {
  background: linear-gradient(135deg, #1f2937 50%, #374151 50%);
}

.theme-option.blue {
  background: linear-gradient(135deg, #1e40af 50%, #3b82f6 50%);
}

.theme-option.green {
  background: linear-gradient(135deg, #065f46 50%, #10b981 50%);
}

.theme-option.purple {
  background: linear-gradient(135deg, #581c87 50%, #8b5cf6 50%);
}

/* Theme-specific body styles */
body.theme-light {
  background-color: var(--theme-bg);
  color: var(--theme-text);
}

body.theme-dark {
  background-color: var(--theme-bg);
  color: var(--theme-text);
}

body.theme-blue {
  background-color: var(--theme-bg);
  color: var(--theme-text);
}

body.theme-green {
  background-color: var(--theme-bg);
  color: var(--theme-text);
}

body.theme-purple {
  background-color: var(--theme-bg);
  color: var(--theme-text);
}

/* Card theming */
.theme-light .card {
  background-color: var(--theme-surface);
  border-color: var(--theme-border);
  color: var(--theme-text);
}

.theme-dark .card {
  background-color: var(--theme-surface);
  border-color: var(--theme-border);
  color: var(--theme-text);
}

.theme-blue .card {
  background-color: var(--theme-surface);
  border-color: var(--theme-border);
  color: var(--theme-text);
}

.theme-green .card {
  background-color: var(--theme-surface);
  border-color: var(--theme-border);
  color: var(--theme-text);
}

.theme-purple .card {
  background-color: var(--theme-surface);
  border-color: var(--theme-border);
  color: var(--theme-text);
}

/* Form theming */
.theme-light .form-control {
  background-color: #ffffff;
  border-color: var(--theme-border);
  color: #1f2937;
}

.theme-light .form-control:focus {
  background-color: #ffffff;
  border-color: var(--primary-color);
  color: #1f2937;
  box-shadow: 0 0 0 0.2rem rgba(139, 92, 246, 0.25);
}

.theme-dark .form-control {
  background-color: #374151;
  border-color: var(--theme-border);
  color: #f9fafb;
}

.theme-dark .form-control:focus {
  background-color: #374151;
  border-color: var(--primary-color);
  color: #f9fafb;
  box-shadow: 0 0 0 0.2rem rgba(139, 92, 246, 0.25);
}

.theme-blue .form-control {
  background-color: #1e40af;
  border-color: var(--theme-border);
  color: #ffffff;
}

.theme-blue .form-control:focus {
  background-color: #1e40af;
  border-color: var(--primary-color);
  color: #ffffff;
  box-shadow: 0 0 0 0.2rem rgba(139, 92, 246, 0.25);
}

.theme-green .form-control {
  background-color: #065f46;
  border-color: var(--theme-border);
  color: #ffffff;
}

.theme-green .form-control:focus {
  background-color: #065f46;
  border-color: var(--primary-color);
  color: #ffffff;
  box-shadow: 0 0 0 0.2rem rgba(139, 92, 246, 0.25);
}

.theme-purple .form-control {
  background-color: #581c87;
  border-color: var(--theme-border);
  color: #ffffff;
}

.theme-purple .form-control:focus {
  background-color: #581c87;
  border-color: var(--primary-color);
  color: #ffffff;
  box-shadow: 0 0 0 0.2rem rgba(139, 92, 246, 0.25);
}

/* Ensure text contrast */
.theme-light .text-secondary {
  color: #4b5563;
}

.theme-dark .text-secondary {
  color: #d1d5db;
}

.theme-light .text-muted {
  color: #6b7280;
}

.theme-dark .text-muted {
  color: #9ca3af;
}

.theme-blue .text-secondary {
  color: #e0e7ff;
}

.theme-blue .text-muted {
  color: #c7d2fe;
}

.theme-green .text-secondary {
  color: #d1fae5;
}

.theme-green .text-muted {
  color: #a7f3d0;
}

.theme-purple .text-secondary {
  color: #e9d5ff;
}

.theme-purple .text-muted {
  color: #ddd6fe;
}

/* Settings page specific text contrast */
.theme-light .card-title {
  color: #1f2937;
}

.theme-light .card-text {
  color: #374151;
}

.theme-light .form-label {
  color: #1f2937;
}

.theme-light .form-check-label,
.theme-light .form-check-label strong {
  color: #374151;
}

.theme-dark .card-title {
  color: #f9fafb;
}

.theme-dark .card-text {
  color: #d1d5db;
}

.theme-dark .form-label {
  color: #f9fafb;
}

.theme-dark .form-check-label {
  color: #d1d5db;
}

/* Settings specific card styling for better contrast */
.theme-light .settings-card {
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  color: #1f2937;
}

.theme-light .settings-card .card-title {
  color: #1f2937;
}

.theme-light .settings-card .text-muted {
  color: #6b7280;
}

.theme-dark .settings-card {
  background-color: #374151;
  border: 1px solid #4b5563;
  color: #f9fafb;
}

.theme-dark .settings-card .card-title {
  color: #f9fafb;
}

.theme-dark .settings-card .text-muted {
  color: #9ca3af;
}

/* Settings page title styling */
.settings-page-title {
  color: var(--text-color);
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.theme-light .settings-page-title {
  color: #1f2937;
}

.theme-dark .settings-page-title {
  color: #f9fafb;
}

.theme-blue .settings-page-title {
  color: #f1f5f9;
}

.theme-green .settings-page-title {
  color: #f0fdf4;
}

.theme-purple .settings-page-title {
  color: #faf5ff;
}

/* Audio Notes Content Styling - ensure proper contrast across all themes */
.audio-note-content,
.transcript-content,
.summary-text {
  color: var(--text-color);
  line-height: 1.6;
}

.theme-light .audio-note-content,
.theme-light .transcript-content,
.theme-light .summary-text {
  color: #1f2937;
  background-color: #f9fafb;
}

.theme-dark .audio-note-content,
.theme-dark .transcript-content,
.theme-dark .summary-text {
  color: #f9fafb;
  background-color: #374151;
}

.theme-blue .audio-note-content,
.theme-blue .transcript-content,
.theme-blue .summary-text {
  color: #f1f5f9;
  background-color: #1e40af;
}

.theme-green .audio-note-content,
.theme-green .transcript-content,
.theme-green .summary-text {
  color: #f0fdf4;
  background-color: #065f46;
}

.theme-purple .audio-note-content,
.theme-purple .transcript-content,
.theme-purple .summary-text {
  color: #faf5ff;
  background-color: #581c87;
}

/* Comprehensive text contrast fixes for all themes */
/* Light theme - dark text on light backgrounds */
.theme-light h1, .theme-light h2, .theme-light h3, .theme-light h4, .theme-light h5, .theme-light h6 {
  color: #1f2937;
}

.theme-light p, .theme-light span, .theme-light div, .theme-light li, .theme-light td {
  color: #374151;
}

.theme-light .text-muted {
  color: #6b7280;
}

.theme-light .text-secondary {
  color: #6b7280;
}

/* Dark theme - light text on dark backgrounds */
.theme-dark h1, .theme-dark h2, .theme-dark h3, .theme-dark h4, .theme-dark h5, .theme-dark h6 {
  color: #f9fafb;
}

.theme-dark p, .theme-dark span, .theme-dark div, .theme-dark li, .theme-dark td {
  color: #d1d5db;
}

.theme-dark .text-muted {
  color: #9ca3af;
}

.theme-dark .text-secondary {
  color: #9ca3af;
}

/* Blue theme - white text on blue backgrounds */
.theme-blue h1, .theme-blue h2, .theme-blue h3, .theme-blue h4, .theme-blue h5, .theme-blue h6 {
  color: #ffffff;
}

.theme-blue p, .theme-blue span, .theme-blue div, .theme-blue li, .theme-blue td {
  color: #f1f5f9;
}

.theme-blue .text-muted {
  color: #c7d2fe;
}

.theme-blue .text-secondary {
  color: #e0e7ff;
}

/* Green theme - white text on green backgrounds */
.theme-green h1, .theme-green h2, .theme-green h3, .theme-green h4, .theme-green h5, .theme-green h6 {
  color: #ffffff;
}

.theme-green p, .theme-green span, .theme-green div, .theme-green li, .theme-green td {
  color: #f0fdf4;
}

.theme-green .text-muted {
  color: #a7f3d0;
}

.theme-green .text-secondary {
  color: #d1fae5;
}

/* Purple theme - white text on purple backgrounds */
.theme-purple h1, .theme-purple h2, .theme-purple h3, .theme-purple h4, .theme-purple h5, .theme-purple h6 {
  color: #ffffff;
}

.theme-purple p, .theme-purple span, .theme-purple div, .theme-purple li, .theme-purple td {
  color: #faf5ff;
}

.theme-purple .text-muted {
  color: #ddd6fe;
}

.theme-purple .text-secondary {
  color: #e9d5ff;
}

/* Footer Navigation - Bright consistent styling across all themes */
.mobile-nav-footer {
  background-color: #ffffff;
  border-top: 1px solid #e5e7eb;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 58px;
  z-index: 1030;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  width: 100%;
  overflow: hidden;
}

/* Override any alternative home page styles for footer */
.alternative-home .mobile-nav-footer {
  background-color: #ffffff;
  border-top: 1px solid #e5e7eb;
}

/* Footer navigation items - consistent dark text on bright background */
.mobile-nav-footer .nav-action-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  height: 58px;
  text-decoration: none;
  padding: 8px 0;
  transition: color 0.2s ease, background-color 0.2s ease;
  font-size: 0.75rem;
  font-weight: 500;
}

/* Footer navigation icons */
.mobile-nav-footer .nav-action-link i {
  font-size: 1.2rem;
  margin-bottom: 4px;
  color: #6b7280;
  display: block;
}

/* Hover states for footer navigation */
.mobile-nav-footer .nav-action-link:hover {
  color: #374151;
  background-color: rgba(0, 0, 0, 0.05);
  text-decoration: none;
}

.mobile-nav-footer .nav-action-link:hover i {
  color: #374151;
}

/* Active states for footer navigation */
.mobile-nav-footer .nav-action-link.active {
  color: #8b5cf6;
  background-color: rgba(139, 92, 246, 0.1);
  border-radius: 8px;
}

.mobile-nav-footer .nav-action-link.active i {
  color: #8b5cf6;
}

/* Override any theme-specific styling for footer navigation */
.theme-light .mobile-nav-footer,
.theme-dark .mobile-nav-footer,
.theme-blue .mobile-nav-footer,
.theme-green .mobile-nav-footer,
.theme-purple .mobile-nav-footer {
  background-color: #ffffff;
  border-top: 1px solid #e5e7eb;
}

.theme-light .mobile-nav-footer .nav-action-link,
.theme-dark .mobile-nav-footer .nav-action-link,
.theme-blue .mobile-nav-footer .nav-action-link,
.theme-green .mobile-nav-footer .nav-action-link,
.theme-purple .mobile-nav-footer .nav-action-link {
  color: #6b7280;
}

.theme-light .mobile-nav-footer .nav-action-link i,
.theme-dark .mobile-nav-footer .nav-action-link i,
.theme-blue .mobile-nav-footer .nav-action-link i,
.theme-green .mobile-nav-footer .nav-action-link i,
.theme-purple .mobile-nav-footer .nav-action-link i {
  color: #6b7280;
}

.theme-light .mobile-nav-footer .nav-action-link.active,
.theme-dark .mobile-nav-footer .nav-action-link.active,
.theme-blue .mobile-nav-footer .nav-action-link.active,
.theme-green .mobile-nav-footer .nav-action-link.active,
.theme-purple .mobile-nav-footer .nav-action-link.active {
  color: #8b5cf6;
  background-color: rgba(139, 92, 246, 0.1);
}

.theme-light .mobile-nav-footer .nav-action-link.active i,
.theme-dark .mobile-nav-footer .nav-action-link.active i,
.theme-blue .mobile-nav-footer .nav-action-link.active i,
.theme-green .mobile-nav-footer .nav-action-link.active i,
.theme-purple .mobile-nav-footer .nav-action-link.active i {
  color: #8b5cf6;
}

/* Override alternative home page styles for footer navigation */
.alternative-home .mobile-nav-footer .nav-action-link {
  color: #6b7280;
}

.alternative-home .mobile-nav-footer .nav-action-link i {
  color: #6b7280;
}

.alternative-home .mobile-nav-footer .nav-action-link:hover {
  color: #374151;
  background-color: rgba(0, 0, 0, 0.05);
}

.alternative-home .mobile-nav-footer .nav-action-link:hover i {
  color: #374151;
}

.alternative-home .mobile-nav-footer .nav-action-link.active {
  color: #8b5cf6;
  background-color: rgba(139, 92, 246, 0.1);
}

.alternative-home .mobile-nav-footer .nav-action-link.active i {
  color: #8b5cf6;
}

/* Force consistent footer styling with highest specificity */
body .mobile-nav-footer {
  background-color: #ffffff;
  border-top: 1px solid #e5e7eb;
}

body .mobile-nav-footer .nav-action-link {
  color: #6b7280;
}

body .mobile-nav-footer .nav-action-link i {
  color: #6b7280;
}

body .mobile-nav-footer .nav-action-link:hover {
  color: #374151;
  background-color: rgba(0, 0, 0, 0.05);
}

body .mobile-nav-footer .nav-action-link:hover i {
  color: #374151;
}

body .mobile-nav-footer .nav-action-link.active {
  color: #8b5cf6;
  background-color: rgba(139, 92, 246, 0.1);
  border-radius: 8px;
}

body .mobile-nav-footer .nav-action-link.active i {
  color: #8b5cf6;
}

/* Ensure Coach icon is visible when active - High specificity override */
body .mobile-nav-footer .nav-action-link.active i.fa-comment-dots,
body .mobile-nav-footer .nav-action-link.active i.fa-comments,
body .mobile-nav-footer .nav-action-link.active i {
  color: #8b5cf6;
}

/* Force all active navigation icons to be purple with max specificity */
.mobile-nav-footer .nav-action-link.active i,
.mobile-nav-footer .nav-action-link.active .fas,
.mobile-nav-footer .nav-action-link.active .fa {
  color: #8b5cf6;
}

/* Ultimate override for active navigation icons with maximum specificity */
body .theme-light .mobile-nav-footer .nav-action-link.active i,
body .theme-dark .mobile-nav-footer .nav-action-link.active i,
body .theme-blue .mobile-nav-footer .nav-action-link.active i,
body .theme-green .mobile-nav-footer .nav-action-link.active i,
body .theme-purple .mobile-nav-footer .nav-action-link.active i,
body .mobile-nav-footer .nav-action-link.active i {
  color: #8b5cf6;
}

/* Force active state with inline style equivalent CSS */
.mobile-nav-footer .nav-action-link.active {
  color: #8b5cf6;
  background-color: rgba(139, 92, 246, 0.1);
  border-radius: 8px;
}

.mobile-nav-footer .nav-action-link.active i {
  color: #8b5cf6;
}

/* Nuclear option - use attribute selector for active state */
.mobile-nav-footer a[class*="active"] {
  color: #8b5cf6;
  background-color: rgba(139, 92, 246, 0.1);
  border-radius: 8px;
}

.mobile-nav-footer a[class*="active"] i {
  color: #8b5cf6;
}

/* Audio notes card styling */
.audio-note-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-color);
}

.theme-light .audio-note-card {
  background-color: #ffffff;
  border-color: #e5e7eb;
  color: #1f2937;
}

.theme-dark .audio-note-card {
  background-color: #374151;
  border-color: #4b5563;
  color: #f9fafb;
}

.theme-blue .audio-note-card {
  background-color: #1e3a8a;
  border-color: #1e40af;
  color: #f1f5f9;
}

.theme-green .audio-note-card {
  background-color: #065f46;
  border-color: #047857;
  color: #f0fdf4;
}

.theme-purple .audio-note-card {
  background-color: #581c87;
  border-color: #6b21a8;
  color: #faf5ff;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .theme-selector {
    top: 10px;
    right: 10px;
    padding: 0.5rem;
  }
  
  .theme-option {
    width: 25px;
    height: 25px;
  }
}