* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; width: 100%; }

:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --success: #4CAF50;
  --danger: #F44336;
  --warning: #FF9800;
  --info: #2196F3;
  --gray: #9E9E9E;
  --bg: #f5f7fa;
  --card-bg: #ffffff;
  --text: #333333;
  --text-light: #666666;
  --border: #e0e0e0;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

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

/* ヘッダー */
.header {
  background: var(--primary);
  color: white;
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
}

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

.header-actions button {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

.header-actions button:hover {
  background: rgba(255,255,255,0.3);
}

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

/* メインレイアウト */
.main-container {
  margin-top: 56px;
  display: flex;
  height: calc(100vh - 56px);
  height: calc(100dvh - 56px);
  position: relative;
  overflow: hidden;
}

#map {
  flex: 1;
  height: 100%;
  width: 100%;
  min-height: 300px;
  z-index: 1;
}

/* サイドパネル */
.side-panel {
  width: 380px;
  background: var(--card-bg);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 2;
}

.side-panel.hidden {
  display: none;
}

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

.panel-header h2 {
  font-size: 16px;
}

.panel-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
}

.panel-body {
  padding: 16px;
  flex: 1;
  overflow-y: auto;
}

/* カテゴリーフィルター */
.filter-bar {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  background: white;
  border-radius: 24px;
  padding: 6px 8px;
  display: flex;
  gap: 4px;
  box-shadow: var(--shadow);
}

.filter-btn {
  border: none;
  background: none;
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-light);
  white-space: nowrap;
  transition: all 0.2s;
}

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

.filter-btn:hover:not(.active) {
  background: #f0f0f0;
}

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(26,115,232,0.15);
}

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

/* 写真アップロード */
.photo-upload {
  display: flex;
  gap: 12px;
}

.photo-slot {
  width: 100px;
  height: 100px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s;
}

.photo-slot:hover {
  border-color: var(--primary);
}

.photo-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-slot .placeholder {
  text-align: center;
  color: var(--text-light);
  font-size: 12px;
}

.photo-slot .placeholder::before {
  content: '+';
  display: block;
  font-size: 28px;
  color: var(--border);
}

.photo-slot .remove-photo {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  cursor: pointer;
  font-size: 12px;
  display: none;
}

.photo-slot:hover .remove-photo {
  display: block;
}

/* カテゴリー選択 */
.category-select {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 2px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.category-option:hover {
  border-color: var(--primary);
}

.category-option.selected {
  border-color: var(--primary);
  background: rgba(26,115,232,0.08);
}

.category-option input {
  display: none;
}

.category-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ボタン */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  gap: 6px;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

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

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

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

.btn-secondary {
  background: #e0e0e0;
  color: var(--text);
}

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

.btn-block {
  width: 100%;
}

/* 投稿カード */
.report-card {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: box-shadow 0.2s;
}

.report-card:hover {
  box-shadow: var(--shadow);
}

.report-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.report-category-badge {
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  color: white;
}

.report-card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.report-card-meta {
  font-size: 12px;
  color: var(--text-light);
}

.report-photos {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.report-photos img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
}

/* モーダル */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: white;
  border-radius: 12px;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-header {
  padding: 20px 24px 0;
}

.modal-header h2 {
  font-size: 20px;
  margin-bottom: 4px;
}

.modal-header p {
  color: var(--text-light);
  font-size: 14px;
}

.modal-body {
  padding: 20px 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ログイン画面 */
.auth-container {
  max-width: 420px;
  margin: 80px auto;
  padding: 20px;
}

.auth-card {
  background: white;
  border-radius: 12px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.auth-card h2 {
  font-size: 22px;
  margin-bottom: 8px;
  text-align: center;
}

.auth-card p {
  color: var(--text-light);
  font-size: 14px;
  text-align: center;
  margin-bottom: 24px;
}

.auth-tabs {
  display: flex;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

.auth-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* 通知 */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  z-index: 3000;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  animation: fadeInUp 0.3s;
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--success);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

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

  .main-container {
    flex-direction: column;
  }

  #map {
    height: 60vh;
    height: 60dvh;
  }

  .side-panel {
    width: 100%;
    height: 40vh;
    height: 40dvh;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .filter-bar {
    top: 58px;
    left: 4px;
    right: 4px;
    transform: none;
    overflow-x: auto;
    padding: 4px 6px;
    gap: 2px;
    -webkit-overflow-scrolling: touch;
    z-index: 500;
  }

  .leaflet-top.leaflet-left {
    top: 50px;
  }

  .filter-btn {
    padding: 5px 10px;
    font-size: 12px;
  }

  .modal-overlay {
    padding: 8px;
    align-items: flex-start;
    padding-top: 60px;
  }

  .modal {
    max-width: 100%;
    max-height: calc(100vh - 80px);
    max-height: calc(100dvh - 80px);
  }

  .modal-body {
    padding: 16px;
  }

  .photo-upload {
    flex-wrap: wrap;
  }

  .category-select {
    gap: 6px;
  }

  .category-option {
    padding: 5px 10px;
    font-size: 12px;
  }

  .header-actions button {
    padding: 5px 10px;
    font-size: 12px;
  }

  .user-info {
    font-size: 11px;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .form-group input,
  .form-group textarea,
  .form-group select {
    font-size: 16px; /* iOSズーム防止 */
  }
}

/* 管理者画面 */
.admin-layout {
  margin-top: 56px;
  padding: 20px;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

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

.stat-card {
  background: white;
  border-radius: 6px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  text-align: center;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.stat-card .number {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.stat-card .label {
  font-size: 12px;
  color: var(--text-light);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.admin-table th,
.admin-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.admin-table th {
  background: #f8f9fa;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-light);
}

.admin-table tr:hover {
  background: #f8f9fa;
}

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

.status-published { background: #e8f5e9; color: #2e7d32; }
.status-hidden { background: #fff3e0; color: #e65100; }
.status-resolved { background: #e3f2fd; color: #1565c0; }

.admin-actions {
  display: flex;
  gap: 6px;
}

.admin-actions button {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
}

.admin-actions button:hover {
  background: #f0f0f0;
}

.admin-actions button.delete:hover {
  background: #ffebee;
  border-color: var(--danger);
  color: var(--danger);
}

/* ローディングスピナー */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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