/* ==========================================================================
   互動工具平台 - 全域共用樣式庫 (common.css)
   ========================================================================== */

/* --- 1. 基礎重置與排版 --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg-main: #0b0f19;
  --bg-sidebar: #1e293b;
  --bg-card: #0f172a;
  --bg-item: #1e293b;
  --border-color: #334155;
  --border-focus: #38bdf8;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --primary: #38bdf8;
  --primary-gradient: linear-gradient(135deg, #38bdf8, #2563eb);
  --success: #4ade80;
  --danger: #f87171;
  --purple: #a855f7;
}

body, html {
  width: 100%;
  height: 100%;
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  user-select: none;
}

/* 自訂捲軸 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-card);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* --- 2. 表單與輸入控制項 --- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #475569;
  background-color: var(--bg-card);
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
}

/* --- 3. 按鈕規範 --- */
.btn {
  padding: 9px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-primary {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.25);
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.92;
  transform: translateY(-1px);
}

.btn-secondary {
  background: #334155;
  color: #cbd5e1;
  border: 1px solid #475569;
}

.btn-secondary:hover:not(:disabled) {
  background: #475569;
  color: #ffffff;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.35);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* 複製與專用功能按鈕 */
.copy-btn {
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--primary);
  background-color: rgba(56, 189, 248, 0.1);
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.copy-btn:hover {
  background-color: var(--primary);
  color: var(--bg-main);
}

.copy-btn.copied {
  border-color: var(--success);
  background-color: rgba(74, 222, 128, 0.2);
  color: var(--success);
}

.overlay-btn {
  border-color: var(--purple);
  background-color: rgba(168, 85, 247, 0.1);
  color: #c084fc;
}

.overlay-btn:hover {
  background-color: var(--purple);
  color: #ffffff;
}

/* --- 4. 狀態徽章與指示燈 --- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: 20px;
  background-color: #334155;
  color: var(--text-muted);
  font-weight: 500;
}

.status-badge.connected {
  background-color: rgba(34, 197, 94, 0.2);
  color: var(--success);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.status-indicator.connected {
  color: var(--success);
}

/* --- 5. 提示卡片與輔助文字 --- */
.card-box {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
}

.tip-text {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.4;
}

/* --- 6. 通用彈窗系統 (Modal) --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 15, 25, 0.88);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
}

.modal-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
}

.modal-error {
  color: var(--danger);
  font-size: 0.8rem;
  text-align: center;
  line-height: 1.3;
  background: rgba(239, 68, 68, 0.1);
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.modal-actions .btn {
  flex: 1;
}