/* Global Variables */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #7c3aed;
  --accent-dark: #6d28d9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --light-bg: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-light: #64748b;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: var(--light-bg);
  color: var(--text);
  line-height: 1.6;
  margin: 0;
  padding: 0;
}

/* Auth Card Styles */
.card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #e0f2fe 0%, #dbeafe 100%);
  padding: 2rem;
}

.card h2 {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.5rem;
  text-align: center;
}

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

.card .muted {
  color: var(--text-light);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.card .desktop-notice {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  text-align: center;
  max-width: 400px;
}

.card form {
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
  display: none;
  transition: all 0.3s ease;
}

.card form.active-form {
  display: block;
}

.card form:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-4px);
}

.card input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

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

.card .row {
  display: flex;
  gap: 0.75rem;
}

.card .row button {
  flex: 1;
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.card .row button[type="submit"] {
  background: linear-gradient(90deg, var(--primary), var(--accent));
  color: white;
  border: none;
}

.card .row button[type="submit"]:hover {
  background: linear-gradient(90deg, var(--primary-dark), var(--accent-dark));
}

.card .row button[type="button"] {
  background: var(--light-bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.card .row button[type="button"]:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

#user-panel {
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
  text-align: center;
  margin-top: 1rem;
  transition: all 0.3s ease;
}

#user-panel:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-4px);
}

#user-panel button {
  width: 100%;
  padding: 0.75rem;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

#user-panel button:hover {
  background: #dc2626;
}

#messages .msg {
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 0.875rem;
  text-align: center;
  opacity: 0;
  animation: fadeIn 0.3s ease forwards;
}

#messages .error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

#messages .success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

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

/* Dashboard Styles */
#dashboard {
  display: none;
  min-height: 100vh;
  padding: 2rem 1rem;
  background: var(--light-bg);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

header {
  background: white;
  box-shadow: var(--shadow);
  padding: 1rem 0;
  margin-bottom: 2rem;
  border-radius: 12px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.brand-info {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

#brandName {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
  background: linear-gradient(to right, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

#provision {
  font-size: 1rem;
  color: var(--text-light);
  font-style: italic;
}

.logout-btn {
  padding: 10px 20px;
  background-color: var(--light-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.logout-btn:hover {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-2px);
}

.help-link {
  padding: 10px 20px;
  background-color: var(--light-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.3s ease;
}

.help-link:hover {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-2px);
}

.reporting-card {
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 2rem;
  margin-bottom: 2rem;
  transition: transform 0.3s ease;
}

.reporting-card:hover {
  transform: translateY(-5px);
}

.reporting-card h3 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.5rem;
}

/* Enhanced Period Controls */
#periodControls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 1.5rem;
  background: white;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: var(--shadow);
  align-items: center;
  transition: box-shadow 0.3s ease;
}

#periodControls:hover {
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

#periodControls button {
  padding: 10px 20px;
  border: none;
  border-radius: 20px;
  background: var(--light-bg);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

#periodControls button:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
}

#periodControls button.active {
  background: linear-gradient(90deg, var(--primary), var(--accent));
  color: white;
  font-weight: 700;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#periodControls button.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 6px;
  height: 6px;
  background: var(--primary-dark);
  border-radius: 50%;
  transform: translateX(-50%);
}

#periodControls .period-label-container {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-light);
  font-weight: 500;
}

#periodControls #periodLabel {
  font-weight: 700;
  color: var(--primary);
  background: linear-gradient(to right, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

#periodControls .custom-period {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  background: var(--light-bg);
}

#periodControls label {
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
}

#periodControls input[type="date"] {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: white;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  max-width: 160px;
}

#periodControls input[type="date"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

#periodControls button[onclick="setCustomPeriod()"] {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.2s ease;
}

#periodControls button[onclick="setCustomPeriod()"]:hover {
  background: linear-gradient(90deg, var(--primary-dark), var(--accent-dark));
  transform: translateY(-2px);
}

.reporting-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.reporting-item {
  padding: 1.5rem;
  border-radius: 12px;
  background: linear-gradient(145deg, #ffffff, #f1f5f9);
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.reporting-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

.reporting-item label {
  font-size: 0.95rem;
  color: var(--text-light);
  display: block;
  margin-bottom: 0.75rem;
}

.reporting-item span {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  background: linear-gradient(to right, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.orders-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.order-card {
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 2rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.order-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

.order-header {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.order-type {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.3s ease;
}

.order-type.SALE {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.2));
  color: var(--success);
}

.order-type.RETURN {
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.2));
  color: var(--danger);
}

.order-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  table-layout: fixed;
}

.order-table th,
.order-table td {
  padding: 14px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 14px;
}

.order-table th {
  font-weight: 600;
  color: var(--text-light);
  background: var(--light-bg);
}

.order-table td {
  color: var(--text);
}

.order-table th:nth-child(1),
.order-table td:nth-child(1) { width: 15%; }
.order-table th:nth-child(2),
.order-table td:nth-child(2) { width: 30%; }
.order-table th:nth-child(3),
.order-table td:nth-child(3) { width: 10%; text-align: center; }
.order-table th:nth-child(4),
.order-table td:nth-child(4) { width: 15%; text-align: right; }
.order-table th:nth-child(5),
.order-table td:nth-child(5) { width: 15%; text-align: right; }
.order-table th:nth-child(6),
.order-table td:nth-child(6) { width: 15%; text-align: center; }
.order-table th:nth-child(7),
.order-table td:nth-child(7) { width: 10%; text-align: center; }

/* SKU-Spalte: Kürzung auf max. 7 Zeichen mit Tooltip für vollständigen Text */
.order-table td:nth-child(1) {
  position: relative;
  overflow: hidden;
}

.order-table td:nth-child(1)::before {
  content: attr(data-sku-full);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: inline-block;
  max-width: 7ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: help;
  z-index: 1;
}

.order-table td:nth-child(1)::after {
  content: attr(data-sku-full);
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  white-space: nowrap;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
  max-width: 200px;
  text-align: center;
}

.order-table td:nth-child(1):hover::after {
  opacity: 1;
  visibility: visible;
}

/* Responsive Anpassung: Auf Mobilgeräten Tooltip deaktivieren und mehr Platz geben */
@media (max-width: 768px) {
  .order-table td:nth-child(1)::before {
    max-width: none;
  }
  
  .order-table td:nth-child(1)::after {
    display: none;
  }
  
  .order-table th:nth-child(1),
  .order-table td:nth-child(1) {
    min-width: 100px;
  }
}

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

.order-table tr:hover {
  background: rgba(37, 99, 235, 0.05);
}

.order-table .return-btn {
  padding: 0.375rem 0.75rem;
  border: none;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--danger), #dc2626);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
  text-align: center;
}

.order-table .return-btn:hover {
  background: linear-gradient(90deg, #dc2626, #b91c1c);
}

.type-label {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.type-label.SALE {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.2));
  color: var(--success);
}

.type-label.RETURN {
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.2));
  color: var(--danger);
}

.loading, .no-orders {
  text-align: center;
  color: var(--text-light);
  font-size: 1rem;
  padding: 2rem;
}

.rmi {
  padding: 3rem;
  color: var(--text-light);
  font-size: 1.1rem;
  font-style: italic;
}

/* Query Container and Button */
.query-container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  background: var(--light-bg);
  margin-top: 8px;
}

.query-input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: white;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  max-width: 200px;
}

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

.query-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
}

.query-btn:hover {
  background: linear-gradient(90deg, var(--primary-dark), var(--accent-dark));
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Responsive Design */
@media (max-width: 768px) {
  .card form, #user-panel {
    padding: 1rem;
    max-width: 95%;
  }

  .card .row {
    flex-direction: column;
    gap: 0.75rem;
  }

  .card .row button {
    width: 100%;
  }

  #periodControls {
    flex-direction: column;
    align-items: stretch;
  }

  #periodControls button {
    width: 100%;
    text-align: center;
  }

  #periodControls .custom-period {
    flex-direction: column;
    align-items: stretch;
  }

  #periodControls input[type="date"],
  #periodControls button[onclick="setCustomPeriod()"] {
    width: 100%;
    max-width: none;
  }

  #periodControls .period-label-container {
    justify-content: center;
  }

  .query-container {
    flex-direction: column;
    align-items: stretch;
  }

  .query-input,
  .query-btn {
    width: 100%;
    max-width: none;
  }

  .reporting-grid {
    grid-template-columns: 1fr;
  }

  .order-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .order-table th,
  .order-table td {
    min-width: 120px;
  }

  .order-table .return-btn {
    width: auto;
    min-width: 80px;
  }

  .order-header {
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 12px;
  }
}