/*
  story.css — Styles for "Kho Truyện Chữ" list page
  - Variables for light/dark theme
  - Clean, minimal layout, responsive
*/

:root {
  --bg: #FAFBFC;
  --surface: #FFFFFF;
  --text: #0F1724;
  --muted: #6B7280;
  --accent: #2EA6FF;
}

/* Dark theme tokens */
[data-theme="dark"] {
  --bg: #0B1220;
  --surface: #0F1724;
  --text: #E6EDF3;
  --muted: #94A3B8;
}

/* Base */
html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
}

/* Container */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header / Brand */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #7C5CFF);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
}

h1 {
  font-size: 20px;
  margin: 0;
}

/* Search area */
.searchBar {
  position: relative;
  display: flex;
  gap: 12px;
  flex: 1;
  align-items: center;
}

.searchBar input {
  flex: 1;
  padding: 12px 14px 12px 44px;
  border-radius: 10px;
  border: 1px solid #e6e9ef;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(15, 23, 36, 0.02);
  font-size: 16px;
}

.searchBar svg {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--muted);
}

/* Controls */
.controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn {
  background: var(--accent);
  color: white;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
}

.chip {
  background: #f3f7fb;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid #e6eefb;
  color: var(--text);
  font-size: 14px;
}

.meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

/* Grid & cards */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.card {
  background: var(--surface);
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 36, 0.04);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: transform .18s ease, box-shadow .18s ease;
}

.card:hover {
  transform: translateY(-6px);
  box-shadow: 0 10px 30px rgba(15, 23, 36, 0.08);
}

.thumb {
  width: 72px;
  height: 96px;
  background: linear-gradient(135deg, var(--accent), #7C5CFF);
  border-radius: 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}

.title {
  font-weight: 600;
  margin: 0 0 6px 0;
}

.author {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.metaRow {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  align-items: center;
}

.badge {
  background: #f1fbff;
  border: 1px solid #d6f0ff;
  color: var(--accent);
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
}

/* Footer / Pagination */
.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 18px;
  gap: 8px;
}

.pageBtn {
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #e6e9ef;
  cursor: pointer;
}

.pageBtn[disabled] {
  opacity: 0.5;
  cursor: default;
}

/* Responsive */
@media (max-width: 640px) {
  .searchBar { flex-direction: column; align-items: stretch; }
  .controls { justify-content: flex-end; }
}

/* List view: single column, larger thumb */
.grid.list-view {
  grid-template-columns: 1fr;
}

.grid.list-view .card {
  align-items: center;
}

.grid.list-view .thumb {
  width: 96px;
  height: 96px;
}

.grid.list-view .title { font-size: 1.05rem; }

/* Active state for view toggle */
.chip.view-active {
  background: var(--accent);
  color: #fff;
  border-color: rgba(255,255,255,0.06);
  box-shadow: 0 4px 12px rgba(46,166,255,0.12);
}

/* Highlight match */
mark {
  background: linear-gradient(90deg, #fff2cc, #ffe8b3);
  padding: 0 2px;
  border-radius: 2px;
}

/* Modal styles */
.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 60; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2,6,23,0.6); backdrop-filter: blur(4px); }
.modal-panel { position: relative; z-index: 1; background: var(--surface); border-radius: 12px; padding: 18px; width: min(560px, 96%); box-shadow: 0 20px 50px rgba(2,6,23,0.35); border: 1px solid rgba(15,23,36,0.06); }
.modal-panel h3 { margin: 0 0 10px 0; }
.modal-panel label { display: block; margin-bottom: 10px; font-size: 14px; }
.modal-panel input[type="text"], .modal-panel input[type="number"] { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid #e6e9ef; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.mt-4 { margin-top: 12px; }
.modal .chip { padding: 6px 8px; font-size: 13px; background: #f3f7fb; border-radius: 8px; border: 1px solid #e6eefb; cursor: pointer; }
#addMsg { min-height: 18px; color: var(--muted); }

/* open link button */
.openLink { display:inline-flex; align-items:center; gap:6px; padding:6px 10px; border-radius:8px; background:#f3f7fb; color:var(--text); text-decoration:none; font-size:13px; border:1px solid rgba(0,0,0,0.05); }
.openLink:hover { transform:translateY(-2px); box-shadow:0 6px 18px rgba(2,6,23,0.06); }

/* copy title button */
.copyTitle { display:inline-flex; align-items:center; gap:6px; padding:6px 10px; border-radius:8px; background:#fff9e6; color:var(--text); font-size:13px; border:1px solid rgba(0,0,0,0.05); cursor:pointer; }
.copyTitle:hover { transform:translateY(-2px); box-shadow:0 6px 18px rgba(2,6,23,0.06); }
.copyTitle[disabled] { opacity:0.6; cursor:not-allowed; }
