/**
 * Pages Manager CSS - ページ管理画面スタイル
 */

/* タブナビゲーション */
.tab-navigation {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid #e5e7eb;
  margin-bottom: 24px;
}

.tab-button {
  padding: 12px 24px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  color: #6b7280;
  transition: all 0.2s ease;
}

.tab-button:hover {
  color: #374151;
  background: #f9fafb;
}

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

/* タブコンテンツ */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ページ一覧テーブル */
.pages-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.pages-table thead {
  background: #f9fafb;
}

.pages-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: #374151;
  border-bottom: 2px solid #e5e7eb;
}

.pages-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
}

.pages-table tbody tr:hover {
  background: #f9fafb;
}

.pages-table tbody tr.inactive-page {
  background-color: #f3f4f6;
}

.pages-table tbody tr.inactive-page:hover {
  background-color: #e5e7eb;
}

.pages-table code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Monaco', 'Consolas', monospace;
  font-size: 14px;
  color: #475569;
}

.description-cell {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions-cell {
  display: flex;
  gap: 8px;
}

/* バッジ */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-primary {
  background: #dbeafe;
  color: #1e40af;
}

.badge-secondary {
  background: #f3f4f6;
  color: #6b7280;
}

.badge-admin {
  background: #fef3c7;
  color: #92400e;
}

.badge-success {
  background: #d1fae5;
  color: #065f46;
}

.badge-warning {
  background: #fed7aa;
  color: #9a3412;
}

.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.status-active {
  background: #d1fae5;
  color: #065f46;
}

.status-inactive {
  background: #f3f4f6;
  color: #6b7280;
}

/* 順序変更リスト */
.reorder-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 8px;
}

.reorder-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: move;
  transition: all 0.2s ease;
}

.reorder-item:hover {
  border-color: #3b82f6;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.reorder-item.dragging {
  opacity: 0.5;
}

.reorder-handle {
  font-size: 18px;
  color: #9ca3af;
  cursor: grab;
  user-select: none;
}

.reorder-handle:active {
  cursor: grabbing;
}

.reorder-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: #f3f4f6;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  color: #374151;
}

.reorder-content {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.reorder-info {
  flex: 1;
}

.reorder-name {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 0;
}

.reorder-description {
  font-size: 12px;
  color: #6b7280;
}

.reorder-actions {
  display: flex;
  gap: 4px;
}

/* ボタン */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-secondary {
  background: #f3f4f6;
  color: #374151;
}

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

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

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

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

.btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
  color: #374151;
  font-size: 14px;
}

.btn-icon:hover:not(:disabled) {
  background: #e5e7eb;
}

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

/* モーダル */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-content.modal-large {
  max-width: 900px;
}

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

.modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: #111827;
}

.modal-close {
  font-size: 28px;
  color: #9ca3af;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s ease;
}

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

.modal-body {
  padding: 24px;
}

/* モーダルボディ 2カラムレイアウト */
.modal-body-columns {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.modal-column-left {
  flex: 1;
  min-width: 0;
}

.modal-column-right {
  flex: 0 0 320px;
  min-width: 320px;
}

.modal-column-right .form-group {
  margin-bottom: 0;
}

.modal-column-right .users-checkbox-list {
  height: 400px;
  max-height: 400px;
}

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

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

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #374151;
}

/* フォーム横並びレイアウト */
.form-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.form-row .form-group {
  margin-bottom: 20px;
}

.form-row .form-group-small {
  flex: 1;
  min-width: 140px;
}

.form-row .form-group-large {
  flex: 1;
}

.form-row .form-group-half {
  flex: 0 0 calc(50% - 8px);
}

.form-row-equal .form-group {
  flex: 1;
}

/* ラジオボタングループ（トグルボタン風） */
.radio-group {
  display: flex;
  gap: 0;
  padding: 4px 0;
}

.radio-item {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin: 0;
  font-weight: 500;
  padding: 8px 16px;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  color: #6b7280;
  transition: all 0.15s ease;
}

.radio-item:first-child {
  border-radius: 6px 0 0 6px;
}

.radio-item:last-child {
  border-radius: 0 6px 6px 0;
  border-left: none;
}

.radio-item:hover {
  background: #e5e7eb;
}

.radio-item input[type='radio'] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-item:has(input[type='radio']:checked) {
  background: #2563eb;
  border-color: #2563eb;
  color: white;
}

.radio-item:has(input[type='radio']:checked):hover {
  background: #1d4ed8;
}

.radio-item:has(input[type='radio']:disabled) {
  opacity: 0.5;
  cursor: not-allowed;
}

.radio-item span {
  font-size: 13px;
}

.form-group input[type='text'],
.form-group input[type='number'],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-check input[type='checkbox'] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.form-check label {
  margin: 0;
  cursor: pointer;
}

/* フォーム横並び時のチェックボックス位置調整 */
.form-check-aligned {
  margin-top: 32px;
}

/* ユーザーチェックボックスリスト */
.users-checkbox-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 12px;
  background: #f9fafb;
}

.user-checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  margin-bottom: 4px;
  background: white;
  border-radius: 4px;
  transition: background 0.2s ease;
}

.user-checkbox-item:hover {
  background: #f3f4f6;
}

.user-checkbox-item input[type='checkbox'] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.user-checkbox-item label {
  margin: 0;
  cursor: pointer;
  flex: 1;
  font-size: 14px;
  color: #374151;
}

.user-checkbox-item small {
  color: #6b7280;
  font-size: 12px;
}

/* セクションヘッダー */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.section-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: #111827;
}

.section-header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* フィルタリンググループ */
.filter-group {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 6px 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

.filter-label {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  white-space: nowrap;
}

.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  user-select: none;
  margin: 0;
}

.filter-checkbox input[type='checkbox'] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  margin: 0;
}

.filter-checkbox span {
  white-space: nowrap;
}

.filter-input {
  padding: 6px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  width: 180px;
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

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

.filter-input::placeholder {
  color: #9ca3af;
}

/* 順序変更セクション */
.reorder-section-header {
  background: #fef3c7;
  border: 1px solid #fbbf24;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.reorder-section-header .icon {
  font-size: 24px;
}

.reorder-section-header .text {
  flex: 1;
  color: #92400e;
}

.reorder-section-header .text strong {
  display: block;
  margin-bottom: 4px;
}

.reorder-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 2px solid #e5e7eb;
}

/* テキスト */
.text-center {
  text-align: center;
}

/* レスポンシブ */
@media (max-width: 768px) {
  .tab-button {
    padding: 10px 16px;
    font-size: 14px;
  }

  .pages-table {
    font-size: 14px;
  }

  .pages-table th,
  .pages-table td {
    padding: 8px 12px;
  }

  .reorder-item {
    padding: 6px 10px;
  }

  .reorder-number {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }

  .modal-content {
    width: 95%;
  }

  /* モーダル2カラムレイアウトを縦並びに */
  .modal-body-columns {
    flex-direction: column;
  }

  .modal-column-right {
    flex: 1;
    width: 100%;
    min-width: 0;
  }

  .modal-column-right .users-checkbox-list {
    height: 250px;
    max-height: 250px;
  }

  /* セクションヘッダーのアクションを縦並びに */
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .section-header-actions {
    flex-wrap: wrap;
    width: 100%;
  }

  .filter-group {
    width: 100%;
    justify-content: center;
    gap: 12px;
    padding: 6px 12px;
  }

  .filter-checkbox {
    font-size: 13px;
  }

  .filter-checkbox input[type='checkbox'] {
    width: 16px;
    height: 16px;
  }

  /* フォーム横並びを縦並びに */
  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .form-row .form-group-small,
  .form-row .form-group-large {
    flex: 1;
    width: 100%;
  }

  .form-row-equal .form-group {
    width: 100%;
  }
}
