/* ═══════════════════════════════════════════════════════════════
   TD-TMS — App-Schicht (v2, 2026-08-06)
   App-spezifische Komponenten auf dem geteilten ALMAS-Doku-Design-System
   (td-tms-doku.css = Basis, td-tms-theme.css = v2-Optik, td-tms-mobile.css = Touch).
   Zuletzt laden. Nutzt ausschließlich die --almas-*-Tokens der Basis.
   ═══════════════════════════════════════════════════════════════ */

/* ─── Lokale Akzente ─── */
:root{
  --tms-yellow:#FDC400;
  --tms-yellow-dark:#c49a00;
  --tms-success:#147A3D;
  --tms-info-bg:#FFFBEB;
  --tms-info-border:#FDC400;
}

/* ─── Login-/Redirect-Screen ─── */
.redirect-note{
  display:flex; align-items:center; justify-content:center; gap:10px;
  margin-top:22px; font-size:14px; color:var(--almas-text-secondary);
}
.tp-spinner{
  width:18px; height:18px; flex:0 0 auto;
  border:2px solid var(--almas-border-strong); border-top-color:var(--almas-red-hover);
  border-radius:50%; animation:tms-spin .8s linear infinite;
}
@keyframes tms-spin{ to{ transform:rotate(360deg); } }

/* ─── Mobile Top-Bar + Hamburger (kein separater Mobile-View) ─── */
.mobile-topbar{
  display:none;
  align-items:center; gap:12px;
  padding:10px 16px;
  background:var(--almas-surface); border-bottom:1px solid var(--almas-border);
  position:sticky; top:0; z-index:120;
}
.mobile-topbar img{ height:22px; }
.mobile-topbar .mt-title{ font-size:15px; font-weight:700; color:var(--almas-text); }
.menu-toggle{
  background:transparent; border:none; color:var(--almas-text);
  cursor:pointer; padding:6px; display:inline-flex; border-radius:8px;
}
.menu-toggle:hover{ background:var(--almas-bg-alt); }
.menu-overlay{
  display:none; position:fixed; inset:0; background:rgba(16,17,22,.42);
  z-index:190;
}
.menu-overlay.show{ display:block; }

/* ─── ALMAS-Button-Familie auf doku-Optik (Alt-Klassen aus dem Bestand) ─── */
.almas-btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  padding:10px 18px; border-radius:10px; border:1px solid transparent;
  font-family:inherit; font-size:14px; font-weight:600; cursor:pointer;
  transition:transform .15s, box-shadow .15s, background .15s, color .15s;
  text-decoration:none; line-height:1.2;
}
.almas-btn:hover{ transform:translateY(-1px); }
.almas-btn:active{ transform:translateY(0); }
.almas-btn-sm{ padding:6px 12px; font-size:13px; border-radius:8px; }
.almas-btn-primary{
  background:var(--almas-red-hover); color:#fff;
  box-shadow:0 8px 20px rgba(255,35,37,.26);
}
.almas-btn-primary:hover{ background:var(--almas-red); box-shadow:0 12px 26px rgba(255,35,37,.34); }
.almas-btn-secondary{
  background:var(--almas-surface); color:var(--almas-text);
  border-color:var(--almas-border-strong); box-shadow:var(--almas-shadow);
}
.almas-btn-secondary:hover{ background:var(--almas-bg-alt); }
.almas-btn-ghost{ background:transparent; color:var(--almas-text); }
.almas-btn-ghost:hover{ background:var(--almas-bg-alt); }
.almas-btn-danger{
  background:var(--almas-surface); color:#C20F1C; border-color:rgba(194,15,28,.32);
}
.almas-btn-danger:hover{ background:#C20F1C; color:#fff; border-color:#C20F1C; }
.almas-btn[disabled]{ opacity:.55; cursor:not-allowed; transform:none; }

/* ─── ORDERS: Toolbar + Tabs ─── */
.orders-toolbar{
  display:flex; justify-content:space-between; align-items:center;
  margin-bottom:20px; flex-wrap:wrap; gap:12px;
}
.orders-toolbar .text-h2{ font-size:20px; font-weight:700; letter-spacing:-.01em; color:var(--almas-text); margin:0; }

.order-tabs{ display:flex; gap:8px; margin-bottom:18px; flex-wrap:wrap; }
.order-tab{
  background:var(--almas-surface); border:1px solid var(--almas-border-strong);
  border-radius:999px; padding:7px 16px; cursor:pointer; font-size:13px; font-weight:600;
  color:var(--almas-text-secondary); transition:all .15s;
}
.order-tab:hover{ background:var(--almas-bg-alt); }
.order-tab.active{
  background:rgba(255,35,37,.10); border-color:transparent;
  color:var(--almas-red-hover); font-weight:700;
}

/* ─── ORDER CARDS ─── */
#ordersList{ display:grid; grid-template-columns:repeat(auto-fill,minmax(320px,1fr)); gap:16px; }
.order-card{
  background:var(--almas-surface); border:1px solid var(--almas-border);
  border-left:4px solid var(--almas-border-strong);
  border-radius:var(--radius); padding:18px 20px;
  box-shadow:var(--almas-shadow);
  transition:transform .18s, box-shadow .18s;
  display:flex; flex-direction:column; gap:10px;
}
.order-card:hover{ transform:translateY(-2px); box-shadow:var(--almas-shadow-lg); }
.order-card.status-entwurf{ border-left-color:#8A5A00; }
.order-card.status-neu{ border-left-color:#147A3D; }
.order-card-header{
  display:flex; justify-content:space-between; align-items:flex-start; gap:10px; flex-wrap:wrap;
}
.order-card-title{ font-size:16px; font-weight:700; color:var(--almas-text); letter-spacing:-.01em; word-break:break-word; }
.order-card-meta{
  font-size:13px; color:var(--almas-text-secondary);
  display:flex; gap:16px; flex-wrap:wrap;
}
.order-card-meta b{ color:var(--almas-text); font-weight:600; }
.order-card-actions{
  display:flex; gap:8px; flex-wrap:wrap;
  padding-top:12px; border-top:1px solid var(--almas-border);
}

/* ─── Status-Badges ─── */
.status-badge{
  display:inline-block; padding:3px 11px; border-radius:999px;
  font-size:12px; font-weight:700; white-space:nowrap;
}
.status-badge.entwurf{ background:#FBF1DD; color:#8A5A00; }
.status-badge.neu{ background:#DDF5E5; color:#147A3D; }

/* ─── Empty-State ─── */
.orders-empty{
  grid-column:1/-1; text-align:center; padding:56px 20px;
  color:var(--almas-text-muted); font-size:14px;
}

/* ═══════════════ FORMULAR ═══════════════ */
.section{
  background:var(--almas-surface); border:1px solid var(--almas-border);
  border-radius:var(--radius); padding:24px; margin-bottom:16px;
  box-shadow:var(--almas-shadow);
}
.section-title{
  font-size:13px; font-weight:800; text-transform:uppercase; letter-spacing:.04em;
  color:var(--almas-red-hover); margin:0 0 18px;
  display:flex; align-items:center; gap:10px;
}
.section-title .num{
  background:var(--almas-red-hover); color:#fff;
  width:26px; height:26px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-size:13px; font-weight:700; flex-shrink:0;
}

.form-group{ margin-bottom:16px; }
.form-group label{
  display:flex; align-items:center; gap:6px;
  font-weight:600; font-size:13px; margin-bottom:6px; color:var(--almas-text);
}
.form-group label .required{ color:var(--almas-red-hover); }

input[type="text"], input[type="email"], input[type="tel"],
input[type="number"], select, textarea{
  width:100%; padding:10px 12px;
  border:1px solid var(--almas-border-strong); border-radius:var(--radius-sm);
  font-size:14px; font-family:inherit; color:var(--almas-text);
  background:var(--almas-surface);
  transition:border-color .15s, box-shadow .15s; outline:none; -webkit-appearance:none;
}
input:focus, select:focus, textarea:focus{
  border-color:var(--almas-red); box-shadow:0 0 0 3px rgba(255,35,37,.14);
}
input::placeholder, textarea::placeholder{ color:var(--almas-text-muted); }
textarea{ resize:vertical; min-height:64px; }
.file-input{ padding:8px; border:1px dashed var(--almas-border-strong); border-radius:var(--radius-sm); width:100%; background:var(--almas-bg-alt); }

/* ─── Info-Button + Tooltip ─── */
.info-btn{
  width:18px; height:18px; border-radius:50%;
  background:var(--tms-yellow); color:#1a1400; border:none;
  font-size:11px; font-weight:800; 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:#fff; }
.info-tooltip{
  display:none; position:absolute; left:24px; top:-4px;
  background:var(--almas-surface); border:1px solid var(--almas-border-strong);
  border-radius:var(--radius-sm); padding:10px 12px;
  font-size:12px; font-weight:400; color:var(--almas-text);
  width:280px; z-index:100; box-shadow:var(--almas-shadow-lg); line-height:1.45;
}
.info-btn:hover .info-tooltip, .info-btn:focus .info-tooltip{ display:block; }

/* ─── Radio / Checkbox ─── */
.radio-group{ display:flex; gap:10px; margin-top:6px; flex-wrap:wrap; }
.radio-group label{
  font-weight:500; display:flex; align-items:center; gap:8px; cursor:pointer;
  padding:8px 14px; border:1px solid var(--almas-border-strong); border-radius:var(--radius-sm);
  transition:all .15s; margin:0;
}
.radio-group label:has(input:checked){
  border-color:var(--almas-red); background:rgba(255,35,37,.06); color:var(--almas-red-hover); font-weight:600;
}
.radio-group input[type="radio"]{ accent-color:var(--almas-red-hover); }
.checkbox-label{ font-weight:500 !important; cursor:pointer; }
input[type="checkbox"]{ accent-color:var(--almas-red-hover); width:17px; height:17px; }

/* ─── Layout-Helfer ─── */
.row{ display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.conditional{
  display:none; margin-top:10px; padding:14px;
  background:var(--almas-bg-alt); border-radius:var(--radius-sm);
  border-left:3px solid var(--almas-red);
}
.conditional.show{ display:block; }
.conditional-inline{
  margin-top:10px; padding:11px 14px;
  background:var(--tms-info-bg); border:1px solid var(--tms-info-border);
  border-radius:var(--radius-sm); font-size:13px;
}

/* ─── BSSID-Boxen ─── */
.bssid-info{ margin-top:8px; padding:10px 14px; border-radius:var(--radius-sm); font-size:13px; }
.bssid-info-success{ background:#DDF5E5; border:1px solid var(--tms-success); }
.bssid-info-warning{ background:#FBF1DD; border:1px solid #8A5A00; }

/* ─── Geräte-Zeilen ─── */
.geraet-row-inner{ display:flex; align-items:flex-end; gap:14px; }
.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:12px; padding-top:12px; border-top:1px dashed var(--almas-border-strong);
}
.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 .15s;
}
.add-geraet-btn{ background:var(--almas-red-hover); color:#fff; }
.add-geraet-btn:hover{ background:var(--almas-red); }
.remove-geraet-btn{ background:var(--almas-text-muted); color:#fff; }
.remove-geraet-btn:hover{ background:var(--almas-text); }

/* ─── Individuelle Programmierung ─── */
.prog-individual-section{
  margin-top:14px; padding:16px; border:1.5px solid var(--almas-red);
  border-radius:var(--radius-md); background:rgba(255,35,37,.03);
}
.prog-individual-section h4{ margin:0 0 14px; color:var(--almas-red-hover); font-size:14px; font-weight:700; }

/* ─── Aktionen ─── */
.actions{
  display:flex; gap:12px; justify-content:flex-end; margin-top:20px; flex-wrap:wrap;
}

/* ─── Meldungen ─── */
.tms-message{
  padding:14px 16px; border-radius:var(--radius-md); margin-bottom:18px;
  font-weight:600; text-align:center; display:none;
}
.tms-message.success{ display:block; background:#DDF5E5; color:#147A3D; border:1px solid var(--tms-success); }
.tms-message.error{ display:block; background:#FCE3E3; color:#C20F1C; border:1px solid #C20F1C; }
.tms-message.warning{ display:block; background:#FBF1DD; color:#8A5A00; border:1px solid #8A5A00; }

/* ─── Vertriebs-Hinweis ─── */
.vertrieb-info{
  background:var(--tms-info-bg); border:1px solid var(--tms-info-border);
  border-radius:var(--radius-md); padding:14px 16px; margin-bottom:18px; font-size:13px;
  color:var(--almas-text);
}
.vertrieb-info strong{ color:var(--almas-text); }

/* ─── Autocomplete ─── */
.autocomplete-wrap{ position:relative; }
.autocomplete-list{
  position:absolute; top:100%; left:0; right:0;
  background:var(--almas-surface); border:1px solid var(--almas-border-strong); border-top:none;
  border-radius:0 0 var(--radius-sm) var(--radius-sm);
  max-height:220px; overflow-y:auto; z-index:50; box-shadow:var(--almas-shadow-lg); display:none;
}
.autocomplete-list.show{ display:block; }
.autocomplete-item{
  padding:10px 12px; cursor:pointer; font-size:14px;
  border-bottom:1px solid var(--almas-border); transition:background .15s;
}
.autocomplete-item:hover, .autocomplete-item.active{ background:rgba(255,35,37,.06); }
.autocomplete-item .ac-name{ font-weight:600; }
.autocomplete-item .ac-email{ color:var(--almas-text-muted); font-size:12px; margin-left:8px; }

/* ─── Spinner (Button) ─── */
.spinner{
  display:none; width:18px; height:18px;
  border:2px solid rgba(255,255,255,.6); border-top:2px solid transparent;
  border-radius:50%; animation:tms-spin .8s linear infinite;
}

/* ─── Datei-Anhänge ─── */
.attachment-item{
  display:flex; align-items:center; gap:8px; padding:7px 11px;
  background:var(--almas-bg-alt); border:1px solid var(--almas-border);
  border-radius:var(--radius-sm); margin-top:8px; font-size:13px;
}
.attachment-item .file-size{ color:var(--almas-text-muted); }

/* ═══════════════ STEPPER ═══════════════ */
#formStepper{
  position:sticky; top:0; z-index:90;
  background:var(--almas-surface); border:1px solid var(--almas-border);
  box-shadow:var(--almas-shadow); margin-bottom:18px; padding:10px 16px;
  border-radius:var(--radius);
}
.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 .15s; user-select:none;
}
.step-item:hover{ background:var(--almas-bg-alt); }
.step-circle{
  width:30px; height:30px; border-radius:50%;
  background:var(--almas-border-strong); color:#fff;
  display:flex; align-items:center; justify-content:center; font-size:13px; font-weight:700;
  transition:background .3s, box-shadow .3s, transform .2s; flex-shrink:0;
}
.step-item.active .step-circle{ background:var(--almas-red-hover); box-shadow:0 0 0 3px rgba(255,35,37,.14); transform:scale(1.12); }
.step-item.done .step-circle{ background:var(--tms-success); }
.step-label{
  font-size:10px; font-weight:600; color:var(--almas-text-muted);
  margin-top:4px; text-align:center; white-space:nowrap; transition:color .2s;
}
.step-item.active .step-label{ color:var(--almas-red-hover); 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(--almas-border);
  margin-top:19px; transition:background .3s; align-self:flex-start;
}
.step-connector.done{ background:var(--tms-success); }

/* ═══════════════ ALMA-CHAT ═══════════════ */
.chat-bubble{
  position:fixed; bottom:24px; right:24px; width:56px; height:56px; border-radius:50%;
  background:var(--almas-red-hover); color:#fff; border:none; cursor:pointer; font-size:24px;
  box-shadow:0 10px 26px rgba(255,35,37,.30); z-index:400;
  display:flex; align-items:center; justify-content:center; transition:transform .15s;
}
.chat-bubble:hover{ transform:translateY(-2px) scale(1.05); }
.chat-window{
  position:fixed; bottom:90px; right:24px; width:380px; height:520px;
  background:var(--almas-surface); border-radius:var(--radius);
  box-shadow:var(--almas-shadow-lg); z-index:400;
  display:none; flex-direction:column; overflow:hidden; border:1px solid var(--almas-border);
}
.chat-window.open{ display:flex; }
.chat-header{ background:var(--almas-red-hover); color:#fff; padding:14px 16px; display:flex; align-items:center; justify-content:space-between; }
.chat-header .title{ font-weight:700; font-size:15px; }
.chat-header .close-btn{ background:none; border:none; color:rgba(255,255,255,.7); cursor:pointer; font-size:20px; padding:0; line-height:1; transition:color .15s; }
.chat-header .close-btn:hover{ color:#fff; }
.chat-messages{ flex:1; overflow-y:auto; padding:16px; display:flex; flex-direction:column; gap:10px; }
.chat-msg{ max-width:85%; padding:10px 14px; border-radius:var(--radius-md); font-size:13px; line-height:1.5; word-wrap:break-word; }
.chat-msg.user{ align-self:flex-end; background:var(--almas-red-hover); color:#fff; border-bottom-right-radius:4px; }
.chat-msg.bot{ align-self:flex-start; background:var(--almas-bg-alt); color:var(--almas-text); border-bottom-left-radius:4px; }
.chat-msg.bot p{ margin:0 0 6px; }
.chat-msg.bot p:last-child{ margin-bottom:0; }
.chat-msg.bot ul,.chat-msg.bot ol{ margin:4px 0 6px; padding-left:18px; }
.chat-msg.bot li{ margin:2px 0; }
.chat-msg.bot code{ background:rgba(0,0,0,.06); padding:1px 5px; border-radius:4px; font-size:12px; }
.chat-msg.bot a{ color:var(--almas-red-hover); text-decoration:underline; }
.chat-msg.bot .typing span{ animation:tms-blink 1.4s infinite; display:inline-block; }
.chat-msg.bot .typing span:nth-child(2){ animation-delay:.2s; }
.chat-msg.bot .typing span:nth-child(3){ animation-delay:.4s; }
@keyframes tms-blink{ 0%,60%,100%{ opacity:.3; } 30%{ opacity:1; } }
.chat-input-area{ padding:12px; border-top:1px solid var(--almas-border); display:flex; gap:8px; }
.chat-input-area input{ flex:1; padding:10px 14px; border:1px solid var(--almas-border-strong); border-radius:999px; font-size:13px; font-family:inherit; outline:none; color:var(--almas-text); background:var(--almas-surface); }
.chat-input-area input:focus{ border-color:var(--almas-red); box-shadow:0 0 0 3px rgba(255,35,37,.14); }
.chat-input-area button{ background:var(--almas-red-hover); color:#fff; border:none; border-radius:50%; width:38px; height:38px; cursor:pointer; font-size:16px; display:flex; align-items:center; justify-content:center; transition:background .15s; }
.chat-input-area button:hover{ background:var(--almas-red); }

/* ─── Version-Badge (Sidebar) ─── */
#appVersion{ cursor:pointer; }

/* ─── Toasts (almas-auth.js) ─── */
.almas-toast-container{ position:fixed; bottom:96px; right:24px; z-index:600; display:flex; flex-direction:column; gap:8px; }
.almas-toast{
  display:flex; align-items:center; gap:9px; padding:12px 16px; min-width:240px; max-width:360px;
  background:var(--almas-surface); color:var(--almas-text); border-radius:12px;
  box-shadow:0 12px 40px rgba(16,17,22,.16); font-size:14px; font-weight:500;
  border-left:3px solid var(--almas-text-muted);
}
.almas-toast span{ font-weight:700; }
.almas-toast-success{ border-left-color:#147A3D; } .almas-toast-success span{ color:#147A3D; }
.almas-toast-error{ border-left-color:#C20F1C; } .almas-toast-error span{ color:#C20F1C; }
.almas-toast-warning{ border-left-color:#8A5A00; } .almas-toast-warning span{ color:#8A5A00; }
.almas-toast-info{ border-left-color:#0057B8; } .almas-toast-info span{ color:#0057B8; }

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

@media (max-width:900px){
  /* Sidebar wird zum Off-Canvas-Drawer, Mobile-Top-Bar erscheint */
  .view-app{ grid-template-columns:1fr; }
  .mobile-topbar{ display:flex; }
  .sidebar{
    position:fixed; top:0; left:0; height:100vh; width:260px; z-index:200;
    transform:translateX(-100%); transition:transform .25s ease;
  }
  .sidebar.open{ transform:translateX(0); box-shadow:var(--almas-shadow-lg); }
  .content{ padding:18px 16px 40px; }
  #formStepper{ top:52px; }
  #ordersList{ grid-template-columns:1fr; }
  .chat-window{ width:calc(100vw - 32px); right:16px; bottom:80px; height:62vh; }
}

@media (max-width:768px){
  .section{ padding:18px 14px; }
  .actions{ flex-direction:column; align-items:stretch; }
  .actions .almas-btn{ width:100%; }
  .info-tooltip{ left:auto; right:0; top:24px; width:240px; }
  .geraet-row-inner{ flex-wrap:wrap; }
  .geraet-type-col{ flex:1 1 100%; }
  .order-card-actions .almas-btn{ flex:1; }
  .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; }
}

@media (max-width:480px){
  .section{ padding:14px 11px; border-radius:var(--radius-md); }
  /* iOS zoomt bei <16px → Pflicht 16px auf Handy */
  input[type="text"], input[type="email"], input[type="tel"],
  input[type="number"], select, textarea{ font-size:16px; padding:12px 14px; }
  .radio-group label{ padding:10px 12px; font-size:14px; min-height:44px; }
  #formStepper{ padding:8px 10px; }
  .step-circle{ width:22px; height:22px; font-size:10px; }
  .step-label{ font-size:8px; }
  .step-item{ min-width:42px; padding:2px; }
}

@media (prefers-reduced-motion:reduce){
  .almas-btn,.order-card,.chat-bubble,.step-circle{ transition:none!important; }
  .almas-btn:hover,.order-card:hover,.chat-bubble:hover{ transform:none!important; }
}
