/* QB-Produktion: integrierte Bildschirmtastatur für Touch- und Kiosk-Terminals. */

.touch-keyboard[hidden],
.touch-keyboard-launcher[hidden] {
  display: none !important;
}

.touch-keyboard {
  position: fixed;
  z-index: 1200;
  inset: auto 0 0;
  max-height: 46vh;
  padding: 10px max(10px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  border-top: 2px solid #d7813a;
  background: #f0f3f1f7;
  box-shadow: 0 -12px 34px #07150f45;
  backdrop-filter: blur(12px);
}

.touch-keyboard-head {
  max-width: 1180px;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.touch-keyboard-head > div {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.touch-keyboard-head strong { font-size: 14px; }
.touch-keyboard-head small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.touch-keyboard-head button {
  flex: 0 0 42px;
  width: 42px;
  min-height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 26px;
}

.touch-keyboard-keys {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  gap: 6px;
}

.touch-keyboard.numeric .touch-keyboard-keys { max-width: 620px; }

.touch-keyboard-row {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.touch-key {
  flex: 1 1 0;
  min-width: 0;
  min-height: 46px;
  padding: 4px 6px;
  border: 1px solid #cbd5cf;
  border-radius: 9px;
  background: #fff;
  color: #17231f;
  box-shadow: 0 2px 0 #aebbb4;
  font: inherit;
  font-size: clamp(15px, 2vw, 20px);
  font-weight: 750;
  touch-action: manipulation;
  user-select: none;
}

.touch-key:hover,
.touch-key:focus-visible {
  border-color: #d7813a;
  background: #fff7ef;
  outline: none;
}

.touch-key:active {
  transform: translateY(2px);
  box-shadow: none;
}

.touch-key.wide { flex-grow: 1.65; }
.touch-key.double { flex-grow: 2.1; }
.touch-key.space { flex-grow: 4; }
.touch-key.accent { background: #e7eee9; }
.touch-key.primary { border-color: #176b4b; background: #176b4b; color: #fff; }
.touch-key.active { border-color: #d7813a; background: #f5b478; color: #24150b; }

.touch-keyboard-launcher {
  position: fixed;
  z-index: 1190;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 15px;
  border: 1px solid #d7813a;
  border-radius: 14px;
  background: #176b4b;
  color: #fff;
  box-shadow: 0 9px 28px #07150f55;
  font: inherit;
}

.touch-keyboard-open .app-content { padding-bottom: min(46vh, 360px); }

[data-touch-keyboard-toggle].active > span:first-child {
  background: #d7813a;
  color: #1a1511;
}

.topbar [data-touch-keyboard-toggle] { margin-left: 0; }

html[data-theme="dark"] .touch-keyboard {
  background: #181715f5;
  border-top-color: #d4772b;
  box-shadow: 0 -12px 34px #000a;
}

html[data-theme="dark"] .touch-keyboard-head button,
html[data-theme="dark"] .touch-key {
  border-color: #514b45;
  background: #302e2a;
  color: #f4f0e9;
  box-shadow: 0 2px 0 #0e0d0c;
}

html[data-theme="dark"] .touch-key:hover,
html[data-theme="dark"] .touch-key:focus-visible { background: #453429; border-color: #d4772b; }
html[data-theme="dark"] .touch-key.accent { background: #3b3935; }
html[data-theme="dark"] .touch-key.primary { background: #b75d21; border-color: #db7c36; }
html[data-theme="dark"] .touch-key.active { background: #d4772b; color: #17100b; }

@media (max-width: 960px) {
  .topbar [data-touch-keyboard-toggle] small { display: none; }
}

@media (max-width: 760px), (max-height: 650px) {
  .touch-keyboard { max-height: 52vh; padding-top: 6px; }
  .touch-keyboard-head { margin-bottom: 5px; }
  .touch-keyboard-head small { display: none; }
  .touch-keyboard-keys, .touch-keyboard-row { gap: 4px; }
  .touch-key { min-height: 40px; padding: 2px 3px; border-radius: 7px; font-size: 14px; }
  .touch-keyboard-open .app-content { padding-bottom: 52vh; }
}

@media print {
  .touch-keyboard,
  .touch-keyboard-launcher,
  [data-touch-keyboard-toggle] { display: none !important; }
}
