/**
 * Enhanced Mobile CSS - PharmacyHomeCare System v0.1.1
 * 音声・リアルタイム機能のモバイル最適化
 */

/* 拡張機能ツールバーのモバイル対応 */
#enhanced-toolbar {
  bottom: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

@media (max-width: 768px) {
  #enhanced-toolbar {
    bottom: 0.5rem;
    right: 0.5rem;
    flex-direction: row;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 1.5rem;
    padding: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  }
  
  #enhanced-toolbar button {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
  }
}

/* 音声可視化のモバイル対応 */
.voice-visualizer {
  width: 100%;
  max-width: 300px;
  height: 60px;
  border-radius: 8px;
  background: #f3f4f6;
}

@media (max-width: 768px) {
  .voice-visualizer {
    height: 50px;
    max-width: 250px;
  }
}

/* 音声入力ボタンのモバイル対応 */
.voice-input-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px) {
  .voice-input-btn {
    right: 0.75rem;
    padding: 0.5rem;
  }
  
  .voice-input-btn i {
    font-size: 1rem;
  }
}

/* リアルタイム通知のモバイル対応 */
#realtime-notifications {
  top: 1rem;
  right: 1rem;
  max-width: calc(100vw - 2rem);
  z-index: 9999;
}

@media (max-width: 768px) {
  #realtime-notifications {
    top: 0.5rem;
    right: 0.5rem;
    left: 0.5rem;
    max-width: none;
  }
}

.notification-toast {
  animation: slideInRight 0.3s ease-out;
  touch-action: manipulation;
}

@media (max-width: 768px) {
  .notification-toast {
    animation: slideInDown 0.3s ease-out;
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideInDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ステータスバーのモバイル対応 */
#enhanced-status {
  font-size: 0.75rem;
  padding: 0.5rem 1rem;
}

@media (max-width: 768px) {
  #enhanced-status {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    flex-direction: column;
    gap: 0.25rem;
  }
  
  #enhanced-status > div {
    justify-content: center;
  }
}

/* QRスキャナーパネルのモバイル対応 */
#qr-scanner .grid {
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  #qr-scanner .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

#scanner-video {
  max-height: 250px;
  object-fit: cover;
}

@media (max-width: 768px) {
  #scanner-video {
    max-height: 200px;
  }
}

/* 処方箋フォームのモバイル対応 */
#prescription-form .grid {
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 768px) {
  #prescription-form .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }
}

/* 音声入力フィールドのラッパー調整 */
.voice-input-wrapper {
  position: relative;
}

.voice-input-wrapper input,
.voice-input-wrapper textarea {
  padding-right: 2.5rem;
}

@media (max-width: 768px) {
  .voice-input-wrapper input,
  .voice-input-wrapper textarea {
    padding-right: 3rem;
  }
}

/* タッチデバイス用の拡張ヒット領域 */
@media (pointer: coarse) {
  button, .voice-input-btn, [onclick] {
    min-height: 44px;
    min-width: 44px;
  }
}

/* プレゼンスインジケーターのモバイル対応 */
#presence-indicator {
  padding: 0.75rem;
  margin-top: 1rem;
}

@media (max-width: 768px) {
  #presence-indicator {
    padding: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
  }
}

/* オンラインユーザーリストのモバイル最適化 */
#online-users {
  max-height: 150px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  #online-users {
    max-height: 100px;
  }
}

/* チャットトグルボタンのモバイル対応 */
#chat-toggle {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#chat-badge {
  min-width: 1rem;
  height: 1rem;
  font-size: 0.6rem;
  line-height: 1;
}

/* 接続ステータスインジケーターのモバイル対応 */
#connection-status {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  min-height: 2.5rem;
}

@media (max-width: 768px) {
  #connection-status {
    min-width: 2rem;
    min-height: 2rem;
  }
}

/* デバッグモード表示の調整 */
.debug-info {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 1rem;
  border-radius: 0.5rem;
  max-width: 90vw;
  max-height: 80vh;
  overflow: auto;
  z-index: 10000;
  font-family: monospace;
  font-size: 0.75rem;
}

/* ローディング状態のアニメーション改善 */
.voice-recording-animation {
  position: relative;
}

.voice-recording-animation::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Accessibility improvements for mobile */
@media (prefers-reduced-motion: reduce) {
  .notification-toast,
  .voice-recording-animation::after {
    animation: none;
  }
  
  .notification-toast {
    transition: opacity 0.2s ease;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  #enhanced-toolbar {
    background: white;
    border: 2px solid black;
  }
  
  .notification-toast {
    border: 2px solid black;
  }
  
  .voice-input-btn {
    border: 1px solid currentColor;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  #enhanced-toolbar {
    background: rgba(31, 41, 55, 0.95);
    color: white;
  }
  
  .notification-toast {
    background: #374151;
    color: white;
  }
  
  .voice-visualizer {
    background: #4b5563;
  }
  
  #enhanced-status {
    background: #1f2937;
    color: white;
  }
}