/* ========================================
   UNIFIED HEADER STYLES - All Analytics Pages
   ======================================== */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f7fa;
  color: #2d3748;
}

/* Header Container */
.header {
  background: white;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.65rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.header-content {
  max-width: 1800px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
}

/* Header Left Side */
.header-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.header-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.header-title h1 {
  font-size: 1rem;
  color: #1a202c;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
}

/* Navigation Links */
.header-nav {
  display: flex;
  gap: 0.2rem;
}

.nav-link {
  padding: 0.4rem 0.75rem;
  border-radius: 5px;
  text-decoration: none;
  font-size: 0.775rem;
  font-weight: 600;
  color: #4a5568;
  transition: all 0.2s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}

.nav-link:hover {
  background: #f7fafc;
  color: #667eea;
}

.nav-link.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

/* Date Controls */
.date-selector,
.controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.date-range-box {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid #cbd5e0;
  border-radius: 5px;
  background: white;
  height: 34px;
}

.date-range-box input {
  border: none;
  outline: none;
  font-size: 0.75rem;
  padding: 0;
  width: 92px;
}

.date-range-box span {
  color: #a0aec0;
  font-weight: 500;
  font-size: 0.75rem;
}

/* Quick Filters Dropdown */
.quick-filters,
.branch-filter {
  position: relative;
}

.btn-period,
.btn-branch {
  padding: 0.4rem 0.7rem;
  border: 1px solid #cbd5e0;
  background: white;
  border-radius: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: #4a5568;
  min-width: 105px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  white-space: nowrap;
}

.btn-period span:first-child,
.btn-branch span:first-child {
  flex: 1;
  text-align: left;
}

.btn-period span:last-child {
  font-size: 0.6rem;
  opacity: 0.6;
}

.btn-period:hover,
.btn-branch:hover {
  border-color: #667eea;
  color: #667eea;
}

.period-dropdown,
.branch-dropdown {
  position: absolute;
  top: 110%;
  left: 0;
  min-width: 150px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 0.4rem;
  z-index: 1000;
  max-height: 400px;
  overflow-y: auto;
}

.branch-dropdown {
  right: 0;
  left: auto;
  min-width: 260px;
  padding: 0.8rem;
}

.period-dropdown.hidden,
.branch-dropdown.hidden {
  display: none;
}

.period-option {
  padding: 0.45rem 0.65rem;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s ease;
  font-size: 0.775rem;
  font-weight: 600;
  color: #4a5568;
}

.period-option:hover {
  background: #f7fafc;
  color: #667eea;
}

.period-option.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.period-divider {
  height: 1px;
  background: #e2e8f0;
  margin: 0.4rem 0;
}

/* Branch Filter Options */
.branch-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s ease;
  margin-bottom: 0.3rem;
}

.branch-option:hover {
  background: #f7fafc;
}

.branch-option.all {
  font-weight: 700;
  color: #667eea;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
}

.branch-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #667eea;
}

.branch-option span {
  flex: 1;
  font-size: 0.8rem;
  color: #2d3748;
}

.branch-options.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* Search Box (Customers Page) */
.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid #cbd5e0;
  border-radius: 5px;
  background: white;
  min-width: 200px;
  height: 34px;
}

.search-box input {
  border: none;
  outline: none;
  font-size: 0.775rem;
  flex: 1;
  min-width: 0;
}

/* Buttons */
.btn {
  padding: 0.4rem 0.75rem;
  border: 1px solid #cbd5e0;
  border-radius: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
  color: #4a5568;
  height: 34px;
  white-space: nowrap;
}

.btn:hover {
  border-color: #667eea;
  color: #667eea;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
}

.btn-primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(102, 126, 234, 0.25);
}

/* Last Updated Badge - Top Right */
.container {
  position: relative;
}

.last-update-badge {
  position: absolute;
  top: -0.5rem;
  right: 2rem;
  font-size: 0.7rem;
  color: #718096;
  background: white;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  z-index: 10;
}

/* Stats Bar */
.stats-bar {
  position: relative;
}

/* Footer */
.analytics-footer {
  text-align: center;
  padding: 2rem 1rem 1rem;
  margin-top: 3rem;
  color: #a0aec0;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* Responsive */
@media (max-width: 1024px) {
  .header-content {
    flex-wrap: wrap;
    gap: 1rem;
  }
  
  .header-left {
    gap: 1rem;
  }
  
  .header-nav {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    padding-top: 0.5rem;
    border-top: 1px solid #e2e8f0;
  }
}

@media (max-width: 768px) {
  .header {
    padding: 0.5rem 1rem;
  }
  
  .header-title h1 {
    font-size: 0.9rem;
  }
  
  .header-logo {
    width: 28px;
    height: 28px;
  }
  
  .nav-link {
    font-size: 0.7rem;
    padding: 0.35rem 0.6rem;
  }
  
  .date-range-box,
  .btn-period,
  .btn-branch,
  .search-box,
  .btn {
    height: 30px;
    font-size: 0.7rem;
    padding: 0.3rem 0.6rem;
  }
  
  .date-range-box input {
    width: 80px;
    font-size: 0.7rem;
  }
}
