/* Verwaltungsystem - Mobile-First CSS for Samsung Z Fold 5 Outer Screen */
/* Resolution: 2316 x 904 pixels, Aspect Ratio: 23.1:9 */

:root {
  /* Colors - ADMIN APP: Black text for maximum readability */
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-text: #000000;
  --color-text-secondary: #000000;
  --color-border: #e5e7eb;
  --color-bg: #e8e8e8;
  --color-white: #ffffff;
  
  /* Card colors */
  --color-weiss: #ffffff;
  --color-gelb: #fef3c7;
  --color-rot: #fee2e2;
  --color-blau: #dbeafe;
  --color-grau: #b1b1b1;
  --color-gruen: #dcfce7;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  
  /* Touch target */
  --touch-target: 44px;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-primary);
  color: white;
  position: sticky;
  top: 0;
  z-index: 100;
  will-change: transform;
}

.header-title {
  font-size: 1.25rem;
  font-weight: 600;
}

/* Alarm Badge */
.alarm-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: #ef4444;
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
  animation: alarm-pulse 2s ease-in-out infinite;
}

@keyframes alarm-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.alarm-btn {
  color: #facc15 !important;
}

.alarm-btn.active {
  background: rgba(245, 158, 11, 0.2);
  border-radius: 8px;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  border-radius: 8px;
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0.3);
  touch-action: manipulation;
  position: relative;
  z-index: 10;
}

.btn-icon:active,
.btn-icon:focus {
  background: rgba(255, 255, 255, 0.2);
  outline: none;
}

.btn-icon.danger {
  color: #ef4444;
}

.btn-icon.restore {
  color: #22c55e;
}

/* Category Tabs */
.tabs {
  display: flex;
  overflow-x: auto;
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex-shrink: 0;
  padding: var(--space-md) var(--space-lg);
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}

.tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* Sub-tabs */
.sub-tabs {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.sub-tab {
  flex-shrink: 0;
  padding: var(--space-sm) var(--space-md);
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}

.sub-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 700;
}

/* Filter Bar */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-lg);
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
}

.filter-group {
  display: flex;
  gap: var(--space-xs);
}

.filter-btn {
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
}

.filter-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.sort-btn {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm);
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
}

/* Search Bar */
.search-bar {
  padding: var(--space-sm) var(--space-md);
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
}

.search-bar input[type="search"] {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  font-size: 0.9rem;
  background: var(--color-bg);
  min-height: 40px;
}

.search-bar input[type="search"]:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
  background: var(--color-white);
}

.search-bar input[type="search"]::placeholder {
  color: #9ca3af;
  font-size: 0.8rem;
}

/* Dimmed state when search is active */
.search-active .filter-group,
.search-active .tabs,
.search-active .sub-tabs {
  opacity: 0.35;
  pointer-events: none;
}

/* Anfragen List */
.list {
  flex: 1;
  padding: var(--space-md);
}

.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  cursor: pointer;
  border: 2px solid transparent;
  position: relative;
}

.card-id {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 1.1em;
  color: #ef4444;
  font-weight: 700;
}

.card:active {
  background: var(--color-bg);
}

.card.color-weiss { background: var(--color-weiss); }
.card.color-gelb { background: var(--color-gelb); }
.card.color-rot { background: var(--color-rot); }
.card.color-blau { background: var(--color-blau); }
.card.color-grau { background: var(--color-grau); }
.card.color-gruen { background: var(--color-gruen); }

.card-route {
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--color-text);
  margin-bottom: var(--space-sm);
}

.card-dates {
  display: block;
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--color-text);
}

.card-volume {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  font-size: 1.5rem;
  color: var(--color-text);
}

.card-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 1.5rem;
}

.card-price {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  margin-top: var(--space-sm);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.card-anfrage-von {
  font-size: 1.5rem;
  font-weight: 700;
  text-transform: uppercase;
  justify-self: start;
}

/* Empty State */
.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  color: var(--color-text-secondary);
  text-align: center;
}

.error-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  color: var(--color-rot);
  text-align: center;
  gap: var(--space-md);
}

.error-state button {
  padding: var(--space-sm) var(--space-lg);
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* Loading State */
.loading-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  color: var(--color-text-secondary);
  text-align: center;
  gap: var(--space-md);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  z-index: 200;
  display: flex;
  flex-direction: column;
}

#umzugsliste-editor,
#nachricht-editor,
#angebot-editor,
#anmerkungen-editor {
  z-index: 300;
}

#pdf-editor,
#rechnung-pdf-editor {
  z-index: 310;
}

.umzugsliste-editor-body {
  padding: var(--space-lg);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.umzugsliste-editor-body textarea {
  flex: 1;
  width: 100%;
  min-height: 70vh;
  resize: vertical;
  font-size: 1rem;
  line-height: 1.6;
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: inherit;
}

.btn-open-editor {
  display: block;
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  margin-top: var(--space-sm);
}

.modal-content {
  flex: 1;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.modal-header h2 {
  flex: 1;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
}

/* Form */
.form {
  padding: var(--space-lg) var(--space-lg) var(--space-lg) var(--space-xl);
}

.form-section {
  margin-bottom: var(--space-xl);
}

/* Notizen section - dark theme */
#notizen-section {
  background: #1f2937;
  padding: var(--space-lg);
  border-radius: 12px;
}

#notizen-section h3 {
  color: #ffffff;
}

#notizen-section label > span,
#notizen-section .checkbox-label span {
  color: #ffffff;
}

#notizen-section .btn-open-editor {
  background: #3b82f6;
}

.form-section h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-md);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

label {
  display: block;
  margin-bottom: var(--space-md);
}

label > span {
  display: block;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-xs);
  word-spacing: 0.5em;
}

input, select, textarea {
  width: 100%;
  min-height: var(--touch-target);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 1.25rem;
  font-family: inherit;
  background: var(--color-white);
  color: var(--color-text);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

/* Radio & Checkbox */
.radio-group, .checkbox-group {
  display: flex;
  gap: var(--space-lg);
}

.radio, .checkbox {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  cursor: pointer;
  margin-bottom: var(--space-md);
}

.radio input, .checkbox input {
  width: 24px;
  height: 24px;
  min-height: auto;
  flex-shrink: 0;
}

.radio span, .checkbox span {
  font-size: 1.25rem;
  font-weight: 600;
  flex: 1;
  word-spacing: 0.5em;
}

/* Standalone checkbox label (e.g. Angerufen) */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 28px;
  height: 28px;
  min-height: auto;
  flex-shrink: 0;
  cursor: pointer;
}

.checkbox-label span {
  font-size: 1.25rem;
  font-weight: 600;
}

/* Text preview (shown above editor buttons) */
.text-preview {
  white-space: pre-wrap;
  font-size: 1rem;
  color: var(--color-text);
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-sm);
  max-height: 120px;
  overflow-y: auto;
  display: none;
}

.text-preview.has-content {
  display: block;
}

/* Detail SVG icons */
.detail-icon {
  width: 2em;
  height: 2em;
  vertical-align: middle;
  display: inline-block;
}

.card-meta-icon {
  width: 1.5em;
  height: 1.5em;
  vertical-align: middle;
}

/* Color Picker */
.color-picker {
  display: flex;
  gap: var(--space-md);
}

.color-option {
  cursor: pointer;
}

.color-option input {
  display: none;
}

.color-swatch {
  display: block;
  width: 40px;
  height: 40px;
  border: 2px solid var(--color-border);
  border-radius: 8px;
}

.color-option input:checked + .color-swatch {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary);
}

.color-swatch.color-weiss { background: var(--color-weiss); }
.color-swatch.color-gelb { background: var(--color-gelb); }
.color-swatch.color-rot { background: var(--color-rot); }
.color-swatch.color-blau { background: var(--color-blau); }
.color-swatch.color-grau { background: var(--color-grau); }
.color-swatch.color-gruen { background: var(--color-gruen); }

/* Media Gallery */
.media-gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.media-item {
  position: relative;
  aspect-ratio: 1;
  background: var(--color-bg);
  border-radius: 8px;
  overflow: hidden;
}

.media-item img, .media-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 36px;
  height: 36px;
  background: rgba(0, 0, 0, 0.7);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* File Upload */
.file-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-lg);
  background: var(--color-white);
  border: 2px solid var(--color-primary);
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  aspect-ratio: 1 / 1;
  max-width: 200px;
  margin: 0 auto;
}

.file-upload input {
  display: none;
}

.file-upload span {
  color: var(--color-primary);
  font-size: 1.125rem;
  font-weight: 600;
}

/* Save Button */
.btn-save {
  width: 100%;
  padding: var(--space-lg);
  background: var(--color-primary);
  border: none;
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: var(--space-lg);
}

.btn-save:active {
  background: var(--color-primary-dark);
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  animation: fadeIn 0.2s ease;
}

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

.lightbox-close {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 28px;
  cursor: pointer;
  z-index: 301;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-close:hover,
.lightbox-close:active {
  background: rgba(255, 255, 255, 0.3);
}

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 32px;
  cursor: pointer;
  z-index: 301;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.lightbox-prev:hover,
.lightbox-prev:active,
.lightbox-next:hover,
.lightbox-next:active {
  background: rgba(255, 255, 255, 0.4);
}

.lightbox-prev {
  left: var(--space-lg);
}

.lightbox-next {
  right: var(--space-lg);
}

.lightbox-counter {
  position: absolute;
  bottom: var(--space-lg);
  left: 50%;
  transform: translateX(-50%);
  color: white;
  font-size: 14px;
  background: rgba(0, 0, 0, 0.5);
  padding: var(--space-xs) var(--space-md);
  border-radius: 20px;
}

.lightbox-content {
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-content img,
.lightbox-content video {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
}

.lightbox-content img.hidden,
.lightbox-content video.hidden {
  display: none;
}

/* Make media items clickable */
.media-item {
  cursor: pointer;
}

.media-item:active {
  opacity: 0.8;
}

/* Backup / Export Toolbar */
.backup-toolbar {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
}

.btn-backup {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-backup:active {
  background: var(--color-hover);
  border-color: var(--color-primary);
}

.btn-backup:disabled {
  opacity: 0.5;
  cursor: wait;
}
