/* ==========================================
   仏壇仏具売上管理システム CSS
   バージョン: v=116000
   ========================================== */

/* ========== リセット & 基本スタイル ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.6;
  min-height: 100vh;
}

/* ========== ヘッダー ========== */
.header {
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  color: white;
  padding: 20px 30px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

.header h1 {
  font-size: 24px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ========== ボタンスタイル ========== */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: white;
}

.btn-primary {
  background: #2196f3;
  color: white;
}

.btn-primary:hover {
  background: #1976d2;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
}

.btn-success {
  background: #4caf50;
  color: white;
}

.btn-success:hover {
  background: #45a049;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.btn-warning {
  background: #ff9800;
  color: white;
}

.btn-warning:hover {
  background: #f57c00;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
}

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

.btn-danger:hover {
  background: #d32f2f;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

.btn-secondary {
  background: #757575;
  color: white;
}

.btn-secondary:hover {
  background: #616161;
  transform: translateY(-2px);
}

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

/* ========== メインコンテナ ========== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* ========== 統計エリア ========== */
.stats-section {
  background: white;
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 25px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.stats-section h2 {
  font-size: 20px;
  margin-bottom: 20px;
  color: #1e3c72;
  display: flex;
  align-items: center;
  gap: 10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 25px;
}

.stat-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
  border-radius: 10px;
  color: white;
  text-align: center;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
  transition: transform 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-5px);
}

.stat-card .stat-value {
  font-size: 32px;
  font-weight: bold;
  margin: 10px 0;
}

.stat-card .stat-label {
  font-size: 14px;
  opacity: 0.9;
}

/* ========== 目標達成エリア ========== */
.goal-section {
  background: white;
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 25px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.goal-input-group {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.goal-input-group input {
  flex: 1;
  min-width: 200px;
  padding: 10px 15px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 16px;
  transition: border-color 0.3s ease;
}

.goal-input-group input:focus {
  outline: none;
  border-color: #2196f3;
}

.achievement-display {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  flex-wrap: wrap;
  gap: 15px;
}

.achievement-text {
  font-size: 18px;
  font-weight: 600;
  color: #1e3c72;
}

.progress-bar {
  width: 100%;
  height: 30px;
  background: #e0e0e0;
  border-radius: 15px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4caf50 0%, #8bc34a 100%);
  transition: width 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 14px;
}

/* ========== 検索エリア ========== */
.search-section {
  background: white;
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 25px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ========== 月切り替えナビゲーション ========== */
.month-navigation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 25px;
  padding: 15px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-month-nav {
  background: white;
  color: #667eea;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-month-nav:hover {
  background: #f5f5f5;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-month-nav:active {
  transform: translateY(0);
}

.current-month-display {
  font-size: 24px;
  font-weight: bold;
  color: white;
  min-width: 160px;
  text-align: center;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.search-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 15px;
}

.search-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-group label {
  font-weight: 600;
  color: #555;
  font-size: 14px;
}

.search-group input,
.search-group select {
  padding: 10px 15px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.3s ease;
}

.search-group input:focus,
.search-group select:focus {
  outline: none;
  border-color: #2196f3;
}

/* ========== テーブルエリア ========== */
.table-section {
  background: white;
  border-radius: 12px;
  padding: 25px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  margin-bottom: 25px;
}

.table-responsive {
  overflow-x: scroll !important;
  -webkit-overflow-scrolling: touch;
}

.table-responsive::-webkit-scrollbar {
  height: 12px;
}

.table-responsive::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.table-responsive::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 10px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
  background: #555;
}

table {
  width: 2600px !important;
  border-collapse: collapse;
  background: white;
}

thead {
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  color: white;
  position: sticky;
  top: 0;
  z-index: 10;
}

th {
  padding: 12px 8px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  border-right: 1px solid rgba(255,255,255,0.2);
}

td {
  padding: 10px 8px;
  border-bottom: 1px solid #e0e0e0;
  font-size: 13px;
  vertical-align: middle;
}

tbody tr {
  transition: background-color 0.2s ease;
}

tbody tr:hover {
  background-color: #f8f9fa;
}

/* ステータス色分け */
tbody tr.status-red {
  background-color: #ffebee !important;
}

tbody tr.status-yellow {
  background-color: #fff9c4 !important;
}

tbody tr.status-blue {
  background-color: #e3f2fd !important;
}

tbody tr.status-green {
  background-color: #e8f5e9 !important;
}

/* ========== モーダル ========== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  overflow-y: auto;
  padding: 20px;
}

.modal.show {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 50px;
}

.modal-content {
  background: white;
  border-radius: 12px;
  max-width: 95%; /* 1200px → 95% に変更して画面幅に合わせる */
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden; /* 横スクロールは子要素に任せる */
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  animation: modalSlideIn 0.3s ease;
  margin-bottom: 50px;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  color: white;
  padding: 20px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 12px 12px 0 0;
}

.modal-header h2 {
  font-size: 22px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: white;
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.modal-close:hover {
  transform: rotate(90deg);
}

.modal-body {
  padding: 30px;
}

/* ========== フォームグリッド ========== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 25px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-weight: 600;
  color: #555;
  font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 10px 15px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #2196f3;
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}

.checkbox-group input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.checkbox-group label {
  cursor: pointer;
  font-weight: 500;
}

  background-color: #d32f2f;
}

.details-table .btn-danger i {
  font-size: 14px;
}
.details-table input:focus,
.details-table select:focus {
  outline: none;
  border-color: #2196f3;
}

.details-table .btn-danger {
  padding: 6px 12px;
  font-size: 12px;
}

/* ========== 計算サマリー ========== */
.calculation-summary {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  margin: 20px 0;
}

.calculation-summary h3 {
  font-size: 18px;
  margin-bottom: 15px;
  color: #1e3c72;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  padding: 10px;
  background: white;
  border-radius: 6px;
  border-left: 4px solid #2196f3;
}

.summary-item strong {
  color: #555;
}

.summary-item span {
  font-weight: 600;
  color: #1e3c72;
}

/* ========== チェックリスト ========== */
.checklist-section {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  margin: 20px 0;
}

.checklist-section h3 {
  font-size: 16px;
  margin-bottom: 15px;
  color: #1e3c72;
  display: flex;
  align-items: center;
  gap: 10px;
}

.checklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: white;
  border-radius: 6px;
}

.checklist-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* ========== モーダルフッター ========== */
.modal-footer {
  padding: 20px 30px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ========== レスポンシブ対応 ========== */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    align-items: stretch;
  }
  
  .header h1 {
    font-size: 20px;
  }
  
  .header-buttons {
    justify-content: center;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .form-grid {
    grid-template-columns: 1fr;
  }
  
  .search-grid {
    grid-template-columns: 1fr;
  }
  
  .modal-content {
    margin: 10px;
    max-height: 95vh;
  }
  
  .modal-body {
    padding: 20px;
  }
  
  table {
    font-size: 12px;
  }
  
  th, td {
    padding: 8px 6px;
  }
}

/* ========== ユーティリティ ========== */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.mt-20 {
  margin-top: 20px;
}

.mb-20 {
  margin-bottom: 20px;
}

.hidden {
  display: none;
}

/* ========== アラート ========== */
.alert {
  padding: 15px 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alert-success {
  background: #d4edda;
  color: #155724;
  border-left: 4px solid #28a745;
}

.alert-danger {
  background: #f8d7da;
  color: #721c24;
  border-left: 4px solid #dc3545;
}

.alert-warning {
  background: #fff3cd;
  color: #856404;
  border-left: 4px solid #ffc107;
}

.alert-info {
  background: #d1ecf1;
  color: #0c5460;
  border-left: 4px solid #17a2b8;
}

/* ========== ローディング ========== */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  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); }
}

/* ========== 操作ガイド ========== */
.guide-section {
  margin-bottom: 25px;
}

.guide-section h3 {
  font-size: 18px;
  color: #1e3c72;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.guide-section ul {
  list-style: none;
  padding-left: 0;
}

.guide-section li {
  padding: 10px 15px;
  margin-bottom: 8px;
  background: #f8f9fa;
  border-radius: 6px;
  border-left: 4px solid #2196f3;
}

.guide-section li strong {
  color: #1e3c72;
}

/* ========== 権限管理バッジ ========== */
.role-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 8px;
  text-transform: uppercase;
}

.role-admin {
  background: #ff6b6b;
  color: white;
}

.role-leader {
  background: #4ecdc4;
  color: white;
}

.role-member {
  background: #95e1d3;
  color: #333;
}

#userInfoDisplay {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ========== アクセス制限メッセージ ========== */
.access-denied {
  text-align: center;
  padding: 60px 20px;
  background: #fff;
  border-radius: 12px;
  margin: 40px auto;
  max-width: 600px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.access-denied i {
  font-size: 64px;
  color: #ff6b6b;
  margin-bottom: 20px;
}

.access-denied h2 {
  color: #333;
  margin-bottom: 15px;
}

.access-denied p {
  color: #666;
  font-size: 16px;
  margin-bottom: 25px;
}

/* ========== 商品詳細テーブル（参考デザイン準拠） ========== */
.details-table-container {
  margin: 25px 0;
  overflow-x: scroll !important; /* 常にスクロールバー表示 */
  overflow-y: visible !important;
  max-width: 100% !important;
  width: 100% !important;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  display: block !important;
  position: relative !important;
  /* 追加: ブラウザのスクロールバーを強制表示 */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: auto; /* Firefoxでスクロールバー表示 */
}

/* Webkit（Chrome/Safari）でスクロールバーを強制表示 */
.details-table-container::-webkit-scrollbar {
  height: 12px !important;
  display: block !important;
}

.details-table-container::-webkit-scrollbar-track {
  background: #f1f1f1 !important;
  border-radius: 6px !important;
}

.details-table-container::-webkit-scrollbar-thumb {
  background: #888 !important;
  border-radius: 6px !important;
}

.details-table-container::-webkit-scrollbar-thumb:hover {
  background: #555 !important;
}

.details-table {
  width: 1800px !important; /* 固定幅でスクロールバーを強制表示 */
  min-width: 1800px !important;
  max-width: 1800px !important;
  table-layout: fixed !important; /* 固定レイアウト */
  border-collapse: collapse;
  margin-bottom: 0;
  display: table !important;
}

.details-table thead {
  background: linear-gradient(135deg, #3b5998 0%, #2d4373 100%);
  position: sticky;
  top: 0;
  z-index: 10;
}

.details-table th {
  padding: 12px 15px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.2);
  white-space: nowrap;
  min-width: 140px !important;
  width: 140px !important;
  max-width: 140px !important;
}

.details-table tbody tr {
  transition: background-color 0.2s;
}

.details-table tbody tr:hover {
  background-color: #f8f9fa;
}

.details-table td {
  padding: 10px;
  border: 1px solid #e0e0e0;
  vertical-align: middle;
  background: #fff;
  min-width: 140px !important;
  width: 140px !important;
  max-width: 140px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
}

/* 原価率の列 - 黄色背景 */
.details-table td:nth-child(10) {
  background-color: #fff9e6 !important;
  font-weight: 600;
  color: #b8860b;
  text-align: center;
}

/* 粗利率の列 - 緑色背景 */
.details-table td:nth-child(11) {
  background-color: #e8f5e9 !important;
  font-weight: 600;
  color: #2e7d32;
  text-align: center;
}

/* 入荷チェックボックスの列 */
.details-table td:nth-child(12) {
  text-align: center;
  background-color: #f0f8ff;
}

/* 削除ボタンの列 */
.details-table td:nth-child(13) {
  text-align: center;
}

.details-table input,
.details-table select {
  width: 100%;
  min-width: 100px;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  background: #fff;
}

.details-table input:focus,
.details-table select:focus {
  outline: none;
  border-color: #3b5998;
  box-shadow: 0 0 0 2px rgba(59, 89, 152, 0.1);
}

.details-table input[readonly] {
  background-color: #f5f5f5;
  color: #666;
  cursor: not-allowed;
}

.details-table input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: #4CAF50;
}

.details-table .btn-danger {
  background-color: #f44336;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.details-table .btn-danger:hover {
  background-color: #d32f2f;
}

.details-table .btn-danger i {
  font-size: 14px;
}

/* ========== 担当者・発注者表示 ========== */
.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 8px;
}

.role-staff {
  background-color: #e3f2fd;
  color: #1976d2;
}

.role-orderer {
  background-color: #ffebee;
  color: #d32f2f;
}
