/* =============================================
   schedule-common.css
   TOPJAPAN 予定表共通スタイル（白背景版）
============================================= */

:root {
  --gold: #333;
  --gold-light: #666;
  --dark-bg: #fff;
  --card-bg: #fff;
  --card-bg-hover: #f5f5f5;
  --border: #ccc;
  --border-light: #ddd;
  --text: #333;
  --text-muted: #666;
  --green: #22c55e;
  --blue: #3b82f6;
  --red: #ef4444;
  --orange: #f97316;
  --accent: #17a2b8;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: #fff;
  color: #333;
  min-height: 100vh;
}

/* ===== ヘッダー ===== */
.header {
  background: #fff;
  border-bottom: 1px solid #ccc;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.back-btn {
  background: transparent;
  border: 1px solid #ccc;
  color: #666;
  padding: 8px 14px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 13px;
  transition: all 0.2s;
}

.back-btn:hover {
  border-color: #333;
  color: #333;
}

.logo {
  font-size: 20px;
  font-weight: 900;
  color: #333;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

/* ===== メインレイアウト（フル幅） ===== */
.main-full {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 65px);
  background: #fff;
}

.main-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1px solid #ccc;
  gap: 20px;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.date-selector-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid #ccc;
}

.date-selector-inline .current-date {
  font-size: 16px;
  font-weight: 700;
  color: #333;
  min-width: 70px;
  text-align: center;
}

/* 月タブ */
.month-tabs {
  display: flex;
  gap: 4px;
}

.month-tab {
  padding: 8px 14px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  color: #666;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  position: relative;
}

.month-tab:hover {
  border-color: #333;
  color: #333;
}

.month-tab.active {
  background: #17a2b8;
  border-color: #17a2b8;
  color: #fff;
  font-weight: 700;
}

.month-tab .month-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  font-size: 12px;
  line-height: 1;
}

.month-tab .month-badge.process {
  color: #4CAF50;
}

.month-tab .month-badge.imported {
  color: #FF9800;
}

/* メインテーブルコンテナ */
.main-table-container {
  flex: 1;
  padding: 20px 24px;
  overflow: auto;
}

.main-table-container .data-table {
  width: 100%;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* 空状態（メイン用） */
.main-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 400px;
  color: #666;
  text-align: center;
}

.main-empty-state .empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.main-empty-state .empty-text {
  font-size: 18px;
  margin-bottom: 8px;
}

.main-empty-state .empty-hint {
  font-size: 14px;
  color: #666;
}

/* ===== 旧メインレイアウト（サイドバー付き） ===== */
.main {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: calc(100vh - 65px);
}

/* ===== サイドバー ===== */
.sidebar {
  background: #fff;
  border-right: 1px solid #ccc;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #666;
  padding-bottom: 8px;
  border-bottom: 1px solid #ccc;
}

/* クイックアクション */
.quick-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 10px;
  color: #333;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
  text-align: left;
}

.action-btn:hover {
  border-color: #333;
  background: #f5f5f5;
}

.action-btn.primary {
  background: #333;
  border-color: #333;
  color: #fff;
  font-weight: 700;
}

.action-btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.action-icon {
  width: 36px;
  height: 36px;
  background: #f5f5f5;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.action-btn.primary .action-icon {
  background: rgba(255,255,255,0.2);
}

.action-info {
  flex: 1;
}

.action-label {
  font-weight: 600;
}

.action-desc {
  font-size: 11px;
  color: #666;
  margin-top: 2px;
}

.action-btn.primary .action-desc {
  color: rgba(255,255,255,0.7);
}

/* 年月セレクター */
.date-selector {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  border: 1px solid #ccc;
}

.date-selector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.date-nav-btn {
  background: #fff;
  border: 1px solid #ccc;
  color: #333;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
}

.date-nav-btn:hover {
  border-color: #333;
  background: #f5f5f5;
}

.current-date {
  font-size: 16px;
  font-weight: 700;
  color: #333;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.month-btn {
  padding: 10px 8px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  color: #666;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
  position: relative;
}

.month-btn:hover {
  border-color: #333;
  color: #333;
}

.month-btn.active {
  background: #17a2b8;
  border-color: #17a2b8;
  color: #fff;
  font-weight: 700;
}

.month-btn.has-data::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
}

/* ===== コンテンツエリア ===== */
.content {
  padding: 24px;
  overflow-y: auto;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.content-title {
  font-size: 24px;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 12px;
}

.content-title-icon {
  font-size: 28px;
}

.content-actions {
  display: flex;
  gap: 10px;
}

.btn {
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-outline {
  background: transparent;
  border: 1px solid #ccc;
  color: #333;
}

.btn-outline:hover {
  border-color: #333;
  background: #f5f5f5;
}

.btn-gold {
  background: #17a2b8;
  border: none;
  color: #fff;
}

.btn-gold:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(23, 162, 184, 0.3);
  background: #138496;
}

/* バックナンバーグリッド */
.backnumber-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.backnumber-filter {
  font-size: 12px;
  padding: 6px 14px;
}

.backnumber-filter.active {
  background: #17a2b8;
  border-color: #17a2b8;
  color: #fff;
}

/* カードグリッド */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.card {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.2s;
  cursor: pointer;
}

.card:hover {
  border-color: #333;
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-type {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 4px;
}

.card-type.weekly {
  background: rgba(59, 130, 246, 0.15);
  color: var(--blue);
}

.card-type.monthly {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
}

.card-type.archive {
  background: rgba(249, 115, 22, 0.15);
  color: var(--orange);
}

.card-date {
  font-size: 12px;
  color: #666;
}

.card-body {
  padding: 20px;
}

.card-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-stats {
  display: flex;
  gap: 20px;
  margin-top: 16px;
}

.card-stat {
  display: flex;
  flex-direction: column;
}

.card-stat-value {
  font-size: 20px;
  font-weight: 900;
  color: #17a2b8;
}

.card-stat-label {
  font-size: 11px;
  color: #666;
}

.card-actions {
  padding: 12px 20px;
  background: #f5f5f5;
  display: flex;
  gap: 8px;
}

.card-btn {
  flex: 1;
  padding: 8px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  color: #666;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.card-btn:hover {
  border-color: #333;
  color: #333;
}

/* 空状態 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #666;
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-text {
  font-size: 16px;
  margin-bottom: 8px;
}

.empty-hint {
  font-size: 13px;
  color: #666;
}

/* ===== モーダル ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 16px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.3s;
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-close {
  background: transparent;
  border: none;
  color: #666;
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}

.modal-close:hover {
  color: #333;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  max-height: 60vh;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid #ccc;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* アップロードエリア */
.upload-zone {
  border: 2px dashed #ccc;
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: #17a2b8;
  background: rgba(23, 162, 184, 0.05);
}

.upload-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.upload-text {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.upload-hint {
  font-size: 13px;
  color: #666;
}

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

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #666;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-select,
.form-input {
  flex: 1;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  color: #333;
  font-size: 14px;
}

.form-select:focus,
.form-input:focus {
  outline: none;
  border-color: #17a2b8;
}

/* プレビューテーブル */
.preview-table-wrapper {
  overflow-x: auto;
  margin-top: 16px;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.preview-table th,
.preview-table td {
  padding: 1px 4px 1px 4px;
  text-align: left;
  border-bottom: 1px solid #ccc;
}

.preview-table th {
  background: #f5f5f5;
  color: #333;
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
}

.preview-table tr:hover td {
  background: #f5f5f5;
}

/* トースト */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 20px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s;
  z-index: 2000;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  border-color: var(--green);
}

.toast.error {
  border-color: var(--red);
}

.toast-icon {
  font-size: 20px;
}

.toast-message {
  font-size: 14px;
}

/* データビュー（モーダル用） - 画面いっぱいに表示 */
.data-view-modal.modal-overlay {
  align-items: stretch;
  justify-content: stretch;
}

.data-view-modal .modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  margin: 0;
  border-radius: 0;
  border: none;
  display: flex;
  flex-direction: column;
}

.data-view-modal .modal-header {
  flex: 0 0 auto;
  padding: 6px 12px;
  background: #fff;
  border-bottom: 1px solid #ccc;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.data-view-modal .modal-header .modal-title {
  font-size: 14px;
}

.data-view-modal .modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.data-view-modal .modal-header-actions .btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}

.data-view-modal .modal-body {
  flex: 1 1 auto;
  overflow: hidden;
  padding: 0;
  background: #fff;
  max-height: none;
  height: calc(100vh - 40px);
}

.data-view-modal .data-table-container {
  overflow: auto;
  height: 100%;
  width: 100%;
  background: #fff;
}

/* ★ data-table-container内のヘッダー固定 */
.data-table-container .data-table {
  border-collapse: separate;
  border-spacing: 0;
}

.data-table-container .data-table th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #e8e8e8;
}

.data-table {
  border-collapse: collapse;
  font-size: 15px;
  background: #fff;
  color: #222;
  width: auto;
  table-layout: auto;
}

/* A3横並び（20列）は全幅 */
.data-table.monthly-table {
  width: 100%;
  table-layout: fixed;
}

.data-table th {
  position: sticky;
  top: 0;
  background: #e8e8e8;
  padding: 1px 4px 1px 4px;
  text-align: left;
  font-weight: 700;
  font-size: 15px;
  color: #333;
  border: 2px solid #000;
  white-space: nowrap;
  z-index: 10;
}

.data-table td {
  padding: 1px 4px 1px 4px;
  border: 1px solid #000;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 列幅設定（A3横並び用） */
.monthly-table td.col-extra-narrow,
.monthly-table th.col-extra-narrow {
  width: 40px;
  max-width: 45px;
  min-width: 35px;
}

.monthly-table td.col-narrow,
.monthly-table th.col-narrow {
  width: 50px;
  max-width: 60px;
  min-width: 45px;
}

.monthly-table td.col-medium,
.monthly-table th.col-medium {
  width: 80px;
  max-width: 100px;
  min-width: 70px;
}

.monthly-table td.col-wide,
.monthly-table th.col-wide {
  min-width: 120px;
  max-width: 250px;
}

.data-table tr:nth-child(even) td {
  background: #fafafa;
}

.data-table tr:hover td {
  background: #e6f7ff;
}

.factory-badge {
  display: inline-block;
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  margin: 0;
}

/* 月間表示の左右区切り */
.data-table.monthly-table .left-border {
  border-left: 3px solid #333 !important;
}

.data-table.monthly-table th.left-border {
  background: #d8d8d8;
}

/* レスポンシブ */
@media (max-width: 900px) {
  .main {
    grid-template-columns: 1fr;
  }
  
  .sidebar {
    display: none;
  }
  
  .cards-grid {
    grid-template-columns: 1fr;
  }
}

/* 印刷用スタイル - A3横向き対応 */
@page {
  size: A3 landscape;
  margin: 10mm;
}

@media print {
  /* 基本設定 */
  body {
    background: #fff !important;
    color: #000 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  
  /* 基本的に全て非表示 */
  .header, .sidebar, .content, .main, .toast {
    display: none !important;
  }
  
  /* モーダルオーバーレイ - 開いているものだけ表示 */
  .modal-overlay {
    display: none !important;
  }
  
  .modal-overlay.active {
    display: block !important;
    position: static !important;
    background: none !important;
    width: 100% !important;
    height: auto !important;
  }
  
  .modal-overlay.active .modal {
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    transform: none !important;
    background: #fff !important;
  }
  
  .modal-overlay.active .modal-header,
  .modal-overlay.active .modal-footer {
    display: none !important;
  }
  
  .modal-overlay.active .modal-body {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
    background: #fff !important;
  }
  
  .data-table-container {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
  
  .data-table {
    font-size: 10px !important;
    width: 100% !important;
    page-break-inside: auto;
    table-layout: auto !important;
  }
  
  .data-table th {
    background: #ddd !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    font-size: 10px !important;
    padding: 4px 2px !important;
  }
  
  .data-table th, .data-table td {
    padding: 4px 2px !important;
    border: 1px solid #000 !important;
    max-width: none !important;
    white-space: nowrap !important;
    line-height: 1.3 !important;
  }
  
  .data-table tr {
    page-break-inside: avoid;
    height: 22px !important;
  }
  
  .factory-badge {
    border: 1px solid #000 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    font-size: 9px !important;
    padding: 1px 3px !important;
  }
}

/* ローディング */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #ccc;
  border-top-color: #17a2b8;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 40px auto;
}

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