/**
 * Virtual Floating Keyboard Stylesheet
 * Touchscreen On-Screen Keyboard (OSK) for POS Terminal
 * 
 * @module pos_core
 * @file   frontend/assets/css/virtual_keyboard.css
 */

/* ── Floating Keyboard Container ── */
#virtual-floating-keyboard {
  position: fixed;
  z-index: 99999;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 820px;
  max-width: 96vw;
  padding: 10px 12px 12px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  box-shadow: 0 20px 60px -10px rgba(0, 0, 0, 0.6),
              0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  font-family: 'Outfit', 'Battambang', 'Hanuman', system-ui, -apple-system, sans-serif;
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#virtual-floating-keyboard.vk-hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

/* Light Theme Support */
body.light-theme #virtual-floating-keyboard,
.light-theme #virtual-floating-keyboard {
  background: rgba(241, 245, 249, 0.92);
  border: 1px solid rgba(203, 213, 225, 0.9);
  box-shadow: 0 20px 50px -10px rgba(15, 23, 42, 0.22),
              0 2px 8px rgba(0, 0, 0, 0.05);
}

/* ── Drag Handle ── */
.vk-drag-handle {
  width: 54px;
  height: 5px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  margin: 0 auto 8px;
  cursor: grab;
  transition: background 0.15s ease, transform 0.15s ease;
}
.vk-drag-handle:hover {
  background: rgba(59, 130, 246, 0.6);
  transform: scaleX(1.15);
}
.vk-drag-handle:active {
  cursor: grabbing;
  background: #3b82f6;
}
body.light-theme .vk-drag-handle,
.light-theme .vk-drag-handle {
  background: rgba(100, 116, 139, 0.35);
}

/* ── Live Preview Bar ── */
.vk-preview-container {
  background: rgba(2, 6, 23, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 6px 12px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25);
  position: relative;
}
body.light-theme .vk-preview-container,
.light-theme .vk-preview-container {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.06);
}

.vk-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 2px;
  min-height: 20px;
}

.vk-preview-label {
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  flex: 1;
  text-align: center;
}
body.light-theme .vk-preview-label,
.light-theme .vk-preview-label {
  color: #64748b;
}

.vk-preview-eye {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: #94a3b8;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.vk-preview-eye:hover {
  background: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
}
.vk-preview-eye:active {
  transform: scale(0.9);
}
body.light-theme .vk-preview-eye {
  background: #f1f5f9;
  color: #64748b;
}
body.light-theme .vk-preview-eye:hover {
  background: #e2e8f0;
  color: #2563eb;
}

.vk-preview-text {
  font-family: 'Outfit', 'Battambang', 'Hanuman', monospace, sans-serif;
  font-size: 17px;
  font-weight: 600;
  color: #f8fafc;
  height: 24px;
  line-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: pre;
  overflow-x: auto;
  max-width: 100%;
  padding: 0 4px;
  scrollbar-width: none;
  cursor: text;
}
.vk-preview-text::-webkit-scrollbar {
  display: none;
}
body.light-theme .vk-preview-text,
.light-theme .vk-preview-text {
  color: #0f172a;
}

/* Interactive Character Spans in Preview Bar */
.vk-char {
  display: inline;
  padding: 0;
  border-radius: 3px;
  cursor: text;
  transition: background 0.1s ease, color 0.1s ease;
  user-select: none;
  -webkit-user-select: none;
}
.vk-char:hover {
  background: rgba(59, 130, 246, 0.25);
  color: #38bdf8;
}
body.light-theme .vk-char:hover {
  background: #dbeafe;
  color: #1d4ed8;
}

/* Blinking Cursor */
.vk-cursor {
  color: #3b82f6;
  font-weight: 800;
  margin: 0 -1px;
  animation: vkBlink 0.9s step-start infinite;
}
@keyframes vkBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ── Keyboard Rows & Keys Grid ── */
.vk-rows-container {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.vk-row {
  display: flex;
  justify-content: center;
  gap: 5px;
}

/* Base Key Style */
.vk-key {
  background: rgba(30, 41, 59, 0.85);
  color: #f8fafc;
  font-family: 'Outfit', 'Battambang', 'Hanuman', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  font-weight: 700;
  height: 38px;
  min-width: 32px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 3px 0 rgba(15, 23, 42, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 1;
  touch-action: manipulation;
  transition: all 0.06s ease-out;
  box-sizing: border-box;
}

.vk-key:hover {
  background: rgba(51, 65, 85, 0.95);
  border-color: rgba(255, 255, 255, 0.2);
}

.vk-key:active,
.vk-key.vk-pressed {
  transform: translateY(2.5px);
  box-shadow: 0 0.5px 0 transparent !important;
}

/* Light Theme Keys */
body.light-theme .vk-key,
.light-theme .vk-key {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  box-shadow: 0 3px 0 #cbd5e1;
}
body.light-theme .vk-key:hover,
.light-theme .vk-key:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

/* ── Special Functional Keys ── */

/* Action / Modifier Keys */
.vk-key-func {
  background: rgba(51, 65, 85, 0.7);
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 700;
}
body.light-theme .vk-key-func,
.light-theme .vk-key-func {
  background: #e2e8f0;
  color: #475569;
  box-shadow: 0 3px 0 #94a3b8;
}

/* Shift / Caps Active Highlight */
.vk-key.vk-active-mod {
  background: #10b981 !important;
  color: #ffffff !important;
  border-color: #059669 !important;
  box-shadow: 0 3px 0 #047857 !important;
}

/* Enter Key (Emerald Action) */
.vk-key-enter {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  font-weight: 800;
  font-size: 14px;
  border-color: #10b981;
  box-shadow: 0 3px 0 #047857;
  flex: 1.5;
}
.vk-key-enter:hover {
  background: linear-gradient(135deg, #059669, #047857);
}

/* Backspace Key */
.vk-key-backspace {
  flex: 1.4;
  font-size: 17px;
}

/* Shift Keys */
.vk-key-shift {
  flex: 1.4;
}

/* Caps Key */
.vk-key-caps {
  flex: 1.2;
}

/* Space Key */
.vk-key-space {
  flex: 4.5;
}

/* Close / Hide Key */
.vk-key-hide {
  background: #ef4444;
  color: #ffffff;
  border-color: #dc2626;
  box-shadow: 0 3px 0 #991b1b;
  font-size: 12.5px;
  flex: 1.2;
}
.vk-key-hide:hover {
  background: #dc2626;
}

/* Arrow Keys */
.vk-key-arrow {
  flex: 0.9;
  font-size: 16px;
}

/* Language Toggle Key */
.vk-key-lang {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #ffffff !important;
  border-color: #6366f1 !important;
  box-shadow: 0 3px 0 #3730a3 !important;
  font-weight: 700;
  font-size: 13px;
  flex: 1.4;
  letter-spacing: 0.3px;
}
.vk-key-lang:hover {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
}
body.light-theme .vk-key-lang,
.light-theme .vk-key-lang {
  background: linear-gradient(135deg, #4f46e5, #3730a3);
  color: #ffffff !important;
  border-color: #4f46e5 !important;
  box-shadow: 0 3px 0 #312e81 !important;
}

/* Khmer Mode Key Typography Enhancements */
#virtual-floating-keyboard.vk-khmer-mode .vk-key {
  font-size: 16px;
  line-height: 1.15;
}
#virtual-floating-keyboard.vk-khmer-mode .vk-key-func {
  font-size: 12px;
}

/* Responsive scaling for compact screens */
@media (max-width: 680px) {
  #virtual-floating-keyboard {
    width: 98vw;
    padding: 8px 6px 10px;
    bottom: 8px;
    border-radius: 16px;
  }
  .vk-key {
    height: 35px;
    min-width: 24px;
    font-size: 13px;
    border-radius: 7px;
  }
  .vk-key-func {
    font-size: 11px;
  }
}

/* ── Trigger Button Component ── */
.vk-trigger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  background: transparent;
  color: #94a3b8;
  border-radius: 8px;
  transition: all 0.2s ease;
}
.vk-trigger-btn:hover {
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.12);
}
.vk-trigger-btn:active {
  transform: scale(0.92);
}
body.light-theme .vk-trigger-btn {
  color: #64748b;
}
body.light-theme .vk-trigger-btn:hover {
  color: #2563eb;
  background: #e2e8f0;
}
