/* ============================
   かんたんInstagram投稿くん
   スタイルシート
   ============================ */

:root {
  --blue:        #1E88E5;
  --blue-dark:   #1565C0;
  --blue-light:  #E3F2FD;
  --blue-mid:    #90CAF9;
  --green:       #2E7D32;
  --green-light: #E8F5E9;
  --white:       #FFFFFF;
  --gray-50:     #F8FAFC;
  --gray-100:    #F1F5F9;
  --gray-200:    #E2E8F0;
  --gray-300:    #CBD5E1;
  --gray-500:    #64748B;
  --gray-700:    #334155;
  --gray-900:    #0F172A;
  --danger:      #DC2626;
  --warning:     #D97706;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 4px 24px rgba(30,136,229,.10);
  --shadow-lg:   0 8px 40px rgba(30,136,229,.16);
  --transition:  0.22s cubic-bezier(.4,0,.2,1);
}

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

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  line-height: 1.7;
}

/* ── ヘッダー ── */
.header {
  background: var(--white);
  border-bottom: 2px solid var(--blue-light);
  padding: 0 32px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(30,136,229,.08);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 18px;
  color: var(--blue);
  text-decoration: none;
}

.header-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--blue), #42A5F5);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.header-badge {
  background: var(--blue-light);
  color: var(--blue);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
}

/* ── レイアウト ── */
.layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 0;
  min-height: calc(100vh - 64px);
}

/* ── サイドバー（入力フォーム） ── */
.sidebar {
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  padding: 28px 24px;
  overflow-y: auto;
  max-height: calc(100vh - 64px);
  position: sticky;
  top: 64px;
}

.sidebar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-title::before {
  content: '';
  width: 4px;
  height: 18px;
  background: var(--blue);
  border-radius: 2px;
}

/* ── フォームグループ ── */
.form-group {
  margin-bottom: 20px;
}

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

.form-label .required {
  color: var(--danger);
  margin-left: 4px;
}

.form-label .hint {
  font-weight: 400;
  color: var(--gray-500);
  font-size: 12px;
  margin-left: 6px;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--gray-900);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30,136,229,.12);
}

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

/* ── ラジオグループ ── */
.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.radio-btn {
  display: none;
}

.radio-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.radio-btn:checked + .radio-label {
  border-color: var(--blue);
  background: var(--blue-light);
  color: var(--blue);
  font-weight: 600;
}

.radio-label:hover {
  border-color: var(--blue-mid);
}

/* ── 画像アップロード ── */
.upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--gray-50);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--blue);
  background: var(--blue-light);
}

.upload-zone .upload-icon { font-size: 32px; margin-bottom: 8px; }
.upload-zone p { font-size: 13px; color: var(--gray-500); }
.upload-zone strong { color: var(--blue); }

#uploadInput { display: none; }

.upload-preview {
  margin-top: 12px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: none;
}

.upload-preview img {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
}

/* ── 生成ボタン ── */
.btn-generate {
  width: 100%;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(30,136,229,.3);
}

.btn-generate:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(30,136,229,.4);
}

.btn-generate:disabled {
  opacity: .65;
  cursor: not-allowed;
  transform: none;
}

/* ── スピナー ── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: none;
}

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

/* ── メインエリア（結果表示） ── */
.main {
  padding: 28px 32px;
  overflow-y: auto;
}

/* ── 空状態 ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  color: var(--gray-500);
  gap: 16px;
}

.empty-state .empty-icon {
  font-size: 64px;
  opacity: .4;
}

.empty-state h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-700);
}

/* ── ローディング ── */
.loading-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  gap: 20px;
}

.loading-ring {
  width: 56px;
  height: 56px;
  border: 4px solid var(--blue-light);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-state p {
  font-size: 15px;
  color: var(--gray-500);
  font-weight: 500;
}

/* ── 結果カード ── */
.result-area { display: none; }

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.result-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-meta {
  font-size: 12px;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.badge-blue  { background: var(--blue-light); color: var(--blue); }
.badge-green { background: var(--green-light); color: var(--green); }

/* ── テキストカード ── */
.text-card {
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
  transition: box-shadow var(--transition);
}

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

.text-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.text-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1.5px solid var(--blue);
  border-radius: 20px;
  background: transparent;
  color: var(--blue);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-copy:hover {
  background: var(--blue);
  color: var(--white);
}

.btn-copy.copied {
  background: var(--green);
  border-color: var(--green);
  color: var(--white);
}

.text-card-body {
  padding: 18px;
  font-size: 14px;
  line-height: 1.85;
  white-space: pre-wrap;
  color: var(--gray-900);
  max-height: 320px;
  overflow-y: auto;
}

.text-card-body.hashtag {
  color: var(--blue);
  font-weight: 500;
}

/* ── 代替テキストグリッド ── */
.alt-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 18px;
}

.alt-item {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alt-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  background: var(--blue);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.alt-text {
  font-size: 13px;
  color: var(--gray-700);
  flex: 1;
  line-height: 1.6;
}

.btn-copy-alt {
  flex-shrink: 0;
  padding: 4px 10px;
  border: 1.5px solid var(--gray-300);
  border-radius: 20px;
  background: transparent;
  color: var(--gray-500);
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
}

.btn-copy-alt:hover { border-color: var(--blue); color: var(--blue); }
.btn-copy-alt.copied { border-color: var(--green); color: var(--green); }

/* ── フッターアクション ── */
.result-actions {
  display: flex;
  gap: 12px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--gray-700);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-secondary:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  background: var(--blue);
  color: var(--white);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}

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

/* ── 履歴タブ ── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 24px;
}

.tab-btn {
  padding: 10px 20px;
  border: none;
  border-bottom: 3px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  margin-bottom: -2px;
  transition: all var(--transition);
}

.tab-btn.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── 履歴リスト ── */
.history-list { display: flex; flex-direction: column; gap: 12px; }

.history-item {
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  transition: all var(--transition);
}

.history-item:hover {
  border-color: var(--blue);
  box-shadow: var(--shadow);
}

.history-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.history-date { font-size: 12px; color: var(--gray-500); }
.history-theme { font-size: 14px; font-weight: 600; color: var(--gray-900); }
.history-hook { font-size: 13px; color: var(--gray-500); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── トースト通知 ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--gray-900);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  z-index: 1000;
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(.4,0,.2,1);
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--green); }
.toast.error { background: var(--danger); }

/* ── エラー表示 ── */
.error-box {
  background: #FEF2F2;
  border: 1.5px solid #FECACA;
  border-radius: var(--radius);
  padding: 16px 18px;
  color: var(--danger);
  font-size: 14px;
  display: none;
}

/* ── セパレーター ── */
.divider {
  border: none;
  border-top: 1px solid var(--gray-200);
  margin: 20px 0;
}

/* ── スクロールバー ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }

/* ── レスポンシブ ── */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
  .main { padding: 20px 16px; }
}
