/*
 * MODERN DARK-MODE THEME FOR MENSA
 * Overrides w3.css defaults and introduces a sleek, premium design.
 */

:root {
  --bg-main: #0B0E14;
  /* Deep, sleek dark background */
  --bg-sidebar: #131722;
  /* Slightly softer dark for sidebar */
  --bg-card: #1C212D;
  /* Card background */
  --bg-card-hover: #262D3D;

  --text-primary: #E2E8F0;
  --text-muted: #94A3B8;
  --accent-color: #3B82F6;
  /* Vibrant blue */
  --accent-glow: rgba(59, 130, 246, 0.5);

  --gradient-glow: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
  --sidebar-gradient: linear-gradient(180deg, #131722 0%, #0B0E14 100%);

  --surface-border: rgba(255, 255, 255, 0.08);
  --success-color: #10B981;
  --danger-color: #EF4444;

  --font-family: 'Inter', sans-serif;
}

body.modern-dark {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-family);
  margin: 0;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1,
h3,
h4,
h5,
h6 {
  font-family: var(--font-family);
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.02em;
}

h2 {
  font-family: var(--font-family);
  font-weight: 700;
  color: #93c5fd; /* Brighter Radiant Blue */
  text-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
  letter-spacing: -0.01em;
  margin-top: 0;
}

/* -------------------------------------
 *  SIDEBAR OVERRIDES
 * ------------------------------------- */

/* Layout - narrow sidebar 80px */
.modern-sidebar {
  width: 100px !important;
  min-width: 100px !important;
  position: fixed !important;
  left: 0;
  top: 0;
  height: 100vh;
  background: var(--sidebar-gradient) !important;
  border-right: 1px solid var(--surface-border);
  display: flex !important;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  z-index: 10;
}

.modern-sidebar .sidebar-avatar {
  padding: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-bottom: 1px solid var(--surface-border);
  margin-bottom: 10px;
}

.modern-sidebar .sidebar-avatar img {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-color);
  box-shadow: 0 0 10px var(--accent-glow);
}

.modern-sidebar a.w3-bar-item {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-muted) !important;
  background: transparent !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 15px 5px !important;
  border-left: 3px solid transparent;
}

.modern-sidebar a.w3-bar-item:hover,
.modern-sidebar a.w3-bar-item:focus {
  background: rgba(255, 255, 255, 0.03) !important;
  color: var(--accent-color) !important;
  border-left: 3px solid var(--accent-color);
}

.modern-sidebar a.w3-bar-item i {
  font-size: 24px !important;
  margin-bottom: 6px;
  transition: transform 0.3s ease;
}

.modern-sidebar a.w3-bar-item:hover i {
  transform: translateY(-2px) scale(1.1);
  color: var(--accent-color);
  text-shadow: 0 0 10px var(--accent-glow);
}

.modern-sidebar a.w3-bar-item p {
  margin: 0;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: center;
}

#main {
  margin-left: 80px !important;
  min-height: 100vh;
  padding: 0 !important;
}

/* Container to prevent full-width stretching */
.page-container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 20px;
  width: auto;
}

/* Tab Management */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: tabFadeIn 0.4s ease;
}

@keyframes tabFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modern-sidebar a.w3-bar-item.active {
  color: var(--accent-color) !important;
  border-left: 3px solid var(--accent-color);
  background: rgba(255, 255, 255, 0.03) !important;
}

@media only screen and (max-width: 600px) {
  html, body {
    height: 100% !important;
    overflow: hidden !important;
    position: fixed;
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
    background-color: var(--bg-main) !important;
  }

  /* Aggressive Full-Width Reset for ALL w3-css and parent containers */
  #main,
  #main2,
  .w3-content,
  .w3-container,
  .tab-content,
  .page-container,
  .modern-card,
  .w3-padding-64 {
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100vw !important;
    width: 100vw !important;
    min-width: 100vw !important;
    left: 0 !important;
    right: 0 !important;
    box-shadow: none !important;
    background-image: none !important; 
  }

  #main {
    margin-left: 0 !important;
    height: 100% !important;
    min-height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* Hide Navigation and Footer on Mobile as requested */
  #myNavbar, 
  .modern-sidebar, 
  footer.w3-content, 
  #impressum,
  .desktop-only {
    display: none !important;
  }

  .hero-header {
    width: 100vw !important;
    margin: 0 !important;
    /* Extra Clearance for Pixel 8 Address Bar */
    padding-top: calc(env(safe-area-inset-top) + 85px) !important;
    padding-bottom: 20px !important;
    padding-left: 20px !important;
    padding-right: 20px !important;
    flex: 0 0 220px !important; /* Stable basis for snapping */
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-sizing: border-box !important;
    background-position: center !important;
    z-index: 5;
  }

  .hero-header h1 {
    font-size: 1.5rem !important;
    margin: 0 !important;
    white-space: nowrap;
    color: #fff !important;
  }

  .hero-header h2 {
    font-size: 0.85rem !important;
    opacity: 0.9;
    color: #93c5fd !important;
    margin-top: 5px !important;
  }

  #home.tab-content {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    width: 100vw !important;
    overflow: hidden !important;
  }

  .page-container {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    overflow: hidden !important;
  }

  .meal-card-container {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    flex: 1 !important;
    display: flex !important;
    height: 100% !important;
    border-radius: 0 !important;
  }

  .meal-plan-scroll-wrapper {
    flex: 1 !important;
    display: block !important;
    overflow-y: scroll !important; /* Forced scroll for Android Snapping */
    scroll-snap-type: y mandatory !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain !important;
    scrollbar-width: none;
    width: 100% !important;
    height: 100% !important;
    scroll-padding-top: 0 !important;
  }

  .meal-plan-scroll-wrapper::-webkit-scrollbar {
    display: none;
  }

  .meal-plan-table {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
  }

  .meal-plan-table thead {
    display: none !important;
  }

  .meal-plan-table tbody {
    display: block !important;
    width: 100% !important;
  }

  .meal-day-row {
    width: 100vw !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    background: var(--bg-card) !important;
    border: none !important;
    border-bottom: 1px solid var(--surface-border) !important;
    border-radius: 0 !important;
    scroll-snap-align: start !important;
    scroll-snap-stop: always !important;
    padding: 0 !important; 
    box-shadow: none !important;
    /* Fill 100% of the parent scroll area's height */
    height: 100% !important;
    min-height: 100% !important;
    overflow-y: auto !important;
    box-sizing: border-box !important;
  }

  .meal-day-row.is-today {
    background: var(--bg-card) !important;
  }

  .meal-day-row td {
    display: block !important;
    width: 100% !important;
    border: none !important;
    padding: 15px 25px !important;
    text-align: left !important;
    margin-bottom: 2px !important;
    box-sizing: border-box !important;
  }

  /* Sticky Day Header within the card */
  .meal-day-row td.day-name {
    font-size: 24px !important;
    font-weight: 800 !important;
    border-bottom: 2px solid var(--surface-border) !important;
    margin-bottom: 0 !important;
    color: var(--accent-color) !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    position: sticky !important;
    top: 0 !important;
    background: var(--bg-main) !important;
    z-index: 20;
    padding: 20px 25px !important;
  }

  .meal-day-row td.day-name [data-label] {
    display: none !important;
  }

  /* Premium Color-Coding for Meal Types */
  .meal-day-row td[data-label="VOLLKOST"] {
    background: rgba(59, 130, 246, 0.12) !important;
    border-left: 4px solid #3b82f6 !important;
  }

  .meal-day-row td[data-label="LEICHTE VOLLKOST"] {
    background: rgba(16, 185, 129, 0.12) !important;
    border-left: 4px solid #10b981 !important;
  }

  .meal-day-row td[data-label="VEGETARISCH"] {
    background: rgba(245, 158, 11, 0.12) !important;
    border-left: 4px solid #f59e0b !important;
  }

  /* Label Styling */
  .meal-day-row td[data-label]:not(.day-name)::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    opacity: 0.8;
    letter-spacing: 1.5px;
    margin-bottom: 6px;
  }

}


/* -------------------------------------
 *  MAIN CONTENT (Cards, Tables, etc.)
 * ------------------------------------- */

/* Hero Banner */
.hero-header {
  background-image: url('images/mensa.jpg') !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-blend-mode: overlay;
  background-color: rgba(11, 14, 20, 0.7) !important;
  padding: 10px 10px !important;
  position: relative;
  overflow: hidden;
}

.hero-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100px;
  background: linear-gradient(to top, var(--bg-main), transparent);
  pointer-events: none;
}

.hero-header h1 {
  font-size: 2.8rem !important;
  font-weight: 800;
  background: linear-gradient(to right, #fff, var(--text-muted));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  margin: 0 0 5px 0;
}

.hero-header h2 {
  opacity: 1;
  font-size: 1.4rem !important;
  color: #fff; /* High Contrast White for images */
  text-shadow: 0 0 15px var(--accent-color);
  margin: 0;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Modern Card */
.modern-card {
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--surface-border);
  padding: 20px;
  margin-bottom: 30px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.modern-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

/* Tabellen / Speiseplan */
.modern-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 12px;
  overflow: hidden;
}

.modern-table th,
.modern-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--surface-border);
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
  hyphens: auto;
}

.modern-table th {
  background: rgba(0, 0, 0, 0.3) !important;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 11px;
}

.modern-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.modern-table tr:last-child td {
  border-bottom: none;
}

.modern-table td b {
  color: #fff;
  font-weight: 600;
}

/* Colored Columns for readability */
.col-vk {
  background: rgba(59, 130, 246, 0.05) !important;
}

.col-lvk {
  background: rgba(16, 185, 129, 0.05) !important;
}

.col-veg {
  background: rgba(245, 158, 11, 0.05) !important;
}

.modern-table tr:hover .col-vk {
  background: rgba(59, 130, 246, 0.1) !important;
}

.modern-table tr:hover .col-lvk {
  background: rgba(16, 185, 129, 0.1) !important;
}

.modern-table tr:hover .col-veg {
  background: rgba(245, 158, 11, 0.1) !important;
}

/* Meal Highlights */
.meal-title {
  font-weight: 500;
  color: #fff;
  display: inline;
}

/* Today Badge */
.today-badge {
  background: var(--accent-color);
  color: white !important;
  font-size: 11px;
  padding: 3px 12px;
  border-radius: 20px;
  text-transform: uppercase;
  font-weight: 700;
  box-shadow: 0 0 15px var(--accent-glow);
  display: inline-block;
  margin-bottom: 5px;
  line-height: 1;
  letter-spacing: 0.5px;
}

.meal-additives {
  color: var(--text-muted);
  font-size: 13px;
  opacity: 0.8;
  display: inline;
}

/* Inputs & Formulare */
input[type="text"],
input[type="password"],
textarea,
select {
  background: rgba(0, 0, 0, 0.2) !important;
  border: 1px solid var(--surface-border) !important;
  color: #fff !important;
  border-radius: 8px !important;
  padding: 15px 20px !important;
  transition: all 0.3s ease;
  font-family: var(--font-family);
  width: 100%;
  box-sizing: border-box;
  max-width: 100%;
}

input:focus,
textarea:focus,
select:focus {
  outline: none !important;
  border-color: var(--accent-color) !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2) !important;
  background: rgba(0, 0, 0, 0.4) !important;
}

select option {
  background: var(--bg-card);
  color: white;
}

/* Radio Buttons für Abstimmung */
.modern-radio-container {
  display: flex;
  justify-content: center;
  align-items: center;
}

input[type='radio'] {
  appearance: none;
  width: 24px;
  height: 24px;
  border: 2px solid var(--text-muted);
  border-radius: 50%;
  outline: none;
  transition: all 0.3s ease;
  cursor: pointer;
  background: transparent;
  position: relative;
  transform: none;
  /* override alter transform */
}

input[type='radio']:checked {
  border-color: var(--accent-color);
  background: rgba(59, 130, 246, 0.1);
}

input[type='radio']:checked::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-color);
  box-shadow: 0 0 10px var(--accent-glow);
}

input[type='radio']:disabled {
  border-color: #333;
  cursor: not-allowed;
}

/* Modern Checkbox & Radio Alignment Fix */
.modern-checkbox, .modern-radio {
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--text-muted);
  outline: none;
  transition: all 0.2s ease;
  cursor: pointer;
  background: transparent;
  position: relative;
  flex-shrink: 0;
  margin: 0 !important;
  display: inline-block;
  vertical-align: middle;
}

.modern-checkbox { border-radius: 4px; }
.modern-radio { border-radius: 50%; }

.modern-checkbox:checked, .modern-radio:checked {
  border-color: var(--accent-color);
  background: rgba(59, 130, 246, 0.1);
}

.modern-radio:checked::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-color);
  box-shadow: 0 0 8px var(--accent-glow);
}

.modern-checkbox:checked::after {
  content: '\f00c';
  font-family: 'FontAwesome';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  color: var(--accent-color);
}

/* Modern Buttons */
.modern-btn {
  background: var(--accent-color);
  color: white !important;
  border: none;
  border-radius: 8px;
  padding: 14px 28px;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
}

.modern-btn:hover {
  background: #2563EB;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.modern-btn.secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--surface-border);
  box-shadow: none;
}

.modern-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.modern-btn.jumbo {
  padding: 20px 40px;
  font-size: 20px;
  border-radius: 12px;
}

/* Footer & Impressum Styling */
footer.w3-content {
  max-width: 1200px;
  margin: 0 auto;
  border-top: 1px solid var(--surface-border);
  padding: 40px 20px !important;
  text-align: center;
}

#impressum {
  padding: 40px 0 !important;
  max-width: 100% !important;
  text-align: left;
}

#impressum h2 {
  font-size: 1.5rem;
  margin-bottom: 5px;
  color: var(--text-muted);
}

#impressum p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 5px 0;
}

#impressum .fa {
  width: 25px;
  font-size: 16px !important;
  color: var(--accent-color) !important;
}

#impressum a {
  color: var(--accent-color);
  text-decoration: none;
}

#impressum a:hover {
  text-decoration: underline;
}

.w3-red {
  border-left-color: var(--danger-color) !important;
  background: rgba(239, 68, 68, 0.1) !important;
  color: white !important;
}

.w3-green {
  border-left-color: var(--success-color) !important;
  background: rgba(16, 185, 129, 0.1) !important;
  color: white !important;
}

/* Typography Overrides for remaining w3 classes */
.w3-text-grey,
.w3-text-light-grey {
  color: var(--text-muted) !important;
}

.w3-xlarge {
  font-size: 20px !important;
}

.w3-xxlarge {
  font-size: 28px !important;
}

.w3-jumbo {
  font-size: 42px !important;
}

hr.w3-opacity {
  border-top: 1px solid var(--surface-border) !important;
  opacity: 1 !important;
}

.w3-opacity {
  opacity: 0.7 !important;
}

/* Contact Section Tweaks */
.w3-check {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-color);
}

/* -------------------------------------
 *  SURVEY FLASHING ANIMATION
 * ------------------------------------- */
@keyframes survey-pulse {
  0% { background-color: var(--danger-color); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { background-color: #dc2626; box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { background-color: var(--danger-color); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.survey-btn-flashing {
  animation: survey-pulse 2s infinite !important;
  color: white !important;
  border-left: 3px solid #fff !important;
}

.custom-survey-red, .custom-survey-red i, .custom-survey-red p {
  color: #ff4d4d !important;
  text-shadow: 0 0 10px rgba(239, 68, 68, 0.4) !important;
}

.survey-btn-flashing i, .survey-btn-flashing p {
  color: white !important;
  text-shadow: 0 0 5px rgba(0,0,0,0.5);
}

.survey-nav-item {
  color: #ff8080 !important; /* Soft red for readability */
}

.survey-nav-item i {
  color: #ef4444 !important; /* Vivid red for icons */
}

.survey-nav-item:hover {
  color: #ff4d4d !important;
  border-left: 3px solid #ef4444 !important;
}