/* MIWE Upload-Tool — Industrial Precision Design */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

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

:root {
  /* MIWE Brand */
  --primary: #004B93;
  --primary-hover: #003870;
  --primary-light: #e8f0fa;
  --primary-muted: #6a9fd8;

  /* Semantic */
  --danger: #c0392b;
  --danger-hover: #962d22;
  --danger-light: #fdecea;
  --success: #1e7e34;
  --success-light: #e8f5e9;
  --warn: #b8860b;
  --warn-light: #fef9e7;

  /* Neutral */
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #4a4a5a;
  --text-muted: #6b7280;
  --border: #d1d5db;
  --border-light: #e5e7eb;

  /* Spacing */
  --radius: 6px;
  --radius-lg: 10px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
}

/* ===== BASE ===== */

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 19px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

.page-wrapper {
  max-width: 680px;
  margin: 0 auto;
  padding: var(--space-md);
  padding-top: 0;
}

.page-wrapper--wide {
  max-width: 960px;
}

/* ===== HEADER ===== */

.site-header {
  background: var(--primary);
  padding: var(--space-lg) var(--space-md);
  margin-bottom: var(--space-lg);
  position: relative;
  overflow: hidden;
}

.site-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #ff8c00, #ffa940, #ff8c00);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
}

.site-header h1 {
  color: #ffffff;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.3;
}

.site-header .header-sub {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.89rem;
  margin-top: 2px;
  font-weight: 400;
}

.brand-mark {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: var(--space-xs);
  display: block;
}

/* ===== TYPOGRAPHY ===== */

h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-sm);
  letter-spacing: -0.01em;
}

p {
  color: var(--text-secondary);
}

/* ===== CARDS ===== */

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--primary);
  position: relative;
}

.card--neutral {
  border-left-color: var(--border-light);
}

/* ===== FORMS ===== */

.form-group {
  margin-bottom: var(--space-lg);
}

.form-group:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  font-weight: 600;
  font-size: 0.84rem;
  color: var(--text);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input[type="text"],
input[type="password"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 75, 147, 0.15);
}

.form-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== BUTTONS ===== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background 0.2s, transform 0.1s;
  width: 100%;
  min-height: 52px;
  letter-spacing: 0.01em;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary:disabled {
  background: var(--primary-muted);
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-small {
  padding: 6px 14px;
  font-size: 0.78rem;
  width: auto;
  min-height: auto;
}

/* ===== FILE INPUT ===== */

.file-input-wrapper {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--bg);
}

.file-input-wrapper:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.file-input-wrapper input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  font-size: 0;
}

.file-input-icon {
  display: block;
  margin: 0 auto var(--space-sm);
  width: 40px;
  height: 40px;
  color: var(--primary-muted);
}

.file-input-label {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}

.file-input-label strong {
  color: var(--primary);
  font-weight: 600;
}

.file-count {
  margin-top: var(--space-sm);
  font-weight: 600;
  color: var(--primary);
  font-size: 0.95rem;
}

/* ===== PROGRESS ===== */

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
  margin: var(--space-md) 0 var(--space-sm);
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  border-radius: 3px;
  transition: width 0.3s ease;
  position: relative;
}

.progress-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.3) 50%,
    transparent 100%
  );
  animation: progress-shine 1.5s ease infinite;
}

@keyframes progress-shine {
  from { transform: translateX(-100%); }
  to { transform: translateX(200%); }
}

.progress-text {
  font-size: 0.84rem;
  color: var(--text-muted);
  text-align: center;
  font-weight: 500;
}

/* ===== MESSAGES ===== */

.msg {
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: var(--space-md);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.45;
}

.msg-error {
  background: var(--danger-light);
  color: var(--danger);
  border-left: 3px solid var(--danger);
}

.msg-success {
  background: var(--success-light);
  color: var(--success);
  border-left: 3px solid var(--success);
}

.msg-warn {
  background: var(--warn-light);
  color: var(--warn);
  border-left: 3px solid var(--warn);
}

/* ===== COLLAPSIBLE ===== */

.collapsible-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding: 10px 0;
  user-select: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  border-top: 1px solid var(--border-light);
  margin-top: var(--space-sm);
  padding-top: var(--space-md);
}

.collapsible-header::after {
  content: '';
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.collapsible-header.open::after {
  transform: rotate(-135deg);
}

.collapsible-body {
  display: none;
  padding-top: var(--space-md);
}

.collapsible-body.open {
  display: block;
}

/* ===== THUMBNAIL GRID ===== */

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: var(--space-sm);
  margin: var(--space-md) 0;
}

.thumb-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius);
  cursor: pointer;
  border: 2px solid var(--border-light);
  transition: border-color 0.2s, transform 0.15s;
}

.thumb-item:hover {
  border-color: var(--primary);
  transform: scale(1.03);
}

.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-item .thumb-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 6px 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  color: #fff;
  font-size: 0.7rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== META TABLE ===== */

.meta-table {
  width: 100%;
  font-size: 0.95rem;
}

.meta-table td {
  padding: 8px 12px 8px 0;
  vertical-align: top;
  border-bottom: 1px solid var(--border-light);
}

.meta-table tr:last-child td {
  border-bottom: none;
}

.meta-table td:first-child {
  font-weight: 600;
  white-space: nowrap;
  width: 1%;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  padding-top: 10px;
}

/* ===== ADMIN: BATCH CARDS (Mobile-first) ===== */

.batch-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.batch-card {
  border-left-color: var(--border-light);
}

.batch-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-md);
  gap: var(--space-sm);
}

.batch-card-header strong {
  font-size: 1rem;
}

.batch-card-header .text-muted {
  font-size: 0.82rem;
  white-space: nowrap;
}

.batch-card-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-md);
  font-size: 0.88rem;
}

.batch-card-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.batch-card-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.batch-card-actions {
  display: flex;
  gap: var(--space-sm);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-light);
}

.batch-card-actions .btn {
  flex: 1;
}

/* Desktop-Tabelle: standardmaessig versteckt */
.batch-desktop {
  display: none;
}

/* ===== ADMIN TABLE (Desktop) ===== */

.batch-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.batch-table th,
.batch-table td {
  padding: 8px 6px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.batch-table th {
  background: var(--bg);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  position: sticky;
  top: 0;
}

.batch-table tbody tr {
  transition: background 0.15s;
}

.batch-table tbody tr:hover {
  background: var(--primary-light);
}

.batch-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.batch-actions {
  white-space: nowrap;
}

.batch-actions .btn {
  display: inline-flex;
  margin-right: 4px;
}

.batch-actions .btn:last-child {
  margin-right: 0;
}

/* ===== BADGES ===== */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
}

.badge-danger {
  background: var(--danger-light);
  color: var(--danger);
}

.badge-warn {
  background: var(--warn-light);
  color: var(--warn);
}

.badge-muted {
  background: #f0f0f0;
  color: var(--text-muted);
}

/* ===== PRODUCT CHIPS ===== */

.chip-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 600;
}

.chip-remove {
  cursor: pointer;
  font-weight: bold;
  opacity: 0.6;
  transition: opacity 0.15s;
  line-height: 1;
}

.chip-remove:hover {
  opacity: 1;
}

/* ===== PIN INPUT ===== */

.pin-input {
  letter-spacing: 0.6em;
  text-align: center;
  font-size: 1.8rem;
  font-weight: 700;
  max-width: 240px;
  margin: 0 auto;
  display: block;
  color: var(--primary);
  border-width: 2px;
}

.pin-section-text {
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/* ===== DOWNLOAD HEADER ===== */

.section-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  gap: var(--space-md);
}

.section-bar h2 {
  margin-bottom: 0;
}

/* ===== STATS ===== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
}

.stat-item {
  text-align: center;
  padding: var(--space-md);
  background: var(--bg);
  border-radius: var(--radius);
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-top: 2px;
}

/* ===== UTILITY ===== */

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-8 { margin-top: var(--space-sm); }
.mt-16 { margin-top: var(--space-md); }
.mb-8 { margin-bottom: var(--space-sm); }
.mb-16 { margin-bottom: var(--space-md); }

/* ===== NETWORK BAR ===== */

.network-bar {
  text-align: center;
  padding: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.network-bar--offline {
  background: var(--danger);
  color: #fff;
}

/* ===== STATUS MODULE ===== */

.status-module {
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: var(--space-md);
  border-left: 3px solid transparent;
}

.status-module--info {
  background: var(--primary-light);
  color: var(--primary);
  border-left-color: var(--primary);
}

.status-module--success {
  background: var(--success-light);
  color: var(--success);
  border-left-color: var(--success);
}

.status-module--warn {
  background: var(--warn-light);
  color: var(--warn);
  border-left-color: var(--warn);
}

.status-module--error {
  background: var(--danger-light);
  color: var(--danger);
  border-left-color: var(--danger);
}

.status-module-text {
  font-weight: 600;
  font-size: 0.9rem;
}

.status-module-progress {
  margin-top: var(--space-sm);
}

/* ===== GALLERY ===== */

.gallery-summary {
  margin-top: var(--space-sm);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.gallery-actions {
  margin-top: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.gallery-actions-row {
  display: flex;
  gap: var(--space-sm);
}

.gallery-actions-row .btn {
  flex: 1;
}

.gallery-manage {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border-light);
  margin-top: var(--space-sm);
}

.empty-state {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  opacity: 0.5;
  margin-bottom: var(--space-sm);
}

/* Thumb Selection */

.thumb-item--selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}

.thumb-check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: rgba(0,0,0,0.3);
}

.thumb-check--active {
  background: var(--primary);
  border-color: var(--primary);
}

.thumb-check--active::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 6px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ===== DRAFT LIST ===== */

.draft-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-light);
}

.draft-item:last-child {
  border-bottom: none;
}

.draft-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.draft-info strong {
  font-size: 0.9rem;
}

.draft-info .text-muted {
  font-size: 0.78rem;
}

.draft-actions {
  display: flex;
  gap: var(--space-xs);
  flex-shrink: 0;
}

/* ===== UPLOAD ITEMS ===== */

.upload-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.upload-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  background: var(--bg);
}

.upload-item--uploaded {
  background: var(--success-light);
}

.upload-item--failed {
  background: var(--danger-light);
}

.upload-item--uploading {
  background: var(--primary-light);
}

.upload-item-icon {
  flex-shrink: 0;
  font-size: 1rem;
}

.upload-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-item-progress {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--primary);
  flex-shrink: 0;
}

/* ===== OVERLAY ===== */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--space-md);
}

.overlay--dark {
  background: rgba(0, 0, 0, 0.9);
}

.overlay-content {
  max-width: 400px;
  width: 100%;
}

.overlay-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

.overlay-actions .btn {
  flex: 1;
}

/* ===== PREVIEW ===== */

.preview-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 90vw;
  max-height: 90vh;
}

.preview-image {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: var(--radius);
}

.preview-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  background: rgba(255,255,255,0.1);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius);
}

.preview-name {
  color: #fff;
  font-size: 0.82rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== BUTTONS EXTRA ===== */

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary-light);
}

.btn-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  padding: 4px 0;
  text-decoration: underline;
}

.btn-link:hover {
  color: var(--primary-hover);
}

.text-danger {
  color: var(--danger) !important;
}

/* ===== PRODUCT DROPDOWN ===== */

.product-dropdown {
  position: absolute;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
  width: 100%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.product-dropdown-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9rem;
}

.product-dropdown-item:hover {
  background: var(--primary-light);
}

/* ===== FORM ACTIONS ===== */

.form-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

.form-actions .btn {
  flex: 1;
}

/* ===== SCREEN READER ONLY ===== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ===== ALPINE CLOAK ===== */

[x-cloak] { display: none !important; }

/* ===== RESPONSIVE ===== */

@media (min-width: 480px) {
  .page-wrapper {
    padding: var(--space-lg);
    padding-top: 0;
  }

  .site-header {
    padding: var(--space-xl) var(--space-lg);
    margin-bottom: var(--space-xl);
  }
}

/* Desktop: Tabelle statt Karten */
@media (min-width: 768px) {
  .batch-cards {
    display: none;
  }

  .batch-desktop {
    display: block;
  }
}
