/* ============================================================
   admin.css — 管理画面専用スタイル
   ============================================================ */

:root {
  --sidebar-w: 220px;
  --primary:   #2563eb;
  --primary-h: #1d4ed8;
  --danger:    #dc2626;
  --success:   #16a34a;
  --warning:   #d97706;
  --bg:        #f1f5f9;
  --card:      #ffffff;
  --border:    #e2e8f0;
  --text:      #1e293b;
  --text-muted:#64748b;
  --radius:    8px;
}

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

body {
  font-family: 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ---- ログイン画面 ---- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
}
.login-box {
  background: #fff;
  border-radius: 14px;
  padding: 40px 36px;
  width: min(94vw, 380px);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-box h1 {
  font-size: 1.25rem;
  text-align: center;
  margin-bottom: 6px;
}
.login-box .sub {
  text-align: center;
  color: var(--text-muted);
  font-size: .85rem;
  margin-bottom: 28px;
}

/* ---- 共通フォーム ---- */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: .83rem;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 11px;
  font-size: .95rem;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group small { display: block; color: var(--text-muted); font-size: .78rem; margin-top: 3px; }

/* ---- ボタン ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 6px;
  border: none;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, opacity .15s;
  font-family: inherit;
}
.btn-primary   { background: var(--primary);  color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-danger    { background: var(--danger);   color: #fff; }
.btn-danger:hover  { opacity: .85; }
.btn-secondary { background: #f1f5f9; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; }
.btn-sm { padding: 5px 12px; font-size: .82rem; }
.btn-full { width: 100%; justify-content: center; }

/* ---- アラート ---- */
.alert {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: .88rem;
  margin-bottom: 16px;
}
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

/* ---- レイアウト ---- */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- サイドバー ---- */
.sidebar {
  width: var(--sidebar-w);
  background: #1e293b;
  color: #cbd5e1;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 30;
  transition: transform .25s;
}
.sidebar-logo {
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  font-weight: 700;
  font-size: .95rem;
  color: #fff;
}
.sidebar nav { padding: 12px 0; flex: 1; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  color: #94a3b8;
  text-decoration: none;
  font-size: .9rem;
  transition: color .15s, background .15s;
}
.sidebar nav a:hover,
.sidebar nav a.active {
  color: #fff;
  background: rgba(255,255,255,.07);
}
.sidebar nav a.active { border-left: 3px solid var(--primary); }
.sidebar-footer {
  padding: 16px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
}

/* ---- メインコンテンツ ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 28px 32px;
  min-width: 0;
}

/* ---- ページヘッダー ---- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 { font-size: 1.4rem; }
.page-header .breadcrumb {
  font-size: .82rem;
  color: var(--text-muted);
  margin-top: 3px;
}
.page-header .breadcrumb a { color: var(--primary); text-decoration: none; }

/* ---- カード ---- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 20px;
}
.card h2 {
  font-size: 1rem;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ---- テーブル ---- */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
th {
  background: #f8fafc;
  text-align: left;
  padding: 10px 14px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* ---- バッジ ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-success   { background: #dcfce7; color: #166534; }
.badge-danger    { background: #fee2e2; color: #991b1b; }
.badge-warning   { background: #fef3c7; color: #92400e; }
.badge-info      { background: #dbeafe; color: #1d4ed8; }
.badge-gray      { background: #f1f5f9; color: #64748b; }
.badge-secondary { background: #f1f5f9; color: #64748b; }

/* ---- ドロップゾーン ---- */
#dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color .2s, background .2s;
  margin-bottom: 16px;
}
#dropzone:hover,
#dropzone.drag-over {
  border-color: var(--primary);
  background: #eff6ff;
  color: var(--primary);
}
#dropzone svg { display: block; margin: 0 auto 10px; }
#dropzone p { font-size: .9rem; }
#dropzone small { font-size: .8rem; margin-top: 4px; display: block; }
/* 子要素がドラッグイベントを横取りしないようにする */
#dropzone * { pointer-events: none; }

/* アップロードプログレスリスト */
#upload-progress-list { list-style: none; margin-bottom: 12px; }
#upload-progress-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: .85rem;
  border-bottom: 1px solid #f1f5f9;
}
#upload-progress-list li:last-child { border-bottom: none; }
.progress-bar-wrap {
  flex: 1;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width .2s;
  border-radius: 3px;
}

/* ---- 管理写真グリッド ---- */
.admin-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.admin-photo-card {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  background: #e2e8f0;
  border: 2px solid transparent;
  transition: border-color .15s;
}
.admin-photo-card:hover { border-color: var(--primary); }
.admin-photo-card img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.admin-photo-card .del-btn {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(220,38,38,.9);
  color: #fff;
  border: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .15s;
}
.admin-photo-card:hover .del-btn { opacity: 1; }
.admin-photo-card .photo-num {
  position: absolute;
  bottom: 4px; left: 4px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: .7rem;
  padding: 2px 5px;
  border-radius: 3px;
}

/* ---- URL表示ボックス ---- */
.url-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: .88rem;
  word-break: break-all;
}
.url-box input {
  border: none;
  background: transparent;
  flex: 1;
  font-size: .88rem;
  color: var(--text);
  min-width: 0;
}
.url-box input:focus { outline: none; }

/* ---- 選択結果 ---- */
.selection-row { cursor: pointer; }
.selection-detail {
  display: none;
  background: #f8fafc;
}
.selection-detail td { padding: 12px 14px; }
.selection-thumb-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.selection-thumb-grid img {
  width: 64px; height: 64px;
  object-fit: cover;
  border-radius: 4px;
  border: 2px solid var(--border);
}

/* ---- レスポンシブ ---- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
    padding: 16px;
  }
  .page-header { margin-bottom: 16px; }
  .admin-photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }

  /* iOS 入力ズーム防止（フォントが 16px 未満だと Safari が自動ズーム） */
  .form-group input,
  .form-group select,
  .form-group textarea {
    font-size: 1rem;
  }

  /* 3カラムグリッドを1カラムに */
  .grid-resp-3 {
    grid-template-columns: 1fr !important;
  }
}

/* ハンバーガーボタン（スマホ） */
#sidebar-toggle {
  display: none;
  position: fixed;
  top: max(12px, env(safe-area-inset-top, 12px)); left: 12px;
  z-index: 40;
  background: #1e293b;
  border: none;
  color: #fff;
  width: 40px; height: 40px;
  border-radius: 6px;
  font-size: 1.2rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
@media (max-width: 768px) {
  #sidebar-toggle { display: flex; }
  .main-content { padding-top: 60px; }
  #upload-status-bar { margin: -16px -16px 16px !important; }
}

/* モーダル */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 28px 24px;
  width: min(94vw, 480px);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-box h3 { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }

/* ---- 写真選択モード ---- */
.photo-item.photo-selected {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px var(--primary);
}
.photo-select-overlay { pointer-events: auto; }
.photo-item .photo-select-cb { pointer-events: auto; }
