/* ============================================
   components.css - UIコンポーネント
   ============================================ */

/* セクションヘッダー（サンプルボタン用） */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

/* サンプルドロップダウン */
.sample-buttons {
  display: flex;
  gap: 8px;
}

.sample-dropdown {
  position: relative;
}

.sample-btn {
  padding: 6px 12px;
  font-size: 0.85rem;
  background: transparent;
  border: 1px solid var(--muted);
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
}

.sample-btn:hover {
  background: rgba(148, 163, 184, 0.1);
}

.sample-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  min-width: 250px;
  z-index: 100;
}

.sample-option {
  display: block;
  width: 100%;
  padding: 10px 16px;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--fg);
  cursor: pointer;
  font-size: 0.9rem;
  border-radius: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sample-option:hover {
  background: rgba(106, 166, 255, 0.1);
}

.sample-option:first-child {
  border-radius: 8px 8px 0 0;
}

.sample-option:last-child {
  border-radius: 0 0 8px 8px;
}

/* 設定グリッド */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 20px;
}

@media (max-width: 768px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

.setting-group {
  padding: 16px;
  background: rgba(255,255,255,0.02);
  border-radius: 10px;
  border: 1px solid var(--border);
}

:root[data-theme="light"] .setting-group {
  background: rgba(0,0,0,0.02);
}

.setting-group h3 {
  margin: 0 0 12px 0;
  font-size: 0.95rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* フィールド */
.fieldset { 
  margin-top: 8px; 
  border-top: 1px dashed var(--border); 
  padding-top: 8px; 
}

.field { 
  margin: 8px 0; 
  display: flex; 
  align-items: center; 
  gap: 12px; 
  flex-wrap: wrap; 
}

.lbl { 
  display: inline-block; 
  min-width: 120px; 
  color: var(--muted); 
}

.key-row { 
  position: relative; 
}

.key-row input[type="text"] { 
  width: 300px !important; 
  max-width: 300px; 
  flex-shrink: 0; 
}

.input-hint { 
  font-size: 0.85rem;
  color: var(--muted);
  flex-basis: 100%;
  margin-left: 132px;
}

/* 整形オプション（チェックボックス群）のレイアウト */
.field input[type="checkbox"] {
  margin-right: 6px;
}

/* チェックボックスを含むラベルのスタイル（.lbl以外） */
.field label:not(.lbl) {
  display: inline-flex;
  align-items: center;
  margin-right: 16px;
  white-space: nowrap;
  min-width: auto;
}

/* 整形オプションの特別なレイアウト */
.field.options-field {
  flex-wrap: nowrap;
  overflow: visible;
  align-items: flex-start;
}

/* 整形オプションのチェックボックス群を右側にまとめる */
.options-field .checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-left: 0;
}

/* 整形ラベルを最初の行に揃える */
.options-field .lbl {
  align-self: flex-start;
  line-height: 1.5;
  margin-top: 2px;
}

/* .field内の入力欄は適切な幅に調整 */
.field input[type="text"] { 
  width: auto; 
  min-width: 200px; 
  flex: 1; 
}

/* 特定サイズの入力欄 */
.w1 { 
  width: 2rem !important; 
  text-align: center; 
  flex-shrink: 0; 
}

.w2 { 
  width: 2.5rem !important; 
  text-align: center; 
}

.w4 { 
  width: 3.2rem !important; 
  text-align: center; 
}

/* ボタングループ */
.buttons { 
  display: flex; 
  gap: 8px; 
  margin-top: 8px; 
}

/* 中間状態表示 */
.intermediate-display {
  margin-top: 12px;
  padding: 16px;
  background: #0f1420;
  border: 1px solid var(--border);
  border-radius: 10px;
}

:root[data-theme="light"] .intermediate-display {
  background: #f8fafc;
}

.formatted-text {
  display: block;
  padding: 12px;
  background: rgba(255,255,255,0.02);
  border-radius: 6px;
  margin-bottom: 12px;
  word-break: break-all;
  line-height: 1.6;
}

:root[data-theme="light"] .formatted-text {
  background: rgba(0,0,0,0.05);
}

.text-info {
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  gap: 16px;
}

.text-info span {
  color: var(--accent);
  font-weight: 600;
}

/* サブセクションヘッダー */
.subsection-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.subsection-header h3 {
  margin: 0;
}

/* 同期ボタン */
.sync-btn {
  padding: 6px 12px;
  font-size: 0.85rem;
  background: rgba(106, 166, 255, 0.1);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.sync-btn:hover {
  background: var(--accent);
  color: #071018;
}

.sync-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: rgba(148, 163, 184, 0.1);
  border-color: var(--muted);
  color: var(--muted);
}

/* コピーボタン */
.output-wrapper {
  position: relative;
}

.copy-btn {
  padding: 4px 12px;
  font-size: 0.85rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.8;
  transition: all 0.2s;
  white-space: nowrap;
  position: static;
}

.copy-btn:hover {
  opacity: 1;
  background: var(--accent);
  color: #071018;
}

/* トースト通知 */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--accent);
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s;
  z-index: 1000;
  font-weight: 600;
  border: 1px solid transparent;
}

/* ライトモード用のtoast */
:root[data-theme="light"] .toast {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.3), 0 2px 8px rgba(0,0,0,0.1);
  border: 1px solid rgba(37, 99, 235, 0.2);
  font-weight: 700;
}

/* 成功toast */
.toast.success {
  background: #16a34a;
}

:root[data-theme="light"] .toast.success {
  background: #16a34a;
  box-shadow: 0 4px 16px rgba(22, 163, 74, 0.3), 0 2px 8px rgba(0,0,0,0.1);
  border: 1px solid rgba(22, 163, 74, 0.2);
}

/* エラーtoast */
.toast.error {
  background: var(--danger);
}

:root[data-theme="light"] .toast.error {
  background: var(--danger);
  box-shadow: 0 4px 16px rgba(220, 38, 38, 0.3), 0 2px 8px rgba(0,0,0,0.1);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}