/**
 * Header & Footer Component Styles
 * Unified header and footer styling for all pages
 */

/* ========== Common Header Styles ========== */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header, 100);
  background: var(--bg-primary, #fdfdfd);
  border-bottom: 1px solid var(--border-color, #e0e0e0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition:
    background-color 0.3s ease,
    box-shadow 0.3s ease;
}

[data-theme="dark"] .site-header {
  background: var(--bg-primary, #1a1a1a);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.site-header-minimal {
  box-shadow: none;
  border-bottom-color: transparent;
  background: transparent;
  position: absolute;
  width: 100%;
}

[data-theme="dark"] .site-header-minimal {
  background: transparent;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 20px;
  gap: 16px;
}

/* ========== Logo ========== */
.header-logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.header-logo .site-logo {
  max-height: 50px;
  width: auto;
  transition: transform 0.2s ease;
}

.header-logo:hover .site-logo {
  transform: scale(1.02);
}

/* Dark mode logo: add background for visibility */
[data-theme="dark"] .header-logo .site-logo {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 4px;
}

/* ========== Header Right Section ========== */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
}

/* ========== Speiseplan Link Button ========== */
.speiseplan-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-secondary, #f5f5f5);
  border: 1px solid var(--border-color, #e0e0e0);
  border-radius: 8px;
  color: var(--text-primary, #333);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
}

.speiseplan-link-btn:hover {
  background: var(--bg-card-alt, #e0e0e0);
  color: var(--accent-orange, #ff8947);
}

[data-theme="dark"] .speiseplan-link-btn {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .speiseplan-link-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.speiseplan-icon {
  font-size: 16px;
}

.speiseplan-text {
  display: inline;
}

/* Hide text on small screens */
@media (max-width: 600px) {
  .speiseplan-text {
    display: none;
  }

  .speiseplan-link-btn {
    padding: 8px 12px;
  }
}

/* ========== Login Trigger Button ========== */
.login-trigger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  background: linear-gradient(
    135deg,
    var(--accent-orange, #ff8947) 0%,
    #ed7e43 100%
  );
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(255, 137, 71, 0.3);
}

.login-trigger-btn:hover {
  background: linear-gradient(
    135deg,
    #ed7e43 0%,
    var(--accent-orange, #ff8947) 100%
  );
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 137, 71, 0.4);
}

.login-trigger-btn:active {
  transform: translateY(0);
}

/* ========== User Menu (Logged In) ========== */
.user-menu-container {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-name-display {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary, #333);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
  display: inline-block;
  flex: 0 1 auto;
}

[data-theme="dark"] .user-name-display {
  color: var(--text-primary, #e0e0e0);
}

@media (max-width: 375px) {
  .user-name-display {
    display: none;
  }
}

/* ========== User Avatar ========== */
.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(
    135deg,
    var(--accent-orange, #ff8947) 0%,
    #ed7e43 100%
  );
  color: white;
  border: none;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(255, 137, 71, 0.3);
}

.user-avatar:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(255, 137, 71, 0.4);
}

/* ========== User Dropdown ========== */
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 260px;
  background: var(--bg-card, white);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color, #e0e0e0);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  z-index: var(--z-dropdown, 500);
  overflow: hidden;
}

[data-theme="dark"] .user-dropdown {
  background: var(--bg-card, #2d2d2d);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.user-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-dropdown-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color, #e0e0e0);
  background: var(--bg-secondary, #f5f5f5);
}

[data-theme="dark"] .user-dropdown-header {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

.user-dropdown-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary, #333);
}

[data-theme="dark"] .user-dropdown-name {
  color: var(--text-primary, #e0e0e0);
}

.user-dropdown-items {
  padding: 8px 0;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-primary, #333);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.user-dropdown-item:hover {
  background: var(--bg-secondary, #f5f5f5);
}

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

[data-theme="dark"] .user-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.user-dropdown-admin {
  color: #c00;
}

[data-theme="dark"] .user-dropdown-admin {
  color: #ff6b6b;
}

.user-dropdown-logout {
  color: #e53935;
}

[data-theme="dark"] .user-dropdown-logout {
  color: #ff6b6b;
}

.user-dropdown-divider {
  height: 1px;
  background: var(--border-color, #e0e0e0);
  margin: 8px 0;
}

[data-theme="dark"] .user-dropdown-divider {
  background: rgba(255, 255, 255, 0.1);
}

.dropdown-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.dropdown-label {
  flex: 1;
}

.logout-form {
  margin: 0;
}

/* ========== Theme Toggle in Dropdown ========== */
.dropdown-theme-toggle {
  justify-content: flex-start;
}

.theme-switch-inline {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.theme-switch-inline input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-inline {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  border-radius: 24px;
  transition: 0.3s;
}

.slider-inline:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.3s;
}

.theme-switch-inline input:checked + .slider-inline {
  background-color: var(--accent-orange, #ff8947);
}

.theme-switch-inline input:checked + .slider-inline:before {
  transform: translateX(20px);
}

/* ========== Header Theme Toggle (standalone button) ========== */
.header-right > .theme-toggle {
  position: static;
  width: 38px;
  height: 38px;
  padding: 8px;
  box-shadow: none;
  background: var(--bg-secondary, #f0f0f0);
  border: 1px solid var(--border-color, #ddd);
  flex-shrink: 0;
  align-self: center;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-right > .theme-toggle:hover {
  background: var(--bg-card-alt, #e5e5e5);
  transform: scale(1.05);
}

[data-theme="dark"] .header-right > .theme-toggle {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .header-right > .theme-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ========== Site Footer ========== */
.site-footer {
  margin-top: auto;
  padding-top: 20px;
  width: 100%;
}

.footer-links {
  padding: 20px 15px;
  text-align: center;
  position: relative;
  z-index: 10;
  background: linear-gradient(135deg, #f8f8f8 0%, #f0f0f0 100%);
  border-radius: 12px;
  margin: 30px auto 10px auto;
  max-width: 1200px;
  width: 100%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  box-sizing: border-box;
}

[data-theme="dark"] .footer-links {
  background: linear-gradient(
    135deg,
    var(--bg-secondary) 0%,
    var(--bg-card) 100%
  );
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  color: var(--text-secondary, #555);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s ease;
  border-radius: 6px;
}

.footer-link:hover {
  color: var(--accent-orange, #ff8947);
  background: rgba(255, 137, 71, 0.08);
}

[data-theme="dark"] .footer-link {
  color: var(--text-secondary, #aaa);
}

[data-theme="dark"] .footer-link:hover {
  color: var(--accent-orange, #ff9a5c);
  background: rgba(255, 137, 71, 0.1);
}

.footer-link-icon {
  font-size: 14px;
}

.footer-separator {
  color: var(--text-muted, #ccc);
  font-size: 12px;
}

[data-theme="dark"] .footer-separator {
  color: var(--text-muted, #555);
}

.footer-copyright {
  text-align: center;
  padding: 15px 20px;
  font-size: 13px;
  color: var(--text-muted, #888);
}

.footer-copyright a {
  color: var(--accent-orange, #ff8947);
  text-decoration: none;
}

.footer-copyright a:hover {
  text-decoration: underline;
}

[data-theme="dark"] .footer-copyright {
  color: var(--text-muted, #666);
}

/* ========== Minimal Footer ========== */
.site-footer-minimal {
  padding: 15px 20px;
}

.footer-minimal-content {
  text-align: center;
  color: var(--text-muted, #888);
  font-size: 12px;
}

.footer-minimal-content p {
  margin: 0;
}

/* ========== Responsive: Mobile ========== */
@media (max-width: 768px) {
  .header-inner {
    padding: 8px 12px;
    gap: 10px;
  }

  .header-logo .site-logo {
    max-height: 40px;
  }

  .header-right > .theme-toggle {
    width: 36px;
    height: 36px;
    padding: 6px;
  }

  .user-dropdown {
    right: 0;
    min-width: 260px;
  }

  .footer-nav {
    flex-direction: column;
    gap: 4px;
  }

  .footer-separator {
    display: none;
  }

  .footer-link {
    padding: 10px 16px;
    width: 100%;
    justify-content: center;
  }

  .footer-links {
    padding: 15px 10px;
    margin: 15px 10px;
    width: auto;
  }
}

@media (max-width: 480px) {
  .header-inner {
    padding: 6px 10px;
  }

  .login-trigger-btn {
    padding: 8px 14px;
    font-size: 13px;
  }

  .user-avatar {
    width: 38px;
    height: 38px;
    font-size: 14px;
  }
}

/* ========== Responsive: Large Screens ========== */
@media (min-width: 1200px) {
  .header-inner {
    max-width: 1200px;
  }

  .header-logo .site-logo {
    max-height: 55px;
  }
}

/* ========== Print Styles ========== */
@media print {
  .site-header,
  .site-footer,
  .admin-header,
  .admin-nav,
  .admin-footer {
    display: none !important;
  }
}
