/* =====================================================
   SpeakNote — style.css
   ===================================================== */

/* ---------- Reset & Variables ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:        #2563eb;
  --accent-hover:  #1d4ed8;
  --accent-light:  #eff6ff;
  --danger:        #dc2626;
  --danger-light:  #fef2f2;
  --bg:            #f8fafc;
  --surface:       #ffffff;
  --border:        #e2e8f0;
  --text-primary:  #0f172a;
  --text-secondary:#64748b;
  --text-muted:    #94a3b8;
  --sidebar-w:     260px;
  --record-h:      88px;
  --toolbar-h:     52px;
  --radius:        10px;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:     0 4px 12px rgba(0,0,0,.10);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans TC',
               'PingFang TC', 'Microsoft JhengHei', sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
}

/* ---------- Layout ---------- */
body {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width .25s ease, opacity .25s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 0;
  opacity: 0;
  pointer-events: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.app-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.note-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 6px;
}

.note-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s;
  border: 1.5px solid transparent;
  margin-bottom: 2px;
}

.note-item:hover { background: var(--bg); }

.note-item.active {
  background: var(--accent-light);
  border-color: var(--accent);
}

.note-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-item-preview {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-item-date {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ---------- Main Area ---------- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ---------- Toolbar ---------- */
.toolbar {
  height: var(--toolbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.note-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  min-width: 0;
}

#note-title-display {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#note-date-display {
  font-size: 11px;
  color: var(--text-muted);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* ---------- Editor ---------- */
.editor-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.editor {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.75;
  color: var(--text-primary);
  background: var(--bg);
  padding: 20px 24px;
}

.editor::placeholder { color: var(--text-muted); }

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 24px;
  pointer-events: none;
}

.empty-icon { font-size: 48px; line-height: 1; }

.empty-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-sub {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 280px;
}

/* ---------- Record Bar ---------- */
.record-bar {
  height: var(--record-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 0 16px;
  flex-shrink: 0;
  position: relative;
}

.lang-select {
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 8px;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg);
  cursor: pointer;
  outline: none;
  transition: border-color .15s;
}
.lang-select:hover { border-color: var(--accent); }

/* 錄音按鈕 */
.btn-record {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 12px 24px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  transition: background .15s, transform .1s, box-shadow .15s;
  box-shadow: 0 2px 8px rgba(37,99,235,.35);
}

.btn-record:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37,99,235,.4);
}

.btn-record:active { transform: translateY(0); }

.btn-record.recording {
  background: var(--danger);
  box-shadow: 0 2px 8px rgba(220,38,38,.35);
  animation: pulse-ring 1.4s ease infinite;
}

.btn-record.recording:hover {
  background: #b91c1c;
  box-shadow: 0 4px 14px rgba(220,38,38,.4);
}

@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0   rgba(220,38,38,.5); }
  70%  { box-shadow: 0 0 0 10px rgba(220,38,38,.0); }
  100% { box-shadow: 0 0 0 0   rgba(220,38,38,.0); }
}

.record-icon { display: flex; align-items: center; }

.record-label { font-size: 11px; letter-spacing: .02em; }

/* 即時轉錄 */
.interim-text {
  flex: 1;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
  max-width: 200px;
}

/* 狀態文字 */
.record-status {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---------- Buttons ---------- */
.btn-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--bg); color: var(--text-primary); }

.btn-text {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  font-size: 12px;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn-text:hover { background: var(--bg); color: var(--text-primary); border-color: #c0ccd8; }
.btn-text:disabled { opacity: .4; cursor: not-allowed; }
.btn-text:disabled:hover { background: transparent; border-color: var(--border); color: var(--text-secondary); }

.btn-danger { color: var(--danger); border-color: #fca5a5; }
.btn-danger:hover { background: var(--danger-light) !important; border-color: var(--danger) !important; color: var(--danger) !important; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #1e293b;
  color: #f1f5f9;
  padding: 9px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  white-space: nowrap;
  z-index: 999;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Scrollbar ---------- */
.note-list::-webkit-scrollbar { width: 4px; }
.note-list::-webkit-scrollbar-track { background: transparent; }
.note-list::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

/* ---------- Utility ---------- */
.hidden { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  :root { --sidebar-w: 100vw; }

  .sidebar {
    position: fixed;
    inset: 0;
    z-index: 100;
    width: 100vw;
  }

  .sidebar.collapsed {
    width: 0;
    opacity: 0;
  }

  .toolbar-actions .btn-text span:not(svg) { display: none; }
  .btn-text { padding: 0 8px; }

  .interim-text { display: none; }
}
