/* CURA 受注管理システム - カスタムスタイル */

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: #f8fafc;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ナビゲーション */
.nav-header {
  background: #fff;
  border-bottom: 2px solid #e2e8f0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  position: sticky;
  top: 0;
  z-index: 100;
}

/* カード */
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  border: 1px solid #e8edf2;
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

/* 症例カード - 不足あり */
.case-card-missing {
  border-left: 4px solid #ef4444;
  background: #fff;
}

/* 症例カード - 完了 */
.case-card-complete {
  border-left: 4px solid #22c55e;
  background: #fff;
}

/* 症例カード - 進行中 */
.case-card-progress {
  border-left: 4px solid #3b82f6;
  background: #fff;
}

/* バッジ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-red { background: #fee2e2; color: #dc2626; }
.badge-green { background: #dcfce7; color: #16a34a; }
.badge-blue { background: #dbeafe; color: #2563eb; }
.badge-yellow { background: #fef9c3; color: #ca8a04; }
.badge-gray { background: #f1f5f9; color: #64748b; }

/* チェックボックス カスタム */
.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid #e2e8f0;
  margin-bottom: 6px;
  background: #fff;
}

.check-item:hover {
  background: #f0f9ff;
}

.check-item.checked {
  background: #f0fdf4;
  border-color: #86efac;
}

.check-item.checked .check-label {
  color: #166534;
}

.check-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  cursor: pointer;
  accent-color: #16a34a;
}

/* 無効チェックアイテム */
.check-item-disabled {
  opacity: 0.38;
  pointer-events: none;
  background: #f1f5f9 !important;
  border-color: #e2e8f0 !important;
}

/* 模型タイプ選択 */
.model-type-selector {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 14px;
}

.model-type-btns {
  gap: 8px;
}

.model-type-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 20px;
  border: 2px solid #e2e8f0;
  background: #fff;
  color: #475569;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.model-type-btn:hover {
  border-color: #2563eb;
  color: #2563eb;
  background: #eff6ff;
}

.model-type-btn.active {
  border-color: #2563eb;
  background: #2563eb;
  color: #fff;
}

.model-type-none.active {
  border-color: #94a3b8;
  background: #94a3b8;
  color: #fff;
}

/* シェード写真なしトグル */
.shade-none-toggle {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  padding: 10px 14px;
}

.shade-none-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.shade-none-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #ea580c;
  cursor: pointer;
}

/* ボタン */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: #2563eb;
  color: white;
}

.btn-primary:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.btn-success {
  background: #16a34a;
  color: white;
}

.btn-success:hover {
  background: #15803d;
}

.btn-danger {
  background: #dc2626;
  color: white;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-secondary {
  background: #f1f5f9;
  color: #374151;
  border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-outline {
  background: transparent;
  border: 1.5px solid #2563eb;
  color: #2563eb;
}

.btn-outline:hover {
  background: #dbeafe;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 13px 24px;
  font-size: 1rem;
}

/* フォーム */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 5px;
}

.form-label .required {
  color: #ef4444;
  margin-left: 3px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
}

.form-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input.error {
  border-color: #ef4444;
}

.form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
  padding-right: 40px;
}

.form-select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ファイルドロップゾーン */
.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #f8fafc;
}

.dropzone:hover, .dropzone.dragover {
  border-color: #3b82f6;
  background: #eff6ff;
}

.dropzone i {
  font-size: 2.5rem;
  color: #94a3b8;
  margin-bottom: 12px;
}

.dropzone.dragover i {
  color: #3b82f6;
}

/* ファイルリスト */
.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 6px;
  background: #fff;
}

.file-item .file-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

/* モーダル */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(2px);
}

@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
  }
}

.modal-content {
  background: #fff;
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  padding: 20px 16px;
  animation: slideUp 0.2s ease;
}

@media (min-width: 640px) {
  .modal-content {
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    animation: scaleIn 0.2s ease;
  }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* アラート */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
}

.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #16a34a;
}

.alert-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #d97706;
}

.alert-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #2563eb;
}

/* ローディングスピナー */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-dark {
  border: 2px solid rgba(0,0,0,0.1);
  border-top-color: #2563eb;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* テーブル */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* トースト通知 */
.toast-container {
  position: fixed;
  top: 80px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
}

.toast {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: toastIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast-success { background: #16a34a; color: white; }
.toast-error { background: #dc2626; color: white; }
.toast-warning { background: #d97706; color: white; }
.toast-info { background: #2563eb; color: white; }

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

/* ステータスバー（モバイル） */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  cursor: pointer;
  transition: all 0.15s;
  color: #94a3b8;
  font-size: 0.65rem;
  font-weight: 600;
  gap: 3px;
}

.bottom-nav-item.active {
  color: #2563eb;
}

.bottom-nav-item i {
  font-size: 1.2rem;
}

/* ページコンテナ（ボトムナビ分のパディング） */
.page-container {
  padding-bottom: 70px;
  min-height: 100vh;
}

@media (min-width: 768px) {
  .page-container {
    padding-bottom: 0;
  }
  .bottom-nav {
    display: none;
  }
}

/* 欠損バッジ */
.missing-count {
  background: #ef4444;
  color: white;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

/* ステータス指示 */
.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-indicator.green { background: #22c55e; }
.status-indicator.red { background: #ef4444; }
.status-indicator.yellow { background: #eab308; }
.status-indicator.blue { background: #3b82f6; }

/* 検索バー */
.search-bar {
  position: relative;
}

.search-bar input {
  padding-left: 42px;
}

.search-bar .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
}

/* アニメーション */
.fade-in {
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 納期切れ強調 */
.overdue {
  color: #dc2626;
  font-weight: 700;
}

/* 今日の納期 */
.due-today {
  color: #d97706;
  font-weight: 700;
}

/* プログレスバー */
.progress-bar {
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* iPhone safe area対応 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
  }
  .page-container {
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
  }
}

/* タブ */
.tab-group {
  display: flex;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 20px;
  gap: 0;
}

.tab-item {
  padding: 10px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  color: #64748b;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: all 0.15s;
}

.tab-item.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
}

.tab-item:hover:not(.active) {
  color: #374151;
  background: #f8fafc;
}

/* 資料チェック グリッド */
.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@media (min-width: 480px) {
  .check-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* ===== 歯式入力UI ===== */

.work-builder {
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px;
  background: #fafbfc;
}

.tooth-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tooth-jaw-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tooth-jaw-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
}

.tooth-select {
  font-size: 0.85rem;
  padding: 8px 10px;
}

/* 歯式グリッド */
.tooth-grid-wrap {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 8px;
  margin-bottom: 10px;
}

.tooth-arch-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #94a3b8;
  text-align: center;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.tooth-grid {
  margin-bottom: 8px;
}

.tooth-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.tooth-side-label {
  font-size: 0.65rem;
  color: #94a3b8;
  width: 18px;
  text-align: center;
  font-weight: 600;
}

.tooth-divider {
  color: #94a3b8;
  font-size: 1.1rem;
  font-weight: 300;
  margin: 0 2px;
  line-height: 1;
}

.tooth-btn {
  width: 30px;
  height: 30px;
  border-radius: 5px;
  border: 1.5px solid #cbd5e1;
  background: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  color: #374151;
  cursor: pointer;
  transition: all 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}

.tooth-btn:hover {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #2563eb;
}

.tooth-btn.selected {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  box-shadow: 0 2px 4px rgba(37,99,235,0.3);
}

@media (max-width: 400px) {
  .tooth-btn {
    width: 26px;
    height: 26px;
    font-size: 0.72rem;
  }
}

/* 選択中の歯式表示 */
.selected-teeth-row {
  min-height: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin-bottom: 8px;
}

.selected-tooth-chip {
  background: #dbeafe;
  color: #1d4ed8;
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid #bfdbfe;
}

.selected-tooth-chip:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

/* 登録済み技工内容エントリー */
.work-entries {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.work-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #15803d;
}

.work-entry .remove-btn {
  margin-left: auto;
  color: #94a3b8;
  cursor: pointer;
  font-size: 0.9rem;
  background: none;
  border: none;
  padding: 2px 4px;
  line-height: 1;
  flex-shrink: 0;
}

.work-entry .remove-btn:hover {
  color: #dc2626;
}

/* 技工内容プレビュー */
.work-preview {
  font-size: 0.875rem;
  color: #374151;
  padding: 8px 10px;
  background: #f8fafc;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  margin-top: 6px;
  white-space: pre-wrap;
}

/* ===== カレンダー ===== */

.cal-grid-wrap {
  overflow: hidden;
  border-radius: 12px;
}

.cal-dow-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
}

.cal-dow {
  text-align: center;
  padding: 8px 2px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.04em;
}

.cal-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-top: 1px solid #f1f5f9;
}

.cal-day {
  min-height: 76px;
  padding: 5px 5px 4px;
  border-right: 1px solid #f1f5f9;
  border-bottom: 1px solid #f1f5f9;
  cursor: default;
  transition: box-shadow 0.15s, filter 0.15s;
  background: #fff;
  position: relative;
  overflow: hidden;
}

.cal-day-empty {
  background: #fafbfc;
  cursor: default;
}

.cal-day-has-cases {
  cursor: pointer;
}

.cal-day-has-cases:hover {
  filter: brightness(0.95);
  box-shadow: inset 0 0 0 2px rgba(37,99,235,0.35);
}

.cal-day-selected {
  box-shadow: inset 0 0 0 2.5px #2563eb !important;
  filter: brightness(0.96);
}

.cal-day-today {
  box-shadow: inset 0 0 0 2px #2563eb;
}

.cal-day-sun .cal-day-num { color: #dc2626; }
.cal-day-sat .cal-day-num { color: #2563eb; }

.cal-day-num {
  font-size: 0.8rem;
  font-weight: 700;
  color: #374151;
  line-height: 1;
  margin-bottom: 3px;
}

.cal-today-num {
  background: #2563eb;
  color: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
}

.cal-day-count {
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(0,0,0,0.55);
  line-height: 1;
  margin-bottom: 2px;
}

.cal-day-clinics {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cal-clinic-chip {
  display: block;
  font-size: 0.6rem;
  font-weight: 600;
  color: rgba(0,0,0,0.7);
  background: rgba(255,255,255,0.55);
  border-radius: 3px;
  padding: 1px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  backdrop-filter: blur(2px);
}

.cal-clinic-more {
  font-size: 0.6rem;
  color: rgba(0,0,0,0.5);
  font-weight: 600;
  padding-left: 2px;
}

/* カレンダー詳細行 */
.cal-detail-row {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #fff;
  transition: background 0.15s;
}

.cal-detail-row:hover {
  background: #f8fafc;
}

.cal-detail-missing {
  border-left: 3px solid #ef4444;
}

.cal-detail-done {
  border-left: 3px solid #22c55e;
  opacity: 0.75;
}

/* スマホ対応 */
@media (max-width: 480px) {
  .cal-day {
    min-height: 58px;
    padding: 3px 3px 3px;
  }
  .cal-day-num {
    font-size: 0.72rem;
  }
  .cal-today-num {
    width: 17px;
    height: 17px;
    font-size: 0.65rem;
  }
  .cal-day-count {
    font-size: 0.58rem;
  }
  .cal-clinic-chip {
    font-size: 0.55rem;
    padding: 1px 3px;
  }
}

/* 印刷スタイル */
@media print {
  .bottom-nav, .btn, .nav-header { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
