/* =========================================
   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;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url('/assets/img/brokenglass.jpg') no-repeat center center;
  background-size: cover;
  opacity: 0.08;
  z-index: 0;
  pointer-events: none;
}

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);
}

.muted {
  color: var(--text-secondary);
}

.small {
  font-size: 0.85rem;
}

.small.muted {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* =========================================
   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);
  }

  .stats-grid {
    grid-template-columns: repeat(4, 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%;
}

.hero-subtitle {
  font-size: 1.85rem;
}

/* Slanted Divider */
.slanted-divider {
  position: relative;
  background: var(--bg);
  padding: var(--space-8) 0 var(--space-12) 0;
  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;
}

/* Service Images */
.glass-card img {
  transition: transform 0.3s ease;
}

.glass-card:hover img {
  transform: scale(1.05);
}

/* 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.98);
}

html.light-mode .topbar a,
html.light-mode .topbar .name,
html.light-mode .topbar .muted,
html.light-mode .topbar button {
  color: #000000 !important;
}

html.light-mode .topbar .btn.primary {
  background: #000000 !important;
  color: #ffffff !important;
}

html.light-mode .topbar .btn,
html.light-mode .topbar .theme-toggle {
  border-color: #000000 !important;
}

.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;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.theme-toggle:hover {
  background: var(--surface);
  border-color: var(--brand);
}

/* Im Dark Mode: Sonne anzeigen (weil man zu Light wechseln kann) */
.icon-sun {
  display: none;
}

.icon-moon {
  display: block;
}

html.dark-mode .icon-sun {
  display: block;
}

html.dark-mode .icon-moon {
  display: none;
}

/* Im Light Mode: Mond anzeigen (weil man zu Dark wechseln kann) */
html.light-mode .icon-sun {
  display: none;
}

html.light-mode .icon-moon {
  display: block;
}

/* =========================================
   8. BUTTONS & UTILS
   ========================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 1.1rem;
  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: var(--text-dark);
}

.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;
  }
}

/* =========================================
   10. STATS / LEISTUNGSUEBERSICHT
   ========================================= */
.stats-section {
  background: #0a0a0a;
  padding: var(--space-12) 0;
  position: relative;
  z-index: 4;
}

html.light-mode .stats-section {
  background: #1a1a2e;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-5);
}

.stat-item {
  padding: var(--space-6) var(--space-5);
  border-left: 1px solid var(--border);
}

.stat-item:first-child {
  border-left: none;
}

.stat-number {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(2.8rem, 5vw, 4.5rem);
  font-weight: 400;
  font-style: italic;
  color: #c9a96e;
  line-height: 1;
  margin-bottom: var(--space-3);
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  line-height: 1.4;
}

.image-center {
  align-items: center;
  justify-content: center;
  display: flex;

}

.row-actions {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.row-actionformatcenter {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-3);
}

@media (max-width: 768px) {
  h1 {
    font-size: clamp(1.6rem, 7vw, 2.1rem);
  }

  h2 {
    font-size: clamp(1.3rem, 5vw, 1.5rem);
  }

  .hero-subtitle {
    font-size: clamp(1rem, 5vw, 1.3rem);
  }

  .container {
    padding: 0 var(--space-3);
  }

  .grid.cols-2,
  .grid.cols-3 {
    grid-template-columns: 1fr;
  }

  .glass-card,
  .card,
  .service-card,
  .user-card,
  .order-card {
    padding: var(--space-4);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-item {
    border-left: none;
    border-bottom: 1px solid var(--border);
    padding: var(--space-4) var(--space-3);
  }

  .stat-number {
    font-size: clamp(2rem, 6vw, 2.5rem);
    margin-bottom: var(--space-2);
  }

  .stat-label {
    font-size: 0.75rem;
  }

  .btn {
    padding: 10px 16px;
    font-size: 0.95rem;
    width: 100%;
  }

  .row-actionformatcenter,
  .row-actions {
    flex-direction: column;
    width: 100%;
  }

  .slide {
    width: 220px;
    height: 160px;
  }

  .slideshow-track {
    width: calc((220px * var(--slide-count, 1) + var(--space-4) * var(--slide-count, 1)) * 2);
    animation: scroll-mobile calc(var(--slide-count, 4) * 4s) linear infinite;
  }

  .hero-section {
    padding-top: calc(var(--header-height) + var(--space-4));
    padding-bottom: var(--space-6);
    min-height: auto;
    text-align: center;
  }

  .hero-content .image-center img {
    max-width: 70%;
  }
}

@keyframes scroll-mobile {
  0% {
    transform: translateX(0);
  }

  100% {
    transform: translateX(calc((220px * var(--slide-count, 1) + var(--space-4) * var(--slide-count, 1)) * -1));
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================================
   11. SLIDESHOW
   ========================================= */
.slideshow-container {
  overflow: hidden;
  position: relative;
  width: 100%;
  padding: var(--space-4) 0;
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
}

.slideshow-track {
  display: flex;
  gap: var(--space-4);
  /* The width accommodates 2 groups of --slide-count items.
     Each slide is 400px wide + gap */
  width: calc((400px * var(--slide-count, 1) + var(--space-4) * var(--slide-count, 1)) * 2);
  animation: scroll calc(var(--slide-count, 4) * 5s) linear infinite;
}

.slideshow-track:hover {
  animation-play-state: paused;
}

.slide {
  width: 400px;
  height: 300px;
  object-fit: cover;
  border-radius: var(--radius-md);
  flex-shrink: 0;
  transition: transform 0.3s ease;
  cursor: pointer;
}

.slide:hover {
  transform: scale(1.03);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

@keyframes scroll {
  0% {
    transform: translateX(0);
  }

  100% {
    transform: translateX(calc((400px * var(--slide-count, 1) + var(--space-4) * var(--slide-count, 1)) * -1));
  }
}

/* Lightbox styles */
.lightbox {
  display: none;
  position: fixed;
  z-index: 9999;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.lightbox-content {
  max-width: 90%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
}

.lightbox-caption {
  color: #fff;
  margin-top: var(--space-4);
  font-size: 1.2rem;
  text-align: center;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 40px;
  color: #fff;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.3s ease;
}

.lightbox-close:hover {
  color: var(--primary);
}