/* 施工管理システム カスタムスタイル */

/* カラーテーマ */
:root {
  --primary: #1e40af;
  --primary-light: #3b82f6;
  --accent: #f97316;
  --success: #16a34a;
  --warning: #ca8a04;
  --danger: #dc2626;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-700: #374151;
  --gray-800: #1f2937;
}

/* ベース */
* { box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', sans-serif; }

/* ローディングアニメーション */
.loading-spinner {
  display: inline-block;
  width: 1.5rem; height: 1.5rem;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ステータスバッジ */
.status-badge {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 9999px;
  font-size: 0.75rem; font-weight: 600;
}
.status-planning { background: #dbeafe; color: #1d4ed8; }
.status-in_progress { background: #dcfce7; color: #15803d; }
.status-completed { background: #f3f4f6; color: #4b5563; }
.status-cancelled { background: #fee2e2; color: #b91c1c; }

/* ロールバッジ */
.role-admin { background: #fef3c7; color: #b45309; }
.role-sales { background: #ede9fe; color: #7c3aed; }
.role-worker { background: #d1fae5; color: #065f46; }

/* サイドバー */
.sidebar {
  width: 240px; min-height: 100vh;
  background: linear-gradient(180deg, #1e3a5f 0%, #1e40af 100%);
  position: fixed; left: 0; top: 0; z-index: 50;
  transition: transform 0.3s ease;
}
.sidebar-nav-item {
  display: flex; align-items: center;
  padding: 0.75rem 1.25rem;
  color: rgba(255,255,255,0.75);
  border-radius: 0.5rem; margin: 2px 8px;
  transition: all 0.2s; cursor: pointer;
  text-decoration: none; font-size: 0.875rem;
}
.sidebar-nav-item:hover, .sidebar-nav-item.active {
  background: rgba(255,255,255,0.15); color: white;
}
.sidebar-nav-item i { width: 1.25rem; margin-right: 0.75rem; }

/* メインコンテンツ */
.main-content { margin-left: 240px; min-height: 100vh; }

/* モバイル対応 */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-overlay { display: block !important; }
}

/* カード */
.card {
  background: white; border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  padding: 1.25rem;
}

/* 現場カード */
.site-card {
  background: white; border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 1rem 1.25rem;
  border-left: 4px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}
.site-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.15); transform: translateY(-1px); }
.site-card.in_progress { border-left-color: #16a34a; }
.site-card.planning { border-left-color: #3b82f6; }
.site-card.completed { border-left-color: #9ca3af; }
.site-card.cancelled { border-left-color: #dc2626; }

/* チャットUI */
.chat-container { height: calc(100vh - 280px); overflow-y: auto; }
.chat-bubble {
  max-width: 75%; padding: 0.625rem 0.875rem;
  border-radius: 1rem; margin-bottom: 0.5rem;
  font-size: 0.9rem; line-height: 1.5;
}
.chat-bubble.mine {
  background: #1d4ed8; color: white;
  border-bottom-right-radius: 0.25rem;
  margin-left: auto;
}
.chat-bubble.theirs {
  background: white; color: #1f2937;
  border-bottom-left-radius: 0.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.chat-bubble.line-source { border: 2px solid #00c300; }

/* ファイルグリッド */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
}
.file-item {
  border-radius: 0.5rem; overflow: hidden;
  border: 1px solid #e5e7eb;
  cursor: pointer; transition: all 0.2s;
  background: white;
}
.file-item:hover { border-color: #3b82f6; box-shadow: 0 2px 8px rgba(59,130,246,0.2); }
.file-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; background: #f3f4f6; }
.file-thumb-placeholder {
  width: 100%; aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  background: #f3f4f6; font-size: 2rem; color: #9ca3af;
}

/* カレンダーイベント */
.cal-event {
  border-radius: 4px; padding: 2px 6px;
  font-size: 0.75rem; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.cal-event.in_progress { background: #dcfce7; color: #15803d; border-left: 3px solid #16a34a; }
.cal-event.planning { background: #dbeafe; color: #1d4ed8; border-left: 3px solid #3b82f6; }
.cal-event.completed { background: #f3f4f6; color: #4b5563; border-left: 3px solid #9ca3af; }

/* モーダル */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(2px);
}
.modal-overlay > div {
  background: #ffffff !important;
  border-radius: 1rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 8px 25px rgba(0, 0, 0, 0.15);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  z-index: 101;
}
.modal-box {
  background: #ffffff;
  border-radius: 1rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 640px; width: 100%;
  max-height: 90vh; overflow-y: auto;
}

/* モーダル内の共通スタイル */
.modal-overlay > div h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 1rem;
}
.modal-overlay > div .form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.375rem;
}
.modal-overlay > div .form-input {
  background: #ffffff;
}
.modal-overlay > div select.form-input {
  background: #ffffff;
  -webkit-appearance: auto;
  appearance: auto;
}
.form-input {
  width: 100%; border: 1px solid #d1d5db;
  border-radius: 0.5rem; padding: 0.625rem 0.75rem;
  font-size: 0.875rem; transition: border-color 0.2s;
  outline: none;
}
.form-input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.form-label { display: block; font-size: 0.8rem; font-weight: 500; color: #374151; margin-bottom: 0.375rem; }

/* ボタン */
.btn { display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.5rem 1rem; border-radius: 0.5rem; font-size: 0.875rem; font-weight: 500; cursor: pointer; transition: all 0.2s; border: none; }
.btn-primary { background: #1d4ed8; color: white; }
.btn-primary:hover { background: #1e40af; }
.btn-secondary { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }
.btn-secondary:hover { background: #e5e7eb; }
.btn-success { background: #16a34a; color: white; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: #dc2626; color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }

/* タブ */
.tabs { display: flex; border-bottom: 2px solid #e5e7eb; }
.tab-btn { padding: 0.625rem 1rem; font-size: 0.875rem; font-weight: 500; color: #6b7280; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; }
.tab-btn.active { color: #1d4ed8; border-bottom-color: #1d4ed8; }
.tab-btn:hover { color: #374151; }

/* ドラッグアンドドロップ */
.drop-zone {
  border: 2px dashed #d1d5db; border-radius: 0.75rem;
  padding: 2rem; text-align: center; cursor: pointer;
  transition: all 0.2s;
}
.drop-zone:hover, .drop-zone.dragover { border-color: #3b82f6; background: #eff6ff; }

/* 通知バナー */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 200;
  padding: 0.75rem 1.25rem; border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}
.toast-success { background: #16a34a; color: white; }
.toast-error { background: #dc2626; color: white; }
.toast-info { background: #1d4ed8; color: white; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* リスト */
.list-item { padding: 0.75rem 1rem; border-bottom: 1px solid #f3f4f6; }
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: #f9fafb; }

/* アバター */
.avatar { width: 2rem; height: 2rem; border-radius: 50%; background: #3b82f6; color: white; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 600; }

/* 進捗バー */
.progress-bar { height: 6px; background: #e5e7eb; border-radius: 9999px; overflow: hidden; }
.progress-fill { height: 100%; background: #3b82f6; border-radius: 9999px; transition: width 0.3s; }

/* 空状態 */
.empty-state { text-align: center; padding: 3rem 1rem; color: #9ca3af; }
.empty-state i { font-size: 3rem; margin-bottom: 1rem; display: block; }
