/**
 * QR SCAN HANDLER STYLES
 * 
 * Styling für alle 3 Device-Flows:
 * - Mobile: Quick Action Modal
 * - Tablet: Floating Action Bar
 * - Desktop: Auto-Scroll Highlight + Toast
 */

/* ================================================================
   QUICK ACTION MODAL (MOBILE)
   ================================================================ */

.qr-quick-action-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease;
  padding: 20px;
}

.qr-quick-action-modal.show {
  opacity: 1;
}

.qr-quick-content {
  background: #000000;
  border-radius: 12px;
  padding: 24px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.qr-quick-title {
  margin: 0 0 16px 0;
  font-size: 1.3rem;
  font-weight: 600;
  color: #ffffff;
  text-align: center;
}

.qr-quick-bestand-info {
  background: #0f0f0f;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
  border-left: 4px solid #4ba3ff;
}

.bestand-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.bestand-row:last-child {
  margin-bottom: 0;
}

.bestand-row .label {
  color: #cccccc;
  font-weight: 500;
}

.bestand-row .value {
  color: #4ba3ff;
  font-weight: 700;
  font-size: 1.1rem;
}

.bestand-row .value.low-stock {
  color: #d32f2f;
}

.qr-quick-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qr-quick-btn {
  padding: 12px 16px;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
  touch-action: manipulation;
}

.btn-primary.qr-quick-btn {
  background: #0066cc;
  color: white;
}

.btn-primary.qr-quick-btn:hover {
  background: #0052a3;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
}

.btn-primary.qr-quick-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 102, 204, 0.3);
}

.btn-secondary.qr-quick-btn {
  background: #2a2a2a;
  color: #ffffff;
  border: 1px solid #444;
}

.btn-secondary.qr-quick-btn:hover {
  background: #3a3a3a;
  border-color: #555;
}

.btn-tertiary.qr-quick-btn {
  background: transparent;
  color: #cccccc;
  border: 1px solid #444;
}

.btn-tertiary.qr-quick-btn:hover {
  background: #2a2a2a;
  border-color: #666;
}

/* Mobile-specific adjustments */
@media (max-width: 480px) {
  .qr-quick-content {
    max-width: 100%;
    padding: 20px;
  }

  .qr-quick-title {
    font-size: 1.2rem;
  }

  .qr-quick-btn {
    font-size: 0.9rem;
    padding: 11px 14px;
  }
}

/* ================================================================
   FLOATING ACTION BAR (TABLET)
   ================================================================ */

.qr-floating-action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #0066cc 0%, #0052a3 100%);
  color: white;
  z-index: 99;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
  animation: slideUp 0.3s ease;
}

.qr-floating-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  max-width: 1200px;
  margin: 0 auto;
  gap: 20px;
}

.qr-floating-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  flex: 1;
}

.qr-floating-info .label {
  font-weight: 600;
  opacity: 0.9;
}

.qr-floating-info .value {
  font-weight: 700;
  font-size: 1rem;
}

.qr-floating-actions {
  display: flex;
  gap: 8px;
}

.btn-floating {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 8px 14px;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.85rem;
  min-height: 40px;
}

.btn-floating:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
}

.btn-floating:active {
  background: rgba(255, 255, 255, 0.4);
}

/* Adjust page bottom padding to not hide content under floating bar */
body.qr-floating-active {
  padding-bottom: 60px;
}

@media (max-width: 768px) {
  .qr-floating-content {
    flex-direction: column;
    gap: 10px;
  }

  .qr-floating-info {
    justify-content: space-around;
    width: 100%;
  }

  .qr-floating-actions {
    width: 100%;
    justify-content: space-between;
  }
}

/* ================================================================
   AUTO-SCROLL HIGHLIGHT (DESKTOP)
   ================================================================ */

[data-section="bestand"].highlight-glow {
  animation: highlightGlow 0.5s ease-out;
  box-shadow: 0 0 20px rgba(0, 102, 204, 0.4),
              inset 0 0 20px rgba(0, 102, 204, 0.1);
  border-radius: 4px;
}

@keyframes highlightGlow {
  0% {
    box-shadow: 0 0 0 rgba(0, 102, 204, 0.5),
                inset 0 0 0 rgba(0, 102, 204, 0.2);
  }
  50% {
    box-shadow: 0 0 30px rgba(0, 102, 204, 0.6),
                inset 0 0 30px rgba(0, 102, 204, 0.15);
  }
  100% {
    box-shadow: 0 0 10px rgba(0, 102, 204, 0.3),
                inset 0 0 10px rgba(0, 102, 204, 0.05);
  }
}

/* ================================================================
   TOAST NOTIFICATIONS
   ================================================================ */

.qr-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #323232;
  color: white;
  padding: 12px 20px;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.qr-toast.show {
  opacity: 1;
}

@media (max-width: 640px) {
  .qr-toast {
    bottom: 80px;
    padding: 10px 16px;
    font-size: 0.85rem;
  }

  .qr-floating-action-bar ~ .qr-toast {
    bottom: 90px;
  }
}

/* ================================================================
   ACCESSIBILITY
   ================================================================ */

@media (prefers-reduced-motion: reduce) {
  .qr-quick-action-modal,
  .qr-floating-action-bar,
  [data-section="bestand"].highlight-glow,
  .qr-toast {
    animation: none !important;
    transition: none !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: more) {
  .qr-quick-content {
    border: 2px solid #000;
  }

  .qr-quick-btn {
    border-width: 2px;
  }

  .qr-floating-action-bar {
    border-top: 2px solid #fff;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .qr-quick-content {
    background: #2a2a2a;
    color: #fff;
  }

  .qr-quick-title {
    color: #fff;
  }

  .qr-quick-bestand-info {
    background: #333;
    border-left-color: #4da6ff;
  }

  .bestand-row .label {
    color: #aaa;
  }

  .bestand-row .value {
    color: #4da6ff;
  }

  .btn-secondary.qr-quick-btn {
    background: #333;
    color: #fff;
    border-color: #555;
  }

  .btn-secondary.qr-quick-btn:hover {
    background: #444;
    border-color: #666;
  }

  .btn-tertiary.qr-quick-btn {
    color: #aaa;
    border-color: #555;
  }

  .btn-tertiary.qr-quick-btn:hover {
    background: #333;
  }

  .qr-toast {
    background: #555;
    color: #fff;
  }
  
  /* Reservation Popup Styles */
  .qr-reservation-popup {
    position: fixed;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 999999;
    padding: 12px;
    font-size: 13px;
    max-height: 350px;
    overflow-y: auto;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.15s ease, transform 0.15s ease;
  }

  .qr-reservation-popup.show {
    opacity: 1;
    transform: translateY(0);
  }

  .qr-popup-header {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .qr-reservation-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
  }

  .qr-reservation-table thead {
    background: #f5f5f5;
    border-bottom: 2px solid #ddd;
  }

  .qr-reservation-table th {
    padding: 6px 4px;
    text-align: left;
    font-weight: 600;
    color: #555;
    font-size: 11px;
    text-transform: uppercase;
  }

  .qr-reservation-table td {
    padding: 6px 4px;
    border-bottom: 1px solid #eee;
    color: #333;
  }

  .qr-reservation-table tbody tr:hover {
    background: #f9f9f9;
  }

  .gericht-cell {
    font-weight: 500;
    max-width: 120px;
    word-break: break-word;
  }

  .datum-cell {
    color: #666;
    font-size: 11px;
  }

  .menge-cell {
    text-align: right;
    font-variant-numeric: tabular-nums;
  }

  .status-col {
    text-align: center;
    width: 32px;
  }

  .status-cell {
    text-align: center;
    font-weight: 600;
    font-size: 14px;
  }

  .status-ok {
    color: #4CAF50;
  }

  .status-error {
    color: #ff4444;
  }

  /* Hover effect on reservation-row */
  .reservation-row {
    transition: background-color 0.15s ease;
  }

  .reservation-row:hover {
    background-color: rgba(255, 165, 0, 0.08);
  }

  /* Mobile adjustments for reservation popup */
  @media (max-width: 600px) {
    .qr-reservation-popup {
      max-width: calc(100vw - 20px);
      left: 10px !important;
      right: 10px !important;
    }

    .qr-reservation-table {
      font-size: 11px;
    }

    .qr-reservation-table th,
    .qr-reservation-table td {
      padding: 4px 3px;
    }

    .gericht-cell {
      max-width: 80px;
    }
  }
}

/* ================================================================
   RESERVATION TOOLTIP (CSS-BASED, like todo.html)
   ================================================================ */

.qr-reservation-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
}

.qr-reservation-tooltip-trigger {
  position: relative;
  cursor: help;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.qr-reservation-tooltip {
  visibility: hidden;
  background-color: #2a2a2a;
  color: #fff;
  text-align: left;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 12px;
  position: fixed;
  z-index: 10000;
  width: 320px;
  box-shadow: 0 8px 24px 0 rgba(0, 0, 0, 0.8);
  font-size: 0.85em;
  font-weight: normal;
  white-space: normal;
  line-height: 1.5;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  max-height: 300px;
  overflow-y: auto;
}

.qr-reservation-tooltip::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #2a2a2a transparent transparent transparent;
}

.qr-reservation-tooltip-trigger:hover ~ .qr-reservation-tooltip {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.qr-reservation-tooltip:hover {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.qr-tooltip-item-ok {
  color: #4CAF50;
  padding: 4px 0;
  font-size: 0.9em;
  line-height: 1.4;
}

.qr-tooltip-item-fail {
  color: #ff6666;
  padding: 4px 0;
  font-size: 0.9em;
  line-height: 1.4;
}
