/* assets/app.css */

/* --------- Base + Theme --------- */

:root {
  --bg: #050816;
  --bg-alt: #0b1020;
  --card-bg: #111827;
  --card-elevated: #151b2f;
  --border-subtle: rgba(255, 255, 255, 0.06);

  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.2);
  --accent-strong: #0ea5e9;
  --danger: #f97373;
  --danger-soft: rgba(248, 113, 113, 0.12);

  --radius-lg: 16px;
  --radius-xl: 22px;
  --shadow-soft: 0 18px 40px rgba(15, 23, 42, 0.7);

  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  background: radial-gradient(circle at top left, #1d2438 0, #050816 40%);
  color: var(--text-main);
}

/* --------- App Shell --------- */

.app-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

@media (min-width: 1024px) {
  .app-shell {
    padding: 32px 0 48px;
  }
}

/* --------- Shared Header --------- */

.app-header {
  background: linear-gradient(135deg, #020617 0%, #0f172a 50%, #1e293b 100%);
  border-radius: 999px;
  padding: 10px 18px;
  margin-bottom: 24px;
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.8);
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 12px;
  z-index: 20;
  backdrop-filter: blur(18px);
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-logo {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 20%, #38bdf8, #0f172a 60%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.06em;
  color: white;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.7), 0 10px 25px rgba(8, 47, 73, 0.7);
}

.app-title {
  display: flex;
  flex-direction: column;
}

.app-title span:first-child {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #e5e7eb;
}

.app-title span:last-child {
  font-size: 12px;
  color: var(--text-muted);
}

.app-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.app-nav a {
  color: var(--text-main);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease,
    transform 0.1s ease;
}

.app-nav a:hover {
  color: #ffffff;
  border-color: rgba(148, 163, 184, 0.45);
  background: rgba(15, 23, 42, 0.8);
  transform: translateY(-1px);
}

.app-nav a.app-nav-primary {
  background: var(--accent-soft);
  color: #e0f2fe;
  border-color: rgba(56, 189, 248, 0.7);
}

.app-nav a.app-nav-primary:hover {
  background: rgba(56, 189, 248, 0.2);
}

/* --------- Generic Card --------- */

.card {
  background: radial-gradient(circle at top left, #111827 0, #020617 55%);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border-subtle);
  padding: 22px 20px 20px;
  color: #fff;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 18px;
  font-weight: 600;
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

/* Two-column layout on desktop for details pages */
.card-grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
  gap: 24px;
}

@media (max-width: 768px) {
  .card-grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* --------- Forms --------- */

.form-grid-2 {
  display: grid;
  grid-template-columns: 1.2fr 2fr;
  gap: 16px 24px;
}

@media (max-width: 768px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: inline-block;
}

input[type="text"],
input[type="number"],
input[type="url"],
textarea,
select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  padding: 9px 11px;
  background: rgba(15, 23, 42, 0.95);
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s;
}

input::placeholder,
textarea::placeholder {
  color: rgba(148, 163, 184, 0.8);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.4);
}

/* --------- Buttons --------- */

.btn {
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(31, 41, 55, 0.9);
  color: var(--text-main);
  transition: background 0.18s ease, transform 0.08s ease, box-shadow 0.18s ease;
}

.btn span.emoji {
  font-size: 16px;
}

.btn:hover {
  background: rgba(55, 65, 81, 1);
  transform: translateY(-1px);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.7);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-strong), #22c55e);
  color: #0b1120;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #38bdf8, #4ade80);
}

.btn-outline {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.6);
}

.btn-danger {
  background: var(--danger-soft);
  color: #fecaca;
}

/* Utility button rows */
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* --------- Tag Pills --------- */

.tag-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.tag {
  background: rgba(15, 23, 42, 0.9);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  color: #e5e7eb;
  border: 1px solid rgba(148, 163, 184, 0.7);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.08s ease, border-color 0.16s;
}

.tag:hover {
  background: rgba(30, 64, 175, 0.9);
  transform: translateY(-1px);
}

.tag.red {
  border-color: rgba(248, 113, 113, 0.9);
  background: rgba(127, 29, 29, 0.9);
}

.tag .trash {
  display: none;
  font-size: 13px;
}

.tag.red .trash {
  display: inline;
}

/* --------- Chapters / details --------- */

details {
  background: linear-gradient(135deg, #020617 0%, #020617 60%, #0b1120 100%);
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  padding: 10px 12px;
  margin-bottom: 10px;
}

details summary {
  list-style: none;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
}

details[open] summary {
  margin-bottom: 6px;
}

details summary::-webkit-details-marker {
  display: none;
}

.chapter-content {
  font-size: 13px;
  color: var(--text-main);
}

/* rating stars */
.rating {
  margin-top: 6px;
}

.star {
  font-size: 18px;
  cursor: pointer;
  color: #4b5563;
  padding: 0 1px;
}

.star.gold {
  color: #fbbf24;
}

/* --------- Table (for mapping, lists, etc.) --------- */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 8px;
  border-bottom: 1px solid rgba(31, 41, 55, 0.9);
}

th {
  text-align: left;
  font-weight: 500;
  color: #e5e7eb;
  background: rgba(15, 23, 42, 0.9);
}

/* --------- Toast --------- */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #e5e7eb;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  font-size: 13px;
  box-shadow: 0 16px 35px rgba(15, 23, 42, 0.9);
  z-index: 9999;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

/* --------- AI Modal (book page) --------- */

#aiModal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(14px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

#aiModal .content {
  background: #020617;
  color: #e5e7eb;
  padding: 20px 22px;
  border-radius: 18px;
  max-width: 720px;
  max-height: 80vh;
  overflow: auto;
  border: 1px solid rgba(148, 163, 184, 0.55);
  box-shadow: 0 18px 45px rgba(15, 23, 42, 1);
  position: relative;
}

#aiModal button.close {
  position: absolute;
  top: 10px;
  right: 10px;
}

/* --------- Lists / Pills / Inline Links --------- */

.section-title {
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.section-slim {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 12px;
  margin-top: 12px;
  background: var(--card-elevated);
}

.mini-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0;
}

.mini-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.02);
}

.mini-row .mini-main {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.mini-row .item-title {
  font-weight: 600;
}

.mini-row .small {
  font-size: 12px;
}

.mini-row.muted {
  opacity: 0.6;
}

.pill {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--accent-soft);
  color: #e0f2fe;
  margin-right: 6px;
}

.pill-muted {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.inline-link {
  color: var(--accent);
  text-decoration: none;
}

.inline-link:hover {
  text-decoration: underline;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 12px;
  cursor: pointer;
}

.btn-ghost:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

.inline-label {
  margin-top: 12px;
  display: block;
}

.stacked-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.note {
  margin-top: 6px;
}

/* --------- Utility --------- */

.text-muted {
  color: var(--text-muted);
  font-size: 13px;
}

.section {
  margin-top: 20px;
}

/* --------- GLOBAL LINK + SELECT OVERRIDES --------- */

/* Make ALL links white everywhere */
.a,
.a:visited {
  color: #ffffff !important;
  text-decoration: none;
}

.a:hover {
  color: #e5e5e5 !important;
  text-decoration: underline;
}

/* Make select text white in the closed state */
.select {
  color: #ffffff !important;
  background-color: rgba(15, 23, 42, 0.95) !important;
}
