/* 日本茶カフェマップ - スタイル */

:root {
  --primary: #5d7553;        /* 茶緑 */
  --primary-dark: #3e4f37;
  --primary-light: #8aa377;
  --accent: #c4a572;         /* 抹茶ベージュ */
  --bg: #faf8f3;
  --surface: #ffffff;
  --text: #2c2c2c;
  --text-muted: #6b6b6b;
  --border: #e0d9c8;
  --danger: #c0392b;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

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

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
}

body.no-scroll {
  overflow: hidden;
}

/* Header */
.header {
  background: var(--primary);
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  z-index: 1000;
  flex-shrink: 0;
}

.header h1 {
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: 0.05em;
}

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

.admin-link {
  color: white;
  text-decoration: none;
  font-size: 1.2rem;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.admin-link:hover {
  opacity: 1;
}

.view-toggle {
  display: flex;
  gap: 0;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  overflow: hidden;
}

.view-btn {
  background: transparent;
  border: none;
  color: white;
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}

.view-btn.active {
  background: rgba(255, 255, 255, 0.25);
}

/* Filters - インライン表示（コンパクト） */
.filters {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 4px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 999;
  flex-shrink: 0;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
  min-width: 36px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  flex: 1;
}

.chip {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1px 8px;
  font-size: 0.7rem;
  line-height: 1.6;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  font-family: inherit;
}

.chip:hover {
  background: var(--border);
}

.chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.reset-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1px 8px;
  font-size: 0.7rem;
  line-height: 1.6;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: auto;
  font-family: inherit;
}

.reset-btn:hover {
  background: var(--bg);
}

/* Main views */
.main {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.view {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
}

.view.active {
  display: block;
}

#map {
  width: 100%;
  height: 100%;
}

.view-list {
  overflow-y: auto;
  padding: 12px;
  background: var(--bg);
}

.cafe-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 720px;
  margin: 0 auto;
}

.cafe-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.cafe-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.cafe-card-name {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--primary-dark);
}

.cafe-card-address {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.cafe-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.tag.tea {
  background: var(--primary-light);
  color: white;
  border-color: var(--primary-light);
}

/* Detail panel - モバイル: 下から / PC: 右から */
.detail-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 70vh;
  background: var(--surface);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  transform: translateY(100%);
  transition: transform 0.25s ease-out;
  z-index: 2000;
  overflow-y: auto;
  padding: 24px;
}

.detail-panel.open {
  transform: translateY(0);
}

/* PC: 右からのドロワー */
@media (min-width: 768px) {
  .detail-panel {
    top: 0;
    bottom: 0;
    left: auto;
    right: 0;
    width: 420px;
    max-width: 100%;
    max-height: none;
    border-top-left-radius: 16px;
    border-bottom-left-radius: 16px;
    border-top-right-radius: 0;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
  }

  .detail-panel.open {
    transform: translateX(0);
  }
}

.close-btn {
  position: absolute;
  top: 12px;
  right: 16px;
  background: var(--bg);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  background: var(--border);
}

.detail-name {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--primary-dark);
  margin-bottom: 4px;
  padding-right: 40px;
}

.detail-address {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.detail-section {
  margin-bottom: 16px;
}

.detail-section h3 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

.detail-section .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.detail-info {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 6px 12px;
  font-size: 0.85rem;
}

.detail-info dt {
  color: var(--text-muted);
}

.detail-info dd {
  color: var(--text);
}

.detail-specialty {
  background: var(--bg);
  border-left: 3px solid var(--primary);
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.detail-note {
  background: rgba(196, 165, 114, 0.15);
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text);
}

.detail-note::before {
  content: "📝 ";
}

/* Leaflet customization */
.leaflet-popup-content-wrapper {
  border-radius: 8px;
}

.popup-name {
  font-weight: 600;
  margin-bottom: 4px;
}

.popup-types {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.popup-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  width: 100%;
}

/* ============== Admin page ============== */

.admin-body {
  display: block;
  overflow: auto;
}

/* 認証ゲート */
.auth-gate {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  padding: 20px;
}

.auth-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow);
}

.auth-box h2 {
  font-size: 1.3rem;
  color: var(--primary-dark);
  margin-bottom: 8px;
}

.auth-box p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.auth-box form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.auth-box input[type="password"] {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}

.auth-box input[type="password"]:focus {
  outline: none;
  border-color: var(--primary);
}

.auth-error {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.2em;
  margin-bottom: 0;
}

.auth-hint {
  font-size: 0.8rem;
  text-align: center;
  margin-top: 16px;
  margin-bottom: 0;
}

.auth-hint a {
  color: var(--text-muted);
  text-decoration: none;
}

.auth-hint a:hover {
  color: var(--primary);
}

.logout-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.admin-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.admin-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.admin-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
}

.admin-btn:hover {
  background: var(--bg);
}

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

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

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

.admin-table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

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

.admin-table th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tr:hover {
  background: var(--bg);
}

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

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
}

.icon-btn:hover {
  background: var(--bg);
}

.icon-btn.danger {
  color: var(--danger);
  border-color: var(--danger);
}

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

/* Edit form */
.edit-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  margin-top: 20px;
}

.edit-form h2 {
  font-size: 1.2rem;
  margin-bottom: 16px;
  color: var(--primary-dark);
}

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

.form-field {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 200px;
}

.form-field.small {
  flex: 0 0 120px;
  min-width: 120px;
}

.form-field label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.form-field input,
.form-field textarea,
.form-field select {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}

.form-field textarea {
  resize: vertical;
  min-height: 60px;
}

.form-checkboxes {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.form-checkboxes label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.toast-msg {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary-dark);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 3000;
  pointer-events: none;
}

.toast-msg.show {
  opacity: 1;
}

/* Responsive - モバイル */
@media (max-width: 600px) {
  .header h1 {
    font-size: 1rem;
  }

  .detail-panel {
    max-height: 80vh;
  }

  .admin-container {
    padding: 12px;
  }

  .admin-table {
    font-size: 0.8rem;
  }
}
