/* ═══════════════════════════════════════════════════════════════
   TD-TMS — App-Specific Styles
   Uses ALMAS Design System tokens from almas-design.css
   ═══════════════════════════════════════════════════════════════ */

/* ─── Local tokens ─── */
:root {
  --tms-yellow: var(--almas-yellow, #FDC400);
  --tms-yellow-dark: #c49a00;
  --tms-success: #3f916c;
  --tms-info-bg: #fffbe6;
  --tms-info-border: var(--almas-yellow, #FDC400);
}

/* ─── ORDERS TOOLBAR ─── */
.orders-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  gap: var(--space-md);
}

/* ─── ORDER TABS ─── */
.order-tabs {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.order-tab {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  border-bottom: 2px solid transparent;
}

.order-tab:hover { background: var(--border-secondary); }

.order-tab.active {
  background: var(--bg-secondary);
  border-color: var(--border-secondary);
  border-bottom-color: var(--almas-red);
  color: var(--almas-red);
  font-weight: 600;
}

/* ─── ORDER CARDS ─── */
.order-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-secondary);
  border-left: 4px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
  cursor: default;
}

.order-card:hover { box-shadow: var(--shadow-md); }
.order-card.status-entwurf { border-left-color: var(--warning); }
.order-card.status-neu { border-left-color: var(--success); }

.order-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-sm);
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.order-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.order-card-meta {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.order-card-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.order-card-actions .almas-btn { font-size: 13px; }

/* ─── STATUS BADGES ─── */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}

.status-badge.entwurf { background: var(--warning-bg); color: #92400e; }
.status-badge.neu { background: var(--success-bg); color: #166534; }

/* ─── ORDERS EMPTY ─── */
.orders-empty {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  color: var(--text-tertiary);
}

.orders-empty svg {
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

/* ─── FORM SECTIONS ─── */
.section {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-secondary);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
}

.section-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--almas-red);
  border-bottom: 2px solid var(--almas-red-border);
  padding-bottom: var(--space-sm);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.section-title .num {
  background: var(--almas-red);
  color: var(--text-inverse);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

/* ─── FORM ELEMENTS ─── */
.form-group { margin-bottom: var(--space-md); }

.form-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: var(--space-xs);
  color: var(--text-primary);
}

.form-group label .required { color: var(--almas-red); }

input[type="text"], input[type="email"], input[type="tel"],
input[type="number"], select, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: var(--font-family);
  color: var(--text-primary);
  background: var(--bg-secondary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--almas-red);
  box-shadow: 0 0 0 3px var(--almas-red-light);
}

input::placeholder, textarea::placeholder { color: var(--text-tertiary); }
textarea { resize: vertical; min-height: 60px; }

.file-input {
  padding: var(--space-sm);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  width: 100%;
}

/* ─── INFO BUTTON + TOOLTIP ─── */
.info-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--tms-yellow);
  color: var(--text-primary);
  border: none;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.info-btn:hover { background: var(--tms-yellow-dark); color: var(--text-inverse); }

.info-tooltip {
  display: none;
  position: absolute;
  left: 24px;
  top: -4px;
  background: var(--tms-info-bg);
  border: 1px solid var(--tms-info-border);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: 12px;
  font-weight: 400;
  color: var(--text-primary);
  width: 280px;
  z-index: 100;
  box-shadow: var(--shadow-md);
  line-height: 1.4;
}

.info-btn:hover .info-tooltip,
.info-btn:focus .info-tooltip { display: block; }

/* ─── RADIO / CHECKBOX ─── */
.radio-group {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-xs);
  flex-wrap: wrap;
}

.radio-group label {
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 6px 12px;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.radio-group label:has(input:checked) {
  border-color: var(--almas-red);
  background: var(--almas-red-light);
}

.radio-group input[type="radio"] { accent-color: var(--almas-red); }

.checkbox-label { font-weight: 400 !important; cursor: pointer; }
input[type="checkbox"] { accent-color: var(--almas-red); width: 16px; height: 16px; }

/* ─── LAYOUT HELPERS ─── */
.row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }

.conditional {
  display: none;
  margin-top: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--almas-red-border);
}

.conditional.show { display: block; }

.conditional-inline {
  margin-top: var(--space-sm);
  padding: 10px 14px;
  background: var(--tms-info-bg);
  border: 1px solid var(--tms-info-border);
  border-radius: var(--radius-sm);
}

/* ─── BSSID Info boxes ─── */
.bssid-info {
  margin-top: 6px;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.bssid-info-success {
  background: #e8f5e9;
  border: 1px solid var(--tms-success);
}

.bssid-info-warning {
  background: #fff3e0;
  border: 1px solid var(--warning);
}

/* ─── GERAET ROWS ─── */
.geraet-row-inner {
  display: flex;
  align-items: flex-end;
  gap: var(--space-md);
}

.geraet-type-col { flex: 2; }
.geraet-count-col { flex: 1; }
.geraet-action-col { flex: 0 0 auto; }

.geraet-row + .geraet-row .geraet-row-inner {
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px dashed var(--border-primary);
}

.add-geraet-btn,
.remove-geraet-btn {
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 20px;
  cursor: pointer;
  margin-bottom: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.add-geraet-btn {
  background: var(--almas-red);
  color: var(--text-inverse);
}

.add-geraet-btn:hover { background: var(--almas-red-hover); }

.remove-geraet-btn {
  background: var(--text-secondary);
  color: var(--text-inverse);
}

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

/* ─── INDIVIDUAL PROGRAMMING SECTION ─── */
.prog-individual-section {
  margin-top: var(--space-md);
  padding: var(--space-md);
  border: 2px solid var(--almas-red);
  border-radius: var(--radius-md);
  background: rgba(208, 19, 23, 0.03);
}

.prog-individual-section h4 {
  margin: 0 0 var(--space-md);
  color: var(--almas-red);
  font-size: 15px;
  font-weight: 600;
}

/* ─── FORM ACTIONS ─── */
.actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  margin-top: var(--space-lg);
  flex-wrap: wrap;
}

/* ─── MESSAGES ─── */
.tms-message {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
  font-weight: 600;
  text-align: center;
  display: none;
}

.tms-message.success {
  display: block;
  background: var(--success-bg);
  color: var(--tms-success);
  border: 1px solid var(--tms-success);
}

.tms-message.error {
  display: block;
  background: var(--danger-bg);
  color: var(--almas-red);
  border: 1px solid var(--almas-red);
}

/* ─── VERTRIEB INFO ─── */
.vertrieb-info {
  background: var(--tms-info-bg);
  border: 1px solid var(--tms-info-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
  font-size: 13px;
}

.vertrieb-info strong { color: var(--text-primary); }

/* ─── AUTOCOMPLETE ─── */
.autocomplete-wrap { position: relative; }

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: var(--shadow-lg);
  display: none;
}

.autocomplete-list.show { display: block; }

.autocomplete-item {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 1px solid var(--border-secondary);
  transition: background var(--transition-fast);
}

.autocomplete-item:hover,
.autocomplete-item.active { background: var(--almas-red-light); }

.autocomplete-item .ac-name { font-weight: 600; }
.autocomplete-item .ac-email { color: var(--text-tertiary); font-size: 12px; margin-left: var(--space-sm); }

/* ─── SPINNER ─── */
.spinner {
  display: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--text-inverse);
  border-top: 2px solid transparent;
  border-radius: 50%;
  animation: almas-spin 0.8s linear infinite;
}

/* ─── FILE ATTACHMENT PREVIEW ─── */
.attachment-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 6px 10px;
  background: var(--info-bg);
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-xs);
  font-size: 13px;
}

.attachment-item .file-size { color: var(--text-tertiary); }

/* ═══ FORM STEPPER ═══ */
#formStepper {
  position: sticky;
  top: var(--header-height);
  z-index: 90;
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--almas-red-border);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-lg);
  padding: 10px var(--space-lg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-secondary);
}

.stepper-inner {
  display: flex;
  align-items: flex-start;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.stepper-inner::-webkit-scrollbar { display: none; }

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
  min-width: 60px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  user-select: none;
}

.step-item:hover { background: rgba(0, 0, 0, 0.04); }

.step-circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--border-primary);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  transition: background 0.3s, box-shadow 0.3s, transform 0.2s;
  flex-shrink: 0;
}

.step-item.active .step-circle {
  background: var(--almas-red);
  box-shadow: 0 0 0 3px var(--almas-red-light);
  transform: scale(1.12);
}

.step-item.done .step-circle { background: var(--tms-success); }

.step-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-tertiary);
  margin-top: 4px;
  text-align: center;
  white-space: nowrap;
  transition: color 0.2s;
}

.step-item.active .step-label { color: var(--almas-red); font-weight: 700; }
.step-item.done .step-label { color: var(--tms-success); }

.step-connector {
  flex: 1 1 8px;
  min-width: 8px;
  height: 2px;
  background: var(--border-secondary);
  margin-top: 19px;
  transition: background 0.3s;
  align-self: flex-start;
}

.step-connector.done { background: var(--tms-success); }

/* ═══ RESPONSIVE — Tablet ═══ */
@media (max-width: 1024px) {
  .row { grid-template-columns: 1fr; }
}

/* ═══ RESPONSIVE — Mobile ═══ */
@media (max-width: 768px) {
  .section { padding: 18px 14px; }
  .section-title { font-size: 16px; }

  .radio-group { flex-wrap: wrap; gap: var(--space-sm); }

  #formStepper {
    padding: 8px 12px;
    border-radius: var(--radius-md);
    -webkit-overflow-scrolling: touch;
  }

  .step-circle { width: 26px; height: 26px; font-size: 11px; }
  .step-label { font-size: 9px; }
  .step-item { min-width: 52px; padding: 4px 3px; }
  .step-connector { margin-top: 17px; min-width: 6px; }

  .actions { flex-direction: column; align-items: stretch; }
  .actions .almas-btn { justify-content: center; }

  .info-tooltip {
    left: auto;
    right: 0;
    top: 24px;
    width: 240px;
  }

  .geraet-row-inner { flex-wrap: wrap; }
  .geraet-type-col { flex: 1 1 100%; }
  .geraet-count-col { flex: 1; }

  .order-card { padding: var(--space-md); }
  .order-card-header { flex-direction: column; }
  .order-card-meta { flex-direction: column; gap: var(--space-xs); }
  .order-card-actions { flex-direction: column; }
  .order-card-actions .almas-btn { width: 100%; text-align: center; justify-content: center; }

  .orders-toolbar { flex-direction: column; align-items: stretch; }
  .orders-toolbar .almas-btn { text-align: center; justify-content: center; }
}

/* ═══ RESPONSIVE — Small phone ═══ */
@media (max-width: 480px) {
  .section { padding: 14px 10px; border-radius: var(--radius-md); }
  .section-title { font-size: 15px; gap: 6px; }
  .section-title .num { width: 24px; height: 24px; font-size: 12px; }

  input[type="text"], input[type="email"], input[type="tel"],
  input[type="number"], select, textarea {
    padding: 8px 10px;
    font-size: 16px !important;
  }

  .radio-group label { padding: 5px 8px; font-size: 13px; }

  #formStepper { padding: 6px 8px; }
  .step-circle { width: 22px; height: 22px; font-size: 10px; }
  .step-label { font-size: 8px; }
  .step-item { min-width: 42px; padding: 2px; }
  .step-connector { margin-top: 15px; min-width: 4px; }

  .vertrieb-info { padding: 10px 12px; font-size: 12px; }
}
