/* Header Navigation Fixes */
/* Fix for white text on white background and layout issues */

/* Main Header Styling - DISABLED FOR TEMPLATE HEADER */
/*
.header {
  background: var(--bg-primary, #ffffff);
  border-bottom: 1px solid var(--border-color, #dee2e6);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow-small, 0 2px 4px rgba(0,0,0,0.1));
}
*/

/* Header Navigation */
.header-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.nav-list {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 1rem;
  align-items: center;
}

.nav-item {
  margin: 0;
  padding: 0;
}

/* Navigation Buttons */
.nav-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-secondary, #6c757d);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  min-width: 44px;
  min-height: 44px;
}

.nav-button:hover {
  background: var(--bg-hover, #f5f5f5);
  color: var(--text-primary, #212529);
  transform: translateY(-1px);
}

.nav-button:focus {
  outline: 2px solid var(--primary-color, #007bff);
  outline-offset: 2px;
}

.nav-button.active {
  background: var(--primary-color, #007bff);
  color: white;
  box-shadow: var(--shadow-small, 0 2px 4px rgba(0,0,0,0.1));
}

.nav-button.active:hover {
  background: var(--primary-color, #007bff);
  color: white;
  transform: translateY(-1px);
}

.nav-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.nav-text {
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
}

/* Fix for header section scroll button icon centering */
.nav-button .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0 auto;
}

.nav-button .nav-icon i {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  text-align: center;
}

/* Additional fixes for icon alignment */
.nav-button .nav-icon .fas,
.nav-button .nav-icon .far,
.nav-button .nav-icon .fab {
  line-height: 1;
  vertical-align: baseline;
}

/* Touch Optimized Buttons */
.touch-optimized {
  min-width: 44px;
  min-height: 44px;
  position: relative;
}

/* Fix for header counter controls positioning */
.multi-counter-header .counter-controls {
  order: 2; /* Move after main content */
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-secondary, #f8f9fa);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

/* Ensure main content comes first */
.multi-counter-interface {
  order: 1;
}

.statistics-dashboard {
  order: 1;
}

/* Counter Menu Dropdown Styles */
.counter-menu {
  position: relative;
}

.counter-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  min-width: 140px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
}

.counter-menu-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.counter-menu-dropdown .menu-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  color: #333;
  text-decoration: none;
  transition: background-color 0.2s;
}

.counter-menu-dropdown .menu-item:hover {
  background-color: #f5f5f5;
}

.counter-menu-dropdown .menu-item.danger {
  color: #dc3545;
}

.counter-menu-dropdown .menu-item.danger:hover {
  background-color: #f8d7da;
}

.counter-menu-dropdown .menu-item i {
  margin-right: 8px;
  width: 12px;
  text-align: center;
}

.counter-menu-dropdown .menu-item:first-child {
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
}

.counter-menu-dropdown .menu-item:last-child {
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
}

/* Counter Menu Button Styling */
.counter-menu-btn {
  background: none !important;
  border: none !important;
  color: #666 !important;
  padding: 4px 8px !important;
  border-radius: 4px !important;
  opacity: 0.7;
  transition: opacity 0.2s, background-color 0.2s !important;
}

.counter-menu-btn:hover {
  opacity: 1;
  background-color: rgba(0,0,0,0.1) !important;
  color: #333 !important;
}

.counter-card:hover .counter-menu-btn {
  opacity: 1;
}

/* Mobile Header Navigation */
.header-mobile-toggle {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
}

.mobile-menu-toggle {
  background: var(--primary-color, #2ba8ff);
  color: white;
  border: none;
  padding: 0.5rem;
  border-radius: 4px;
  cursor: pointer;
}

.mobile-menu-toggle:hover {
  background: var(--primary-color-dark, #1a8fd9);
}

.header-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-color, #333);
}

/* Settings Panel Styling */
.settings-content {
  padding: 2rem;
  text-align: center;
}

.settings-placeholder {
  margin-top: 2rem;
  padding: 3rem;
  background: #f8f9fa;
  border-radius: 8px;
  color: #6c757d;
}

.settings-placeholder i {
  color: #adb5bd;
  margin-bottom: 1rem;
}

.settings-placeholder p {
  font-size: 1.1rem;
  margin: 0;
}

/* Enhanced Mobile Stats Header Fixes */
@media (max-width: 768px) {
  .stats-header {
    padding: 1rem 0.5rem;
  }
  
  .stats-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  
  /* Mobile Stats Header Toggle */
  .stats-mobile-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--primary-color, #2ba8ff);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
  }
  
  .stats-mobile-toggle:hover {
    background: var(--primary-color-dark, #1a8fd9);
  }
  
  .stats-mobile-toggle .toggle-icon {
    transition: transform 0.2s ease;
  }
  
  .stats-controls.collapsed .stats-mobile-toggle .toggle-icon {
    transform: rotate(180deg);
  }
  
  /* Collapsible Stats Controls */
  .stats-controls-content {
    display: none;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-top: 0.5rem;
  }
  
  .stats-controls.expanded .stats-controls-content {
    display: flex;
  }
  
  .view-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  
  .stats-view-btn {
    flex: none;
    font-size: 0.75rem;
    padding: 0.6rem 0.5rem;
    white-space: nowrap;
    text-align: center;
    border-radius: 4px;
  }
  
  .stats-view-btn i {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 1rem;
  }
  
  .time-range-selector {
    width: 100%;
    margin: 0;
  }
  
  .time-range-selector select {
    width: 100%;
    font-size: 0.875rem;
    padding: 0.75rem;
  }
  
  .stats-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
  }
  
  .stats-actions .btn {
    flex: none;
    font-size: 0.75rem;
    padding: 0.6rem 0.5rem;
    text-align: center;
  }
  
  .stats-actions .btn i {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .view-selector {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }
  
  .stats-view-btn {
    padding: 0.5rem;
    font-size: 0.7rem;
  }
  
  .stats-actions {
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }
  
  .stats-actions .btn {
    padding: 0.5rem;
    font-size: 0.7rem;
  }
  
  .stats-actions .btn:last-child {
    grid-column: 1 / -1;
  }
}

/* Responsive Navigation */
@media (max-width: 768px) {
  .nav-list {
    gap: 0.5rem;
  }
  
  .nav-button {
    padding: 0.5rem;
    min-width: 40px;
    min-height: 40px;
  }
  
  .nav-text {
    font-size: 0.6875rem;
  }
  
  .nav-icon {
    font-size: 1rem;
  }
  
  .header-mobile-toggle {
    display: flex;
  }
  
  .multi-counter-header {
    flex-direction: column;
    position: relative;
  }
  
  .multi-counter-header .counter-controls,
  .multi-counter-header .view-controls {
    display: none;
    flex-direction: column;
    width: 100%;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 1rem;
    margin-top: 0.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 1000;
  }
  
  .mobile-menu-open .multi-counter-header .counter-controls,
  .mobile-menu-open .multi-counter-header .view-controls {
    display: flex !important;
  }
  
  .multi-counter-header .counter-controls .btn,
  .multi-counter-header .view-controls .btn {
    width: 100%;
    margin-bottom: 0.5rem;
    justify-content: flex-start;
  }
  
  .multi-counter-header .counter-controls .btn:last-child,
  .multi-counter-header .view-controls .btn:last-child {
    margin-bottom: 0;
  }
  
  .view-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
  }
  
  .view-toggle .btn {
    flex: 1;
    margin-bottom: 0;
  }
  
  .search-controls {
    display: flex;
    gap: 0.5rem;
  }
  
  .search-controls input {
    flex: 1;
  }
  
  .search-controls .btn {
    margin-bottom: 0;
    width: auto;
  }
}

@media (max-width: 480px) {
  .header-title {
    font-size: 1.1rem;
  }
  
  .mobile-menu-toggle {
    padding: 0.4rem;
  }
  
  .multi-counter-header .counter-controls,
  .multi-counter-header .view-controls {
    padding: 0.75rem;
  }
}

/* Layout Structure Fixes */
.demo-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Mobile Layout Restructure */
@media (max-width: 768px) {
  .demo-container {
    padding: 0;
  }
  
  /* Hide demo header and nav on mobile - will be in hamburger */
  .demo-header,
  .demo-nav {
    display: none;
  }
  
  /* Create mobile header */
  .mobile-main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--primary-color, #2ba8ff);
    color: white;
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
  }
  
  .mobile-main-header h1 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
  }
  
  .main-hamburger-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s;
  }
  
  .main-hamburger-toggle:hover {
    background-color: rgba(255,255,255,0.1);
  }
  
  /* Mobile Menu Overlay */
  .mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  
  .mobile-menu-overlay.show {
    display: block;
    opacity: 1;
  }
  
  /* Mobile Menu Content */
  .mobile-menu-content {
    position: fixed;
    top: 0;
    left: -300px;
    width: 280px;
    height: 100vh;
    background: white;
    z-index: 2001;
    transition: left 0.3s ease;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
  }
  
  .mobile-menu-overlay.show .mobile-menu-content {
    left: 0;
  }
  
  .mobile-menu-header {
    background: var(--primary-color, #2ba8ff);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  .mobile-menu-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
  }
  
  .mobile-menu-nav {
    padding: 1rem 0;
  }
  
  .mobile-menu-nav button {
    display: block;
    width: 100%;
    padding: 1rem 1.5rem;
    border: none;
    background: none;
    text-align: left;
    font-size: 1rem;
    color: #333;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid #eee;
  }
  
  .mobile-menu-nav button:hover {
    background-color: #f8f9fa;
  }
  
  .mobile-menu-nav button.active {
    background-color: var(--primary-color, #2ba8ff);
    color: white;
  }
  
  /* Main content adjustments */
  .demo-section {
    padding: 1rem;
    margin-top: 0;
  }
}

/* Desktop - keep existing layout */
@media (min-width: 769px) {
  .mobile-main-header,
  .mobile-menu-overlay {
    display: none;
  }
}

/* Fix for layout order issues */
.main-content {
  display: flex;
  flex-direction: column;
}

/* Ensure proper z-index for modals and overlays */
.modal {
  z-index: 2000;
}

.modal-backdrop {
  z-index: 1999;
}

/* Fix for ellipsis menu functionality */
.counter-menu {
  position: relative;
}

.counter-menu-button {
  background: none;
  border: none;
  color: var(--text-secondary, #6c757d);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.counter-menu-button:hover {
  background: var(--bg-hover, #f5f5f5);
  color: var(--text-primary, #212529);
}

.counter-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border: 1px solid var(--border-color, #dee2e6);
  border-radius: 6px;
  box-shadow: var(--shadow-medium, 0 4px 6px rgba(0,0,0,0.1));
  min-width: 150px;
  z-index: 1000;
  display: none;
}

.counter-menu-dropdown.show {
  display: block;
}

.counter-menu-item {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: none;
  background: none;
  text-align: left;
  color: var(--text-primary, #212529);
  cursor: pointer;
  transition: background 0.2s ease;
}

.counter-menu-item:hover {
  background: var(--bg-hover, #f5f5f5);
}

.counter-menu-item:first-child {
  border-radius: 6px 6px 0 0;
}

.counter-menu-item:last-child {
  border-radius: 0 0 6px 6px;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  .nav-button,
  .counter-menu-button,
  .counter-menu-item {
    transition: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .nav-button {
    border: 1px solid currentColor;
  }
  
  .nav-button.active {
    border: 2px solid white;
  }
}

/* Print styles */
@media print {
  .header,
  .counter-controls,
  .counter-menu {
    display: none;
  }
}

/* Full-width header fix */
.demo-header {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 2rem 1rem;
}

.demo-nav {
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
}
