/* app.css - shared styles for YTLists */

:root { --radius: 10px; }

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Theme variables */
body.theme-dark {
  --bg: #0f1012;
  --bg-alt: #17191c;
  --bg-elevated: #1d2024;
  --text: #e7e9ee;
  --muted: #a3a8b3;
  --border: #2a2e35;
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.14);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.14);
}

body.theme-light {
  --bg: #f9fafb;
  --bg-alt: #f3f4f6;
  --bg-elevated: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #d1d5db;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.10);
  --danger: #b91c1c;
  --danger-soft: rgba(185, 28, 28, 0.08);
}

body.theme-dark-purple {
  --bg: #0a0312;
  --bg-alt: #130820;
  --bg-elevated: #1a0d2e;
  --text: #f5e6ff;
  --muted: #b89cd9;
  --border: #2d1b4e;
  --accent: #cb6ce6;
  --accent-soft: rgba(203, 108, 230, 0.16);
  --danger: #ff6b9d;
  --danger-soft: rgba(255, 107, 157, 0.14);
}

body.theme-light-pink {
  --bg: #faf5ff;
  --bg-alt: #f3e8ff;
  --bg-elevated: #ffffff;
  --text: #2d1b4e;
  --muted: #7c5d9e;
  --border: #e9d5ff;
  --accent: #a855f7;
  --accent-soft: rgba(168, 85, 247, 0.12);
  --danger: #db2777;
  --danger-soft: rgba(219, 39, 119, 0.10);
}

/* Layout */
.page-container {
  max-width: 1200px;
  margin: 1.5rem auto 2rem;
  padding: 0 1.5rem;
}

.site-header { margin-bottom: 0.75rem; }

.site-header-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.site-title { font-size: 1.4rem; font-weight: 650; }
.site-subtitle { font-size: 0.95rem; color: var(--muted); margin-top: 0.25rem; }

.site-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.user-label { color: var(--muted); margin-right: 0.5rem; }
.user-links a { margin-left: 0.35rem; }

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.65rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
}

.site-nav a {
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  background: transparent;
  border: 1px solid transparent;
}
.site-nav a:hover {
  background: var(--accent-soft);
  border-color: var(--accent-soft);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.theme-toggle label {
  color: var(--muted);
}
.theme-toggle select {
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
}
.theme-toggle select:hover {
  border-color: var(--accent);
}
.theme-toggle select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Cards / panels */
.card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 1rem 1.25rem;
}

.layout-two-col {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 880px) {
  .layout-two-col { grid-template-columns: 1fr; }
  .site-header-right { align-items: flex-start; }
}

/* Messages */
.msg {
  color: #16a34a;
  background: rgba(22, 163, 74, 0.16);
  border: 1px solid rgba(22, 163, 74, 0.20);
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.92rem;
}

.err {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid rgba(251, 113, 133, 0.20);
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.92rem;
}

.note { font-size: 0.92rem; color: var(--muted); margin-bottom: 0.8rem; }

/* Forms */
label { display: block; margin-bottom: 0.65rem; font-size: 0.95rem; }

input[type="text"], input[type="password"], select {
  padding: 0.40rem 0.55rem;
  font-size: 0.95rem;
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text);
}

input[type="text"]:focus, input[type="password"]:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

select[multiple] { min-height: 170px; }

.form-row { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; }
.form-row > * { flex: 1 1 240px; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.50rem 0.95rem;
  font-size: 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button:hover, .btn:hover { filter: brightness(0.95); text-decoration: none; }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-alt); }

/* Icon buttons (favorites star) */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg-alt); filter: none; }
.star-btn span { font-size: 1.05rem; line-height: 1; }
.star-btn.is-on { color: #f5c542; border-color: rgba(245, 197, 66, 0.45); }
.star-btn.is-on:hover { background: rgba(245, 197, 66, 0.10); }

.btn-danger {
  background: transparent;
  border-color: rgba(251, 113, 133, 0.55);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger-soft); }

/* Tables */
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { border: 1px solid var(--border); padding: 0.50rem 0.65rem; vertical-align: top; }
th { background: var(--bg-alt); text-align: left; }

.table-actions { white-space: nowrap; }
.table-actions a { margin-right: 0.45rem; }
.table-actions a:last-child { margin-right: 0; }

/* Pagination */
.pagination {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  margin-top: 0.85rem;
}
.pagination .page-pill {
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}
.pagination .page-pill.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* Category checklist */
.cat-checklist {
  max-height: 320px;
  overflow: auto;
  padding: 0.25rem 0.25rem 0.25rem 0.15rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-alt);
}
.cat-checklist label {
  display: block;
  margin: 0.2rem 0;
  font-size: 0.88rem;
  color: var(--text);
}
.cat-checklist .indent-0 { padding-left: 0.15rem; }
.cat-checklist .indent-1 { padding-left: 1.1rem; }
.cat-checklist .indent-2 { padding-left: 2.0rem; }
.cat-checklist .indent-3 { padding-left: 2.9rem; }
.cat-checklist .indent-4 { padding-left: 3.8rem; }

/* Index category grid */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}
.category-card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 0.9rem 1rem 0.9rem;
}
.cat-heading { margin: 0 0 0.35rem; }
.cat-heading-depth-0 { font-size: 1.1rem; font-weight: 650; }
.cat-heading-depth-1 { font-size: 1.0rem; font-weight: 600; }
.cat-heading-depth-2 { font-size: 0.95rem; font-weight: 600; }
ul.item-list { list-style: disc; margin: 0.35rem 0 0.4rem 1.2rem; padding: 0; }
ul.item-list li { margin: 0.18rem 0; }

.item-meta {
  display: block;
  margin-top: 2px;
}
.item-meta .icon-btn {
  margin-right: 10px;
}

/* MyTube */
.mytube-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 0.9rem;
}
.mytube-filters label { margin: 0; font-size: 0.8rem; }
.mytube-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.mytube-card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.mytube-thumb-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--bg-alt);
  overflow: hidden;
}
.mytube-thumb { width: 100%; height: auto; display: block; }
.mytube-card-inner { display: flex; flex-direction: column; }
@media (min-width: 720px) { .mytube-card-inner { flex-direction: row; } }
.mytube-content { padding: 0.75rem 0.85rem; }
.mytube-title { margin: 0 0 0.35rem; font-size: 0.98rem; }
.mytube-channel { font-size: 0.9rem; color: var(--muted); margin-bottom: 0.4rem; }
.mytube-meta { font-size: 0.85rem; color: var(--muted); display: flex; gap: 0.45rem; align-items: center; flex-wrap: wrap; }

/* Manage pages */
.manage-header {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
}
.manage-header h2 { margin: 0; }
.manage-toolbar { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

.list-row-title { font-weight: 650; }
.small-muted { color: var(--muted); font-size: 0.88rem; }

.category-tree { display: grid; gap: 0.55rem; }
.category-node {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 0.75rem 0.85rem;
}
.category-node .node-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.75rem;
}
.category-node .node-name { font-weight: 650; }
.category-node .node-meta { color: var(--muted); font-size: 0.88rem; margin-top: 0.15rem; }
.category-node .node-children {
  margin-top: 0.55rem;
  padding-left: 0.9rem;
  display: grid;
  gap: 0.55rem;
  border-left: 2px solid var(--border);
}

/* Utilities */
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.my-1 { margin-top: 0.25rem !important; margin-bottom: 0.25rem !important; }
.no-margin { margin: 0 !important; }
.center { text-align: center !important; }

.narrow { max-width: 460px; margin: 1rem auto 0; }

.ok {
  border: 1px solid rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.12);
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
}
@media (min-width: 640px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

label.inline {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.page-pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}


.search-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.search-form input[type="text"] {
  min-width: 180px;
}
