/* KOMATSU製造ライン見える化システム カスタムスタイル */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans JP', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
}

/* テキスト選択の無効化 */
.no-select {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* タッチ対応ボタンスタイル */
button {
  touch-action: manipulation;
  cursor: pointer;
  border: none;
  outline: none;
  position: relative;
  overflow: hidden;
}

button:active {
  transform: scale(0.98);
}

/* リップル効果 */
button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transition: width 0.3s, height 0.3s, top 0.3s, left 0.3s;
  transform: translate(-50%, -50%);
  z-index: 1;
  pointer-events: none;
}

button:active::before {
  width: 300px;
  height: 300px;
}

/* 品番ボタンのスタイル */
.product-type-btn {
  min-height: 100px;
  transition: all 0.3s ease;
}

.product-type-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* 工程セルのスタイル */
.process-cell {
  min-width: 80px;
  min-height: 60px;
  transition: all 0.2s ease;
}

.process-cell:hover {
  background-color: #f3f4f6 !important;
  transform: scale(1.05);
}

.process-cell:active {
  transform: scale(0.95);
}

/* 製造番号行のホバー効果 */
.manufacturing-item-row {
  transition: all 0.2s ease;
}

.manufacturing-item-row:hover {
  background-color: #f9fafb !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 優先度に応じた行のスタイル */
.manufacturing-item-row[data-priority="2"] {
  background-color: #fef2f2; /* 最高優先度 - 薄い赤 */
}

.manufacturing-item-row[data-priority="1"] {
  background-color: #fffbeb; /* 高優先度 - 薄い黄色 */
}

/* 進捗バーのアニメーション */
.progress-bar {
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 通知スタイル */
.notification {
  opacity: 0;
  transform: translateX(100%);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border-left: 4px solid currentColor;
  max-width: 400px;
  word-wrap: break-word;
}

/* モーダルスタイル */
#detail-modal {
  backdrop-filter: blur(4px);
}

/* 時計スタイル */
#clock {
  font-family: 'Courier New', monospace;
  letter-spacing: 1px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

/* テーブルの改善 */
table {
  border-collapse: collapse;
}

th, td {
  border-bottom: 1px solid #e5e7eb;
}

th {
  background-color: #f9fafb;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 10;
}

/* スクロールバーのカスタマイズ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a1a1a1;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  /* モバイル用のボタンサイズ調整 */
  button {
    min-height: 48px;
    padding: 12px 16px;
  }
  
  input {
    min-height: 48px;
    padding: 12px;
    font-size: 16px; /* iOS の自動ズーム防止 */
  }
  
  /* 品番ボタンのサイズ調整 */
  .product-type-btn {
    min-height: 80px;
    padding: 12px;
  }
  
  /* テーブルの横スクロール */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* ヘッダーの調整 */
  header h1 {
    font-size: 1.125rem;
  }
  
  /* モーダルの調整 */
  #detail-modal .bg-white {
    margin: 16px;
    max-height: calc(100vh - 32px);
  }
}

/* タブレット横向き対応 */
@media (max-height: 500px) and (orientation: landscape) {
  header {
    padding: 8px 0;
  }
  
  .py-6 {
    padding-top: 16px;
    padding-bottom: 16px;
  }
  
  .mb-6 {
    margin-bottom: 16px;
  }
  
  .p-6 {
    padding: 16px;
  }
}

/* 高コントラストモード対応 */
@media (prefers-contrast: high) {
  .bg-white {
    background-color: #ffffff;
    border: 1px solid #000000;
  }
  
  .text-gray-600 {
    color: #000000;
  }
  
  .border-gray-200 {
    border-color: #000000;
  }
}

/* アニメーション無効化対応 */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 印刷対応 */
@media print {
  .no-print {
    display: none !important;
  }
  
  header {
    background-color: #ffffff !important;
    color: #000000 !important;
    box-shadow: none !important;
  }
  
  .bg-yellow-400 {
    background-color: #ffffff !important;
    border-bottom: 2px solid #000000 !important;
  }
  
  button {
    display: none;
  }
  
  table {
    border-collapse: collapse;
    width: 100%;
  }
  
  th, td {
    border: 1px solid #000000 !important;
    padding: 8px;
  }
}

/* KOMATSUブランドカラー */
.komatsu-yellow {
  background-color: #FFD700;
}

.komatsu-yellow-dark {
  background-color: #FFC000;
}

/* 緊急度に応じた色分け */
.urgent-delivery {
  animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
  0% { background-color: transparent; }
  50% { background-color: rgba(239, 68, 68, 0.1); }
  100% { background-color: transparent; }
}

/* ローディング状態 */
.loading {
  position: relative;
}

.loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  margin: auto;
  border: 3px solid transparent;
  border-top-color: #3B82F6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* アクセシビリティ向上 */
button:focus,
input:focus,
select:focus {
  outline: 2px solid #3B82F6;
  outline-offset: 2px;
}

/* ツールチップスタイル */
[title] {
  position: relative;
}

/* 状態表示のバッジ */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* 優先度バッジのアニメーション */
.priority-high {
  animation: priority-pulse 3s infinite;
}

@keyframes priority-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* データなし状態のスタイル */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #6B7280;
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* 成功・エラー状態 */
.success-state {
  border: 2px solid #10B981 !important;
  background-color: rgba(16, 185, 129, 0.1) !important;
}

.error-state {
  border: 2px solid #EF4444 !important;
  background-color: rgba(239, 68, 68, 0.1) !important;
}