/* ============================================
   マダミスマーケット 共通スタイル
   ============================================ */

:root {
  --bg: #0d0d1a;
  --bg-card: #16162a;
  --bg-card-hover: #1e1e38;
  --border: #2a2a4a;
  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --accent-dim: rgba(139, 92, 246, 0.15);
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

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

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ ナビゲーション ============ */
.navbar {
  background: rgba(13, 13, 26, 0.95);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.nav-logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.05em;
}

.nav-logo span { color: var(--accent); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-link {
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: color 0.2s;
}

.nav-link:hover { color: var(--text); text-decoration: none; }

#nav-auth {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ============ ボタン ============ */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  display: inline-block;
}

.btn-primary:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }
.btn-primary:active { transform: scale(0.98); }

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-block;
}

.btn-outline:hover { background: var(--accent-dim); text-decoration: none; }

.btn-primary-sm {
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 6px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-block;
  transition: background 0.2s;
}

.btn-primary-sm:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }

.btn-outline-sm {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 16px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-outline-sm:hover { border-color: var(--text-muted); color: var(--text); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 20px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-danger:hover { opacity: 0.85; }

/* ============ レイアウト ============ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.page-header {
  padding: 60px 0 40px;
  text-align: center;
}

.page-header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.page-header p { color: var(--text-muted); }

/* ============ カード ============ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

/* ============ ストーリーグリッド ============ */
.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  padding: 0 0 60px;
}

.story-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  cursor: pointer;
  display: block;
  color: var(--text);
}

.story-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 8px 32px rgba(139, 92, 246, 0.2);
  text-decoration: none;
  color: var(--text);
}

.story-card-cover {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: linear-gradient(135deg, #1a1a3e, #2d1b4e);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--accent);
}

.story-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story-card-body { padding: 16px; }

.story-card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.4;
}

.story-card-seller {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.story-card-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.tag {
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.75rem;
}

.story-card-price {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

/* ============ 検索・フィルター ============ */
.search-bar {
  padding: 32px 0 24px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 16px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-dim); }

select.search-input {
  cursor: pointer;
  flex: 0 0 auto;
}

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

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

.form-control {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 14px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--text-dim); }

textarea.form-control { resize: vertical; min-height: 120px; }

.form-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ============ アラート ============ */
.alert {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.alert-error { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3); }
.alert-success { background: rgba(34, 197, 94, 0.15); color: #86efac; border: 1px solid rgba(34, 197, 94, 0.3); }

/* ============ 認証ページ ============ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 440px;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
  text-align: center;
}

.auth-subtitle {
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 32px;
  font-size: 0.9rem;
}

.auth-divider {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  margin: 20px 0;
}

.role-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.role-option {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.role-option:hover { border-color: var(--accent); }
.role-option.active { border-color: var(--accent); background: var(--accent-dim); }
.role-option .role-icon { font-size: 1.5rem; margin-bottom: 6px; }
.role-option .role-name { font-size: 0.9rem; font-weight: 600; }
.role-option .role-desc { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* ============ ヒーロー ============ */
.hero {
  text-align: center;
  padding: 80px 24px 60px;
  background: radial-gradient(ellipse at center top, rgba(139, 92, 246, 0.15) 0%, transparent 60%);
}

.hero h1 {
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 16px;
}

.hero h1 span { color: var(--accent); }
.hero p { color: var(--text-muted); font-size: 1.05rem; margin-bottom: 32px; }

/* ============ ストーリー詳細 ============ */
.story-detail {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 32px;
  padding: 40px 0 60px;
}

.story-cover-large {
  width: 100%;
  border-radius: var(--radius);
  aspect-ratio: 16/9;
  object-fit: cover;
  background: linear-gradient(135deg, #1a1a3e, #2d1b4e);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
  margin-bottom: 24px;
}

.story-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0;
}

.meta-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.meta-item .label { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; }
.meta-item .value { font-size: 0.95rem; font-weight: 600; }

.purchase-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  position: sticky;
  top: 80px;
  height: fit-content;
}

.purchase-price {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.purchase-fee-note {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 20px;
}

/* ============ ページネーション ============ */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 32px 0;
}

.page-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
}

.page-btn:hover, .page-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

/* ============ 空状態 ============ */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 8px; }
.empty-state p { font-size: 0.9rem; color: var(--text-dim); margin-bottom: 24px; }

/* ============ フッター ============ */
.footer {
  border-top: 1px solid var(--border);
  padding: 32px 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: auto;
}

/* ============ レスポンシブ ============ */
@media (max-width: 768px) {
  .hero h1 { font-size: 1.6rem; }
  .story-detail { grid-template-columns: 1fr; }
  .purchase-box { position: static; }
  .auth-box { padding: 24px; }
  .story-meta-grid { grid-template-columns: 1fr; }
}

/* ============ ローディング ============ */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 40px auto;
}

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

.loading { text-align: center; padding: 60px; }
