/**
 * 管理者画面スタイル
 */

:root {
  --admin-primary: #2563eb;
  --admin-danger: #dc2626;
  --admin-success: #16a34a;
  --admin-warning: #ea580c;
  --admin-bg: #f9fafb;
  --admin-border: #e5e7eb;
  --admin-text: #1f2937;
  --admin-text-muted: #6b7280;
}

/* メインレイアウト */
.admin-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  background-color: var(--admin-bg);
  min-height: calc(100vh - 80px);
}

/* ヘッダー */
.app-header {
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  color: white;
  padding: 1rem 2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

.app-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-info {
  font-size: 0.9rem;
  opacity: 0.9;
}

/* ユーザー管理セクション */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.section-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--admin-text);
}

.section-header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* テーブル */
.table-container {
  overflow-x: auto;
  margin-bottom: 1rem;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.users-table thead {
  background-color: #f3f4f6;
}

.users-table th {
  text-align: left;
  padding: 0.75rem;
  font-weight: 600;
  color: var(--admin-text);
  border-bottom: 2px solid var(--admin-border);
  white-space: nowrap;
}

.users-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--admin-border);
}

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

.users-table tbody tr.inactive-user {
  background-color: #f3f4f6;
}

.users-table tbody tr.inactive-user:hover {
  background-color: #e5e7eb;
}

.users-table .loading,
.users-table .error,
.users-table .no-data {
  text-align: center;
  padding: 2rem;
  color: var(--admin-text-muted);
}

.users-table .error {
  color: var(--admin-danger);
}

/* バッジ（ユーザー管理用）*/
/* NOTE: pages-manager.cssにも類似スタイルあり（用途別に微調整済み）*/
.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

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

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

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

/* URLリンク */
.url-link {
  display: inline-block;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  color: var(--admin-primary);
  text-decoration: none;
}

.url-link:hover {
  text-decoration: underline;
  color: var(--admin-primary-dark, #1d4ed8);
}

/* ステータスバッジ（pages-manager.cssで定義） */

/* ページネーション */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* ボタン */
.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-primary {
  background-color: var(--admin-primary);
  color: white;
}

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

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

.btn-secondary:hover {
  background-color: #4b5563;
}

.btn-danger {
  background-color: var(--admin-danger);
  color: white;
}

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

.btn-sm {
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
}

.btn-success {
  background-color: #10b981;
  color: white;
}

.btn-success:hover:not(:disabled) {
  background-color: #059669;
}

/* ページ状態トグルボタン（バッジ兼用） */
.btn-status-active {
  background-color: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.btn-status-active:hover:not(:disabled) {
  background-color: #a7f3d0;
}

.btn-status-inactive {
  background-color: #e5e7eb;
  color: #6b7280;
  border: 1px solid #d1d5db;
}

.btn-status-inactive:hover:not(:disabled) {
  background-color: #d1d5db;
}

/* ボタン無効時のスタイル */
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn:disabled:hover {
  transform: none;
  box-shadow: none;
}

/* モーダル */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.modal.show {
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background-color: white;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--admin-border);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--admin-text);
}

.modal-close {
  font-size: 1.5rem;
  color: var(--admin-text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  background: none;
  border: none;
}

.modal-close:hover {
  color: var(--admin-text);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--admin-border);
  margin-top: 1rem;
}

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

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--admin-text);
}

.form-group input[type='text'],
.form-group input[type='url'],
.form-group input[type='email'],
.form-group input[type='password'],
.form-group select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  font-size: 0.875rem;
  transition: border-color 0.2s;
}

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

.form-group input:disabled {
  background-color: #f3f4f6;
  cursor: not-allowed;
}

.form-group small {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--admin-text-muted);
}

.form-error {
  color: var(--admin-danger);
  font-size: 0.875rem;
  margin-top: 0.5rem;
  white-space: pre-line;
}

/* ステータストグル */
.status-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.status-toggle input[type='checkbox'] {
  width: auto;
  margin: 0;
}

.status-toggle .toggle-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: normal;
  margin: 0;
  cursor: pointer;
}

.status-toggle .toggle-text-inactive {
  color: var(--admin-danger);
}

.status-toggle .toggle-text-active {
  color: var(--admin-success);
  display: none;
}

.status-toggle input[type='checkbox']:checked ~ .toggle-label .toggle-text-inactive {
  display: none;
}

.status-toggle input[type='checkbox']:checked ~ .toggle-label .toggle-text-active {
  display: inline;
}

/* パスワード要件表示 */
.password-requirements {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background-color: #f9fafb;
  border-radius: 6px;
  border: 1px solid var(--admin-border);
}

.requirement {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  color: var(--admin-text-muted);
  transition: color 0.2s;
}

.requirement:last-child {
  margin-bottom: 0;
}

.requirement-icon {
  font-size: 1rem;
  font-weight: bold;
  color: var(--admin-text-muted);
  transition: color 0.2s;
}

.requirement.valid {
  color: var(--admin-success);
}

.requirement.valid .requirement-icon {
  color: var(--admin-success);
}

.requirement.valid .requirement-icon::before {
  content: '✓';
}

.requirement.invalid {
  color: var(--admin-danger);
}

.requirement.invalid .requirement-icon {
  color: var(--admin-danger);
}

.requirement.invalid .requirement-icon::before {
  content: '✗';
}

/* レスポンシブ */
@media (max-width: 768px) {
  .admin-main {
    padding: 1rem;
  }

  .header-content {
    flex-direction: column;
    gap: 1rem;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .users-table {
    font-size: 0.75rem;
  }

  .users-table th,
  .users-table td {
    padding: 0.5rem;
  }

  .modal-content {
    width: 95%;
    max-height: 95vh;
  }
}

/* インライン通知システム */
.notification-container {
  min-height: 32px;
  display: flex;
  align-items: center;
}

.notification {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  animation: slideIn 0.3s ease-out;
}

.notification.success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #10b981;
}

.notification.error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #ef4444;
}

.notification.fadeOut {
  animation: fadeOut 0.3s ease-out forwards;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(-10px);
  }
}

/* ========================================
   試合種別権限設定UI
   ======================================== */

/* 権限タイプラジオボタン */
.permission-type-radio {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 0.75rem;
}

.permission-type-radio .radio-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.permission-type-radio .radio-item input[type='radio'] {
  margin: 0;
  cursor: pointer;
}

.permission-type-radio .radio-item span {
  font-size: 0.9rem;
}

/* プリセット選択 */
.permission-preset-selector {
  margin-top: 0.5rem;
}

.permission-preset-selector select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--admin-border);
  border-radius: 4px;
  font-size: 0.9rem;
}

/* カスタム選択（グループ/試合種別ツリー） */
.permission-custom-selector {
  margin-top: 0.5rem;
}

.game-kinds-tree {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--admin-border);
  border-radius: 4px;
  padding: 0.75rem;
  background: #fafafa;
}

.game-kinds-tree-loading {
  color: var(--admin-text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 1rem;
}

.game-kind-group-section {
  margin-bottom: 0.75rem;
}

.game-kind-group-section:last-child {
  margin-bottom: 0;
}

.game-kind-group-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--admin-bg);
  border-radius: 4px;
  margin-bottom: 0.25rem;
}

.game-kind-group-header input[type='checkbox'] {
  margin: 0;
}

.game-kind-group-header label {
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.game-kind-items {
  padding-left: 1.5rem;
}

.game-kind-items label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  border-radius: 3px;
}

.game-kind-items label:hover {
  background: var(--admin-bg);
}

.game-kind-items input[type='checkbox'] {
  margin: 0;
}

/* ユーザー一覧の試合種別列 */
.users-table .permission-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.users-table .permission-badge.all {
  background: #dbeafe;
  color: #1e40af;
}

.users-table .permission-badge.preset {
  background: #e0e7ff;
  color: #4338ca;
}

.users-table .permission-badge.custom {
  background: #f0fdf4;
  color: #166534;
}

.users-table .permission-badge.none {
  background: #fef2f2;
  color: #991b1b;
}

/* ========================================
   ユーザーページ管理
   ======================================== */

/* ページ数バッジ */
.page-count-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  background: #f0fdf4;
  color: #166534;
  min-width: 2rem;
  text-align: center;
}

/* ページボタン */
.btn-info {
  background-color: #0ea5e9;
  color: white;
  border: none;
}

.btn-info:hover {
  background-color: #0284c7;
}

/* ユーザーページモーダル */
.user-pages-section {
  margin-bottom: 1.5rem;
}

.user-pages-section h4 {
  margin: 0 0 0.75rem 0;
  font-size: 0.95rem;
  color: var(--admin-text);
  border-bottom: 1px solid var(--admin-border);
  padding-bottom: 0.5rem;
}

.user-pages-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--admin-border);
  border-radius: 4px;
  padding: 0.5rem;
  background: #fafafa;
}

.user-page-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem;
  border-bottom: 1px solid var(--admin-border);
}

.user-page-item:last-child {
  border-bottom: none;
}

.user-page-item.inactive {
  opacity: 0.6;
  background-color: #f3f4f6;
}

.page-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-info code {
  background: #e5e7eb;
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  font-size: 0.75rem;
}

.page-name {
  font-size: 0.875rem;
}

.page-name-input {
  font-size: 0.875rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--admin-border);
  border-radius: 4px;
  width: 150px;
}

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

.page-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.no-pages {
  padding: 1rem;
  text-align: center;
  color: var(--admin-text-muted);
  font-size: 0.875rem;
}

.error-message {
  padding: 1rem;
  text-align: center;
  color: #991b1b;
  font-size: 0.875rem;
}

/* 新規ページ作成フォーム */
.create-user-page-form {
  border: 1px solid var(--admin-border);
  border-radius: 4px;
  padding: 1rem;
  background: #fafafa;
}

.create-user-page-form .form-group {
  margin-bottom: 0.75rem;
}

.create-user-page-form .form-group:last-of-type {
  margin-bottom: 0;
}

.create-user-page-form label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--admin-text);
}

.create-user-page-form input[type='text'],
.create-user-page-form textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--admin-border);
  border-radius: 4px;
  font-size: 0.875rem;
}

.create-user-page-form input[type='text']:focus,
.create-user-page-form textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.create-user-page-form .form-actions {
  margin-top: 1rem;
  text-align: right;
}

/* 新規ページ作成フォーム - 入力と情報の横並び */
.create-user-page-form .form-row-with-info {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.create-user-page-form .form-group-input {
  flex: 1;
}

.create-user-page-form .form-group-readonly {
  flex-shrink: 0;
}

.create-user-page-form .form-group-readonly label {
  color: #64748b;
}

.create-user-page-form .readonly-value {
  padding: 0.5rem 0.75rem;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #334155;
  min-width: 4rem;
  text-align: center;
}
