/* =============================================
   Trilhae — CSS responsivo (sem framework)
   ============================================= */

/* Reset & base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --info: #0891b2;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 8px;
  --shadow: 0 1px 4px rgba(0,0,0,.08);
  --dot-done: #16a34a;
  --dot-progress: #d97706;
  --dot-new: #94a3b8;
}

html { font-size: 16px; }
body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Header ---- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 900px; margin: 0 auto;
  padding: .75rem 1rem;
  display: flex; align-items: center; gap: 1rem;
}
.logo { font-size: 1.25rem; font-weight: 700; color: var(--primary); }
.nav { margin-left: auto; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.nav-name { font-size: .875rem; color: var(--text-muted); }

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  padding: .45rem 1rem;
  background: var(--primary);
  color: #fff !important;
  border: 1.5px solid var(--primary);
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  text-decoration: none !important;
}
.btn:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline {
  background: transparent;
  color: var(--primary) !important;
}
.btn-outline:hover { background: #eff6ff; }
.btn-sm { padding: .3rem .75rem; font-size: .8rem; }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }

/* ---- Main content ---- */
.main-content {
  flex: 1;
  max-width: 900px; width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* ---- Alerts ---- */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
}
.alert-success { background: #dcfce7; color: #166534; }
.alert-danger   { background: #fee2e2; color: #991b1b; }
.alert-warning  { background: #fef3c7; color: #92400e; }
.alert-info     { background: #e0f2fe; color: #075985; }

/* ---- Auth pages ---- */
.auth-page { max-width: 420px; margin: 2rem auto; }
.auth-page h1 { margin-bottom: 1.25rem; }
.auth-link { margin-top: 1rem; font-size: .9rem; text-align: center; }

/* ---- Forms ---- */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: .35rem; }
.form-group input[type=text],
.form-group input[type=email],
.form-group input[type=password],
.form-group textarea {
  width: 100%;
  padding: .5rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  background: var(--surface);
  transition: border-color .15s;
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.form-check { display: flex; align-items: center; gap: .5rem; }
.form-check label { margin: 0; font-weight: normal; }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1.25rem; }

.form-page { max-width: 680px; }
.form-page h1 { margin-bottom: .5rem; }
.hint { color: var(--text-muted); font-size: .875rem; margin-bottom: 1.25rem; }

/* ---- Home ---- */
.page-header {
  display: flex; align-items: center;
  gap: 1rem; margin-bottom: 1rem;
}
.page-header h1, .page-header h2 { flex: 1; }
.mt-lg { margin-top: 2.5rem; }
.empty-state { color: var(--text-muted); font-size: .95rem; }

.trail-list { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.trail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  display: flex; align-items: center; gap: 1rem;
  box-shadow: var(--shadow);
  transition: border-color .15s;
}
.trail-card:hover { border-color: var(--primary); }
.trail-title { font-weight: 600; flex: 1; }
.trail-meta { font-size: .8rem; color: var(--text-muted); white-space: nowrap; }

/* ---- Trail detail page ---- */
.trail-page { }
.trail-header {
  display: flex; gap: 1rem; flex-wrap: wrap;
  align-items: flex-start; margin-bottom: 1.25rem;
}
.trail-header-text { flex: 1; }
.trail-header-text h1 { font-size: 1.5rem; margin-bottom: .4rem; }
.trail-description { color: var(--text-muted); font-size: .9rem; line-height: 1.6; }
.trail-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-start; padding-top: .25rem; }

/* Inline forms inside <details> */
.inline-form-wrapper summary { cursor: pointer; list-style: none; }
.inline-form-wrapper summary::-webkit-details-marker { display: none; }
.inline-form {
  display: flex; gap: .4rem; flex-wrap: wrap;
  margin-top: .5rem;
  padding: .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.inline-form input { flex: 1; min-width: 180px; }

/* Progress bar */
.progress-bar-wrapper {
  display: flex; align-items: center; gap: .75rem;
  margin-bottom: 1.25rem;
}
.progress-bar-track {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--success);
  border-radius: 99px;
  transition: width .4s;
}
.progress-label { font-size: .8rem; color: var(--text-muted); white-space: nowrap; }

/* Item list */
.item-list { list-style: none; display: flex; flex-direction: column; gap: .4rem; }
.item-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color .15s;
}
.item-row.completed { border-left: 4px solid var(--dot-done); }
.item-row.in-progress { border-left: 4px solid var(--dot-progress); }
.item-row:not(.completed):not(.in-progress) { border-left: 4px solid var(--border); }

.item-info {
  display: flex; align-items: center; gap: .6rem;
  padding: .75rem 1rem;
  cursor: pointer;
  user-select: none;
}
.item-info:hover { background: #f1f5f9; }
.item-icon { font-size: 1rem; flex-shrink: 0; }
.item-status-dot {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
}
.dot-done     { background: var(--dot-done); }
.dot-progress { background: var(--dot-progress); }
.dot-new      { background: var(--dot-new); }
.item-title { font-weight: 500; flex: 1; }
.item-author { font-size: .82rem; color: var(--text-muted); }

/* Inline player */
.inline-player { padding: .75rem 1rem 1rem; background: #f8fafc; border-top: 1px solid var(--border); }
.inline-player audio { width: 100%; display: block; }
.yt-container { position: relative; padding-bottom: 56.25%; height: 0; }
.yt-container iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; }

/* Notes section */
.notes-section { margin-top: .75rem; }
.notes-label-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .4rem; margin-bottom: .3rem; }
.notes-label { font-size: .8rem; font-weight: 600; color: var(--text-muted); }
.notes-hint { font-weight: normal; font-size: .75rem; }
.notes-timestamp-btn { font-size: .75rem; padding: .2rem .55rem; }
.notes-textarea {
  width: 100%;
  min-height: 80px;
  padding: .5rem .6rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  font-family: inherit;
  resize: vertical;
  background: #fff;
  transition: border-color .15s;
}
.notes-textarea:focus { outline: none; border-color: var(--primary); }
.notes-saved { font-size: .75rem; color: var(--success); margin-left: .4rem; transition: opacity .4s; }

/* Share list */
.share-list { margin-top: 2rem; font-size: .875rem; }
.share-list h3 { margin-bottom: .5rem; }
.share-list ul { list-style: disc; padding-left: 1.25rem; color: var(--text-muted); }

/* ---- Footer ---- */
.site-footer {
  text-align: center;
  padding: 1rem;
  font-size: .8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .header-inner { flex-wrap: wrap; }
  .trail-header { flex-direction: column; }
  .trail-actions { width: 100%; }
  .inline-form { flex-direction: column; }
  .form-actions { flex-direction: column; }
  .page-header { flex-wrap: wrap; }
}
