/* Tastiera virtuale iPad-like */
.vk-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom, 0);
  /* Migliora performance animazioni */
  will-change: opacity;
  -webkit-tap-highlight-color: transparent;
}

/* Supporto riduzione movimento */
@media (prefers-reduced-motion: reduce) {
  .vk-overlay,
  .vk-key {
    transition: none !important;
    animation: none !important;
  }
  .vk-key:active {
    transform: none !important;
  }
}

.vk-modal {
  background: linear-gradient(180deg, #d1d5db 0%, #c5c9cf 100%);
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
  padding: 8px 4px 12px 4px;
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vk-modal--ipad {
  background: linear-gradient(180deg, #d1d5db 0%, #c5c9cf 100%);
}

/* Preview testo digitato */
.vk-preview {
  background: #fff;
  border-radius: 8px;
  padding: 12px 16px;
  margin: 4px 8px 8px 8px;
  font-size: 1.3rem;
  font-weight: 500;
  color: #1c1c1e;
  text-align: center;
  min-height: 24px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
  word-break: break-all;
}

.vk-preview--placeholder {
  color: #8e8e93;
  font-weight: 400;
}

.vk-row {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 0 4px;
}

.vk-key {
  flex: 1;
  min-width: 28px;
  max-width: 42px;
  height: 46px;
  font-size: 1.25rem;
  font-weight: 400;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
  border: none;
  border-radius: 6px;
  background: #fff;
  color: #1c1c1e;
  box-shadow: 0 1px 0 rgba(0,0,0,0.35), 0 1px 3px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: transform 0.08s, background 0.08s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
  /* Previeni selezione testo */
  -webkit-touch-callout: none;
}

.vk-key:active {
  background: #a8a8a8;
  transform: scale(1.15);
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Tasto Shift */
.vk-key--shift {
  flex: 1.3;
  max-width: 52px;
  background: #aeb3bb;
  font-size: 1.4rem;
}

.vk-key--shift.vk-key--active {
  background: #fff;
  color: #007aff;
}

/* Tasto Backspace */
.vk-key--backspace {
  flex: 1.3;
  max-width: 52px;
  background: #aeb3bb;
  font-size: 1.3rem;
}

/* Tasto Spazio */
.vk-key--space {
  flex: 4 !important;
  max-width: none !important;
  background: #fff;
  color: #8e8e93;
  font-size: 1rem;
  text-transform: lowercase;
}

/* Tasto Fine/Done */
.vk-key--done {
  flex: 1.5 !important;
  max-width: 80px !important;
  background: linear-gradient(180deg, #007aff 0%, #0066d6 100%);
  color: #fff;
  font-weight: 500;
  font-size: 1rem;
}

.vk-key--done:active {
  background: linear-gradient(180deg, #0066d6 0%, #004eb3 100%);
}

/* Tasti modalità (123, ABC, #+=) */
.vk-key--mode {
  flex: 1.2;
  max-width: 56px;
  background: #aeb3bb;
  font-size: 0.95rem;
  font-weight: 500;
}

/* Responsive per tablet/kiosk 7" */
@media (min-width: 500px) {
  .vk-modal {
    max-width: 600px;
    border-radius: 12px;
    margin-bottom: 20px;
    padding: 10px 8px 16px 8px;
  }
  
  .vk-key {
    height: 52px;
    max-width: 48px;
    font-size: 1.4rem;
  }
  
  .vk-key--shift,
  .vk-key--backspace {
    max-width: 60px;
  }
  
  .vk-key--mode {
    max-width: 65px;
  }
}

/* Responsive per schermi più grandi */
@media (min-width: 768px) {
  .vk-overlay {
    align-items: center;
  }
  
  .vk-modal {
    max-width: 650px;
    border-radius: 16px;
    padding: 12px 10px 18px 10px;
    margin-bottom: 0;
  }
  
  .vk-key {
    height: 56px;
    max-width: 52px;
    font-size: 1.5rem;
    border-radius: 8px;
  }
  
  .vk-row {
    gap: 8px;
  }
}
