/* =========================================
   1. VARIABLES & THEME CONFIGURATION
   ========================================= */
:root {
  /* DARK MODE (Default) */
  --bg-dark: #050505;
  --bg-dark-elevated: #0f0f0f;
  --bg-dark-card: rgba(20, 20, 20, 0.65);
  --surface-dark: rgba(255, 255, 255, 0.05);
  --text-dark: #ffffff;
  --text-dark-secondary: rgba(255, 255, 255, 0.7);
  --border-dark: rgba(255, 255, 255, 0.1);

  /* LIGHT MODE */
  --bg-light: #f8f9fa;
  --bg-light-elevated: #ffffff;
  --bg-light-card: rgba(255, 255, 255, 0.75);
  --surface-light: rgba(0, 0, 0, 0.03);
  --text-light: #0f172a;
  --text-light-secondary: rgba(15, 23, 42, 0.65);
  --border-light: rgba(0, 0, 0, 0.1);

  /* BRAND COLORS */
  --brand: #06b6d4;
  --brand-hover: #0891b2;
  --brand-text: #ffffff;
  --brand-glow: rgba(6, 182, 212, 0.2);
  
  /* UTILS */
  --success: #10b981;
  --danger: #ef4444;
  --radius-md: 6px;
  --radius-lg: 12px;
  --radius-xl: 20px;
  
  --header-height: 80px;
  --max-width: 1400px;

  /* SPACING */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-8: 48px; --space-10: 64px;
  --space-12: 80px; --space-16: 128px; --space-20: 160px;

  /* INITIAL VARIABLES (Dark Default) */
  --bg: var(--bg-dark);
  --bg-elevated: var(--bg-dark-elevated);
  --bg-card: var(--bg-dark-card);
  --surface: var(--surface-dark);
  --text: var(--text-dark);
  --text-secondary: var(--text-dark-secondary);
  --border: var(--border-dark);
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

/* LIGHT MODE OVERRIDES */
html.light-mode {
  --bg: var(--bg-light);
  --bg-elevated: var(--bg-light-elevated);
  --bg-card: var(--bg-light-card);
  --surface: var(--surface-light);
  --text: var(--text-light);
  --text-secondary: var(--text-light-secondary);
  --border: var(--border-light);
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
}

/* =========================================
   2. BASE RESET & TYPOGRAPHY
   ========================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; transition: 0.2s; }
img { max-width: 100%; height: auto; display: block; }

h1, h2, h3, h4 { font-weight: 800; line-height: 1.2; color: var(--text); }
h1 { font-size: clamp(2.5rem, 5vw, 4rem); text-transform: uppercase; letter-spacing: -0.03em; }
h2 { font-size: clamp(1.8rem, 4vw, 2.5rem); margin-bottom: var(--space-4); }
h3 { font-size: 1.25rem; font-weight: 700; margin-bottom: var(--space-2); }

p { color: var(--text-secondary); margin-bottom: var(--space-4); }

/* =========================================
   3. LAYOUT & GRID
   ========================================= */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-5);
  position: relative;
  z-index: 2;
}

.grid { display: grid; gap: var(--space-5); }
.grid.cols-1 { grid-template-columns: 1fr; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

@media(min-width: 1024px) {
    .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
}

/* =========================================
   4. HERO & PARALLAX
   ========================================= */
.hero-section {
  position: relative;
  min-height: 60vh;
  display: flex;
  align-items: center;
  padding-top: var(--header-height);
  padding-bottom: var(--space-10);
  overflow: hidden;
}

.parallax-bg {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 120%;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  z-index: 0;
  filter: brightness(0.4) contrast(1.1);
}

html.light-mode .parallax-bg {
  filter: brightness(1.1) contrast(0.9) opacity(0.3);
}

.hero-content {
  position: relative;
  z-index: 2;
  width: 100%;
}

/* Slanted Divider */
.slanted-divider {
  position: relative;
  background: var(--bg);
  padding: var(--space-12) 0;
  margin-top: -5vw;
  clip-path: polygon(0 5vw, 100% 0, 100% 100%, 0 100%);
  z-index: 3;
}

/* =========================================
   5. GLASS CARDS & UI COMPONENTS
   ========================================= */
/* WICHTIG: Overflow visible lassen, damit Dropdowns nicht abgeschnitten werden! */
.glass-card, .service-card, .card, .user-card, .order-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  box-shadow: var(--shadow);
  overflow: visible !important; 
}

.glass-card:hover, .service-card:hover, .card:hover, .user-card:hover, .order-card:hover {
  transform: translateY(-5px);
  border-color: var(--brand);
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.card .pad { padding: 0; } /* Reset padding inner container if used */

/* Service Card Spezifisch */
.service-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.service-card-title { font-size: 1.25rem; color: var(--text); }
.service-card-description { flex-grow: 1; color: var(--text-secondary); font-size: 0.95rem; }
.service-card-footer {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

/* User Card Spezifisch (Admin Panel) */
.user-card-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-4);
}
.user-card-id {
  font-family: monospace; background: var(--surface);
  padding: 4px 8px; border-radius: var(--radius-md); font-size: 0.85rem;
  color: var(--text-secondary);
}
.user-card-info h3 { font-size: 1.1rem; margin-bottom: 0.25rem; }
.user-card-info .email { color: var(--text-secondary); font-size: 0.9rem; }
.user-card-info .phone { color: var(--text-secondary); font-size: 0.9rem; margin-top: 0.25rem; }

.user-card-actions {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-5);
}
.user-card-field { margin-bottom: 0; }
.user-card-password { grid-column: 1 / -1; margin-top: var(--space-2); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.user-card-note { font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.5rem; font-style: italic; }

/* Order Card Spezifisch */
.order-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: var(--space-4); }
.order-card-title { font-size: 1.25rem; font-weight: 700; }
.order-card-id { font-size: 0.9rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }

/* =========================================
   6. FORMS & CUSTOM SELECTS
   ========================================= */
.field { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); }
.field label, .user-card-field label {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase; color: var(--text-secondary); letter-spacing: 0.05em;
}

/* Inputs */
.input, .textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 12px;
  color: var(--text);
  border-radius: var(--radius-md);
  font-family: inherit; font-size: 1rem;
  transition: 0.2s;
}
.input:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-glow); }

/* CUSTOM SELECT (Dropdowns) - Fix für Admin Panel */
.custom-select-wrapper {
  position: relative;
  width: 100%;
  font-family: inherit;
  z-index: 50; /* Ensure it's above other inline elements */
}

.custom-select.input {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  min-height: 48px;
}

.custom-select-dropdown {
  position: absolute;
  top: calc(100% + 5px);
  left: 0; right: 0;
  background: var(--bg-elevated) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  z-index: 9999;
  max-height: 250px;
  overflow-y: auto;
  padding: 5px;
  opacity: 0; visibility: hidden; transform: translateY(-10px);
  transition: all 0.2s ease;
}

/* Open State */
.custom-select-wrapper.open .custom-select-dropdown,
.custom-select-dropdown[style*="display: block"] {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0) !important;
  display: block !important;
}

.topbar .container { height: 100%; }
.topbar .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.custom-select-option {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.1s;
}
.custom-select-option:hover { background: var(--surface); }
.custom-select-option.selected { background: var(--brand); color: var(--brand-text); }

/* =========================================
   7. NAVIGATION & HEADER
   ========================================= */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-height);
  z-index: 1000;
  background: rgba(5, 5, 5, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
html.light-mode .topbar { background: rgba(255, 255, 255, 0.9); }

.topbar .row { display: flex; align-items: center; justify-content: space-between; height: 100%; }

.brand { display: flex; align-items: center; gap: var(--space-3); font-weight: 700; text-transform: uppercase; }
.brand img { height: 40px; border-radius: 4px; }

.nav { display: flex; align-items: center; gap: var(--space-2); }
.nav a {
  font-size: 0.9rem; font-weight: 600; text-transform: uppercase;
  padding: 8px 12px; border-radius: var(--radius-md); color: var(--text-secondary);
}
.nav a:hover, .nav a.active { color: var(--text); background: var(--surface); }

.menu-toggle { display: none; background: none; border: none; color: var(--text); cursor: pointer; }

/* Theme Toggle Button */
.theme-toggle {
  background: transparent; border: 1px solid var(--border);
  color: var(--text); width: 40px; height: 40px;
  border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.icon-sun { display: none; }
.icon-moon { display: block; }
html.dark-mode .icon-sun { display: block; }
html.dark-mode .icon-moon { display: none; }

/* =========================================
   8. BUTTONS & UTILS
   ========================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-md);
  font-weight: 600; font-size: 0.9rem; text-transform: uppercase;
  cursor: pointer; transition: all 0.2s;
  border: 1px solid var(--border); background: transparent; color: var(--text);
  line-height: 1; text-decoration: none;
}
.btn:hover { background: var(--surface); transform: translateY(-2px); }

.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }

.badge {
  display: inline-block; padding: 4px 8px; border-radius: 4px;
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  background: var(--surface); border: 1px solid var(--border);
}
.badge.brand { border-color: var(--brand); color: var(--brand); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); margin-top: var(--space-4); }
.table { width: 100%; border-collapse: collapse; min-width: 600px; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { background: var(--surface); font-size: 0.8rem; text-transform: uppercase; color: var(--text-secondary); }

/* Category Headers (Leistungen) */
.category-header { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-5); padding-bottom: var(--space-3); border-bottom: 2px solid var(--border); }
.category-icon { width: 44px; height: 44px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.category-title { font-size: 1.5rem; margin-bottom: 2px; }
.category-count { color: var(--text-secondary); font-size: 0.9rem; }

/* Footer */
.footer {
  padding: var(--space-12) 0; margin-top: var(--space-12);
  border-top: 1px solid var(--border); background: var(--bg-elevated);
  text-align: center; color: var(--text-secondary);
}

/* =========================================
   9. RESPONSIVE
   ========================================= */
@media (max-width: 768px) {
  .nav { display: none; }
  .menu-toggle { display: block; }
  
  .nav.active {
    display: flex; flex-direction: column; position: absolute;
    top: var(--header-height); left: 0; right: 0;
    background: var(--bg-card); padding: var(--space-5);
    border-bottom: 1px solid var(--border);
  }
  
  .hero-section h1 { font-size: 2.2rem; }
  .slanted-divider { margin-top: 0; clip-path: none; border-top: 1px solid var(--border); }
  
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  
  .user-card-actions { grid-template-columns: 1fr; }
  .user-card-header { flex-direction: column; gap: var(--space-2); }
  
  .table th, .table td { padding: 8px 10px; font-size: 0.9rem; }
}