// ============================================
// SERVICES PAGE - MOBILE-FIRST OPTIMIZED
// ============================================

// ===== VARIABLES =====
$bg: #EDF2FD;
$white: #ffffff;
$text: #1a1a2e;
$text-light: #5a5a72;
$text-muted: #8a8aa3;
$brand: #2563eb;
$brand-light: #3b82f6;
$border: rgba(0, 0, 0, 0.06);
$radius: 16px;
$radius-sm: 10px;

// Category colors
$c-hardware: #f59e0b;
$c-software: #8b5cf6;
$c-web: #3b82f6;
$c-netzwerk: #06b6d4;
$c-support: #10b981;

// ===== BASE =====
:host {
  display: block;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

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

.services-page {
  min-height: 100vh;
  background: $bg;
  padding: 1rem 0 2rem;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow-x: hidden;
  width: 100%;
}

// ===== CONTAINER - OVERRIDE GLOBAL STYLES =====
.container {
  width: 100% !important;
  max-width: 100% !important;
  padding: 0 1rem !important;
  margin: 0 auto !important;
  box-sizing: border-box !important;

  @media (min-width: 640px) {
    padding: 0 1.5rem !important;
  }

  @media (min-width: 900px) {
    max-width: 1100px !important;
    padding: 0 2rem !important;
  }
}

// ===== HEADER - MOBILE OPTIMIZED =====
.header {
  text-align: center;
  margin-bottom: 1.25rem;
  padding: 0 0.25rem;

  h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: $text;
    margin-bottom: 0.375rem;
    letter-spacing: -0.02em;
    line-height: 1.2;
  }

  > p {
    color: $text-light;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    line-height: 1.4;
  }
}

// ===== STATE MESSAGES (Loading, Error, Empty) =====
.state-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
  background: $white;
  border-radius: $radius;
  margin: 2rem 0;
  
  .loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba($brand, 0.2);
    border-top-color: $brand;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
  }
  
  .material-symbols-outlined {
    font-size: 3rem;
    color: $brand;
    margin-bottom: 1rem;
  }
  
  h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: $text;
    margin-bottom: 0.5rem;
  }
  
  p {
    color: $text-light;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    max-width: 400px;
  }
  
  .sub {
    font-size: 0.9rem;
    color: $text-muted;
    margin-bottom: 1.5rem;
  }
  
  .btn {
    margin-top: 1rem;
  }
  
  &--error {
    .material-symbols-outlined {
      color: #dc2626;
    }
  }
  
  &--construction {
    .material-symbols-outlined {
      color: $c-hardware;
    }
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

// ===== SEARCH - MOBILE OPTIMIZED =====
.search-box {
  position: relative;
  max-width: 100%;
  margin: 0 auto;

  > .material-symbols-outlined {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    color: $text-muted;
  }

  input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 2.75rem;
    font-size: 0.9375rem;
    border: 2px solid $border;
    border-radius: 50px;
    background: $white;
    color: $text;
    transition: all 0.2s;

    &::placeholder {
      color: $text-muted;
      font-size: 0.875rem;
    }

    &:focus {
      outline: none;
      border-color: $brand;
      box-shadow: 0 0 0 3px rgba($brand, 0.1);
    }
  }

  .clear-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;

    .material-symbols-outlined {
      font-size: 16px;
      color: $text-muted;
    }

    &:hover,
    &:active {
      background: rgba(0, 0, 0, 0.1);
    }
  }
}

.search-info {
  text-align: center;
  margin-top: 0.625rem;
  font-size: 0.8125rem;
  color: $text-muted;
}

// ===== FILTER TABS - MOBILE OPTIMIZED =====
.filter-tabs {
  display: flex;
  gap: 0.375rem;
  overflow-x: auto;
  padding: 0.5rem 0 1.25rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-snap-type: x mandatory;

  &::-webkit-scrollbar {
    display: none;
  }
}

.tab {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
  background: $white;
  border: 2px solid $border;
  border-radius: 50px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: $text-light;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
  scroll-snap-align: start;

  .material-symbols-outlined {
    font-size: 16px;
  }

  &:hover,
  &:active {
    border-color: $brand;
    color: $brand;
  }

  &.active {
    background: $brand;
    border-color: $brand;
    color: white;
  }
}

// ===== SERVICES =====
.services {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

// ===== CATEGORY - MOBILE OPTIMIZED =====
.category {
  background: $white;
  border-radius: $radius;
  padding: 1rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.category-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.875rem;
  border-bottom: 2px solid rgba(0, 0, 0, 0.04);

  h2 {
    font-size: 1rem;
    font-weight: 700;
    color: $text;
    margin-bottom: 0.125rem;
    line-height: 1.2;
  }

  p {
    font-size: 0.75rem;
    color: $text-muted;
    line-height: 1.3;
  }
}

.category-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;

  .material-symbols-outlined {
    font-size: 22px;
    color: white;
  }

  &[data-type="hardware"] {
    background: linear-gradient(135deg, $c-hardware, darken($c-hardware, 8%));
  }

  &[data-type="software"] {
    background: linear-gradient(135deg, $c-software, darken($c-software, 8%));
  }

  &[data-type="web"] {
    background: linear-gradient(135deg, $c-web, darken($c-web, 8%));
  }

  &[data-type="netzwerk"] {
    background: linear-gradient(135deg, $c-netzwerk, darken($c-netzwerk, 8%));
  }

  &[data-type="support"] {
    background: linear-gradient(135deg, $c-support, darken($c-support, 8%));
  }
}

// ===== SERVICE GRID - MOBILE OPTIMIZED =====
.service-grid {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

// ===== SERVICE CARD - MOBILE OPTIMIZED =====
.service-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem;
  background: $bg;
  border: 2px solid rgba($brand, 0.08);
  border-radius: $radius-sm;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
  position: relative;

  // Subtle pulsing hint on first load (nur einmal)
  &:first-child {
    animation: subtleHint 2s ease-in-out 1s 1;
  }

  &:hover,
  &:active {
    background: $white;
    border-color: rgba($brand, 0.25);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);

    .card-arrow {
      opacity: 1;
      transform: translateX(3px);
    }

    .card-hint {
      opacity: 1;
    }
  }
}

@keyframes subtleHint {
  0%, 100% { border-color: rgba($brand, 0.08); }
  50% { border-color: rgba($brand, 0.3); }
}

.card-hint {
  position: absolute;
  bottom: 0.5rem;
  right: 0.75rem;
  font-size: 0.625rem;
  color: $brand;
  opacity: 0.5;
  transition: opacity 0.2s;
  font-weight: 600;
}

.service-icon {
  font-size: 1.375rem;
  line-height: 1;
  flex-shrink: 0;
}

.service-content {
  flex: 1;
  min-width: 0;

  h3 {
    font-size: 0.875rem;
    font-weight: 700;
    color: $text;
    margin-bottom: 0.1875rem;
    line-height: 1.3;
  }

  p {
    font-size: 0.75rem;
    color: $text-light;
    line-height: 1.45;
    margin-bottom: 0.375rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

.card-arrow {
  font-size: 18px;
  color: $brand;
  opacity: 0.7;
  transform: translateX(0);
  transition: all 0.2s;
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;

  span {
    padding: 0.1875rem 0.4375rem;
    background: rgba($brand, 0.08);
    border-radius: 5px;
    font-size: 0.625rem;
    font-weight: 600;
    color: $brand;
  }
}

// ===== NO RESULTS =====
.no-results {
  text-align: center;
  padding: 2rem 1.25rem;
  background: $white;
  border: 2px dashed $border;
  border-radius: $radius;

  .material-symbols-outlined {
    font-size: 40px;
    color: $text-muted;
    margin-bottom: 0.75rem;
  }

  h3 {
    font-size: 1rem;
    font-weight: 700;
    color: $text;
    margin-bottom: 0.375rem;
  }

  p {
    font-size: 0.875rem;
    color: $text-light;
    margin-bottom: 1rem;
    max-width: 280px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.4;
  }
}

// ===== CTA BOX - MOBILE OPTIMIZED =====
.cta-box {
  margin-top: 2rem;
  padding: 1.25rem 1rem;
  background: linear-gradient(135deg, rgba($brand, 0.05), rgba($brand, 0.02));
  border: 2px solid rgba($brand, 0.1);
  border-radius: $radius;
  text-align: center;

  h3 {
    font-size: 1rem;
    font-weight: 700;
    color: $text;
    margin-bottom: 0.25rem;
  }

  > p {
    font-size: 0.875rem;
    color: $text-light;
    margin-bottom: 1rem;
  }
}

.cta-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

// ===== BUTTONS - MOBILE OPTIMIZED =====
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;

  .material-symbols-outlined {
    font-size: 18px;
  }

  &.primary {
    background: linear-gradient(135deg, $brand, $brand-light);
    color: white;
    box-shadow: 0 4px 16px rgba($brand, 0.25);

    &:hover,
    &:active {
      box-shadow: 0 6px 20px rgba($brand, 0.35);
    }
  }

  &.secondary {
    background: $white;
    color: $brand;
    border: 2px solid $brand;

    &:hover,
    &:active {
      background: rgba($brand, 0.05);
    }
  }

  &.large {
    padding: 0.875rem 1.5rem;
    font-size: 0.9375rem;
  }
}

// ===== MATERIAL ICONS =====
.material-symbols-outlined {
  font-variation-settings: "FILL" 0, "wght" 500, "GRAD" 0, "opsz" 24;
  line-height: 1;
}


// ============================================
// MODAL - ZENTRIERT AUF ALLEN GERÄTEN
// ============================================
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: $white;
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem); // Dynamic viewport height für mobile
  overflow-y: auto;
  border-radius: 20px;
  position: relative;
  animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

  // Smooth scrolling
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

@keyframes scaleIn {
  from { 
    opacity: 0;
    transform: scale(0.95); 
  }
  to { 
    opacity: 1;
    transform: scale(1); 
  }
}

.modal-close {
  position: absolute;
  top: 0.875rem;
  right: 0.875rem;
  background: rgba(0, 0, 0, 0.06);
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 1;
  -webkit-tap-highlight-color: transparent;

  .material-symbols-outlined {
    font-size: 18px;
    color: $text-light;
  }

  &:hover,
  &:active {
    background: rgba(0, 0, 0, 0.12);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 1.25rem 1.25rem 0;
  padding-right: 3rem; // Platz für Close Button

  h2 {
    font-size: 1.125rem;
    font-weight: 700;
    color: $text;
    margin: 0;
    line-height: 1.3;
  }
}

.modal-category {
  font-size: 0.6875rem;
  font-weight: 600;
  color: $text-muted;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.modal-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;

  .service-emoji {
    font-size: 1.5rem;
  }

  &[data-type="hardware"] {
    background: linear-gradient(135deg, rgba($c-hardware, 0.15), rgba($c-hardware, 0.05));
  }

  &[data-type="software"] {
    background: linear-gradient(135deg, rgba($c-software, 0.15), rgba($c-software, 0.05));
  }

  &[data-type="web"] {
    background: linear-gradient(135deg, rgba($c-web, 0.15), rgba($c-web, 0.05));
  }

  &[data-type="netzwerk"] {
    background: linear-gradient(135deg, rgba($c-netzwerk, 0.15), rgba($c-netzwerk, 0.05));
  }

  &[data-type="support"] {
    background: linear-gradient(135deg, rgba($c-support, 0.15), rgba($c-support, 0.05));
  }
}

.modal-body {
  padding: 1rem 1.25rem;
}

.modal-description {
  font-size: 0.875rem;
  line-height: 1.65;
  color: $text-light;
  margin-bottom: 1rem;
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;

  span {
    padding: 0.3125rem 0.625rem;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 500;
    color: $text-muted;
    // Bewusst flach und nicht-interaktiv
    cursor: default;
    user-select: none;
  }
}

.modal-actions {
  padding: 1rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(0, 0, 0, 0.02);
  border-radius: 0 0 20px 20px;

  .btn {
    width: 100%;
  }
}


// ============================================
// RESPONSIVE - TABLET (640px+)
// ============================================
@media (min-width: 640px) {

  .header {
    margin-bottom: 2rem;

    h1 {
      font-size: 2.25rem;
    }

    > p {
      font-size: 1.125rem;
      margin-bottom: 1.5rem;
    }
  }

  .search-box {
    max-width: 450px;

    input {
      padding: 1rem 3rem 1rem 3.25rem;
      font-size: 1rem;

      &::placeholder {
        font-size: 1rem;
      }
    }

    > .material-symbols-outlined {
      font-size: 22px;
      left: 1rem;
    }
  }

  .filter-tabs {
    justify-content: center;
    flex-wrap: wrap;
    padding: 1rem 0 1rem;
    margin: 0;
    gap: 0.5rem;
  }

  .tab {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;

    .material-symbols-outlined {
      font-size: 18px;
    }
  }

  .services {
    gap: 2rem;
  }

  .category {
    padding: 1.5rem;
  }

  .category-header {
    gap: 1rem;
    margin-bottom: 1.25rem;

    h2 {
      font-size: 1.25rem;
    }

    p {
      font-size: 0.875rem;
    }
  }

  .category-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;

    .material-symbols-outlined {
      font-size: 28px;
    }
  }

  .service-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .service-card {
    padding: 1.125rem;
  }

  .service-content {
    h3 {
      font-size: 1rem;
    }

    p {
      font-size: 0.875rem;
      -webkit-line-clamp: 3;
    }
  }

  .service-icon {
    font-size: 1.5rem;
  }

  .tags span {
    font-size: 0.75rem;
    padding: 0.3rem 0.625rem;
  }

  .card-arrow {
    opacity: 0.6;
    transform: translateX(0);
  }

  .service-card:hover .card-arrow {
    opacity: 1;
    transform: translateX(3px);
  }

  .cta-box {
    padding: 2rem;
  }

  .cta-buttons {
    flex-direction: row;
    justify-content: center;
    gap: 0.75rem;
  }

  .btn {
    padding: 0.875rem 1.5rem;
    font-size: 0.9375rem;

    &.large {
      padding: 1rem 1.75rem;
      font-size: 1rem;
    }
  }

  // Modal Tablet
  .modal {
    max-width: 480px;
  }

  .modal-header {
    padding: 1.5rem 1.5rem 0;
    gap: 1rem;

    h2 {
      font-size: 1.375rem;
    }
  }

  .modal-category {
    font-size: 0.75rem;
  }

  .modal-icon {
    width: 56px;
    height: 56px;

    .service-emoji {
      font-size: 1.75rem;
    }
  }

  .modal-body {
    padding: 1.25rem 1.5rem;
  }

  .modal-description {
    font-size: 0.9375rem;
    margin-bottom: 1.25rem;
  }

  .modal-tags span {
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
  }

  .modal-actions {
    padding: 1.25rem 1.5rem 1.5rem;
    flex-direction: row;
    gap: 0.75rem;

    .btn {
      width: auto;
      flex: 1;
    }
  }

  .modal-close {
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;

    .material-symbols-outlined {
      font-size: 20px;
    }
  }
}

// ============================================
// RESPONSIVE - DESKTOP (900px+)
// ============================================
@media (min-width: 900px) {
  .header h1 {
    font-size: 2.5rem;
  }

  .service-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .category {
    padding: 2rem;
  }

  .modal {
    max-width: 500px;
  }

  .modal-header {
    padding: 2rem 2rem 0;

    h2 {
      font-size: 1.5rem;
    }
  }

  .modal-body {
    padding: 1.5rem 2rem;
  }

  .modal-actions {
    padding: 1.5rem 2rem 2rem;
  }
}

// ===== SAFE AREA SUPPORT (Notch etc.) =====
@supports (padding: max(0px)) {
  .modal-backdrop {
    padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  }
}

// ===== REDUCED MOTION =====
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}