/* ============================================================
   Song Lyrics to Ebook — web UI stylesheet
   ============================================================ */

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

:root {
  --brand:       #1a1a2e;
  --brand-hover: #16213e;
  --accent:      #e94560;
  --bg:          #f4f6f8;
  --surface:     #ffffff;
  --border:      #dde1e7;
  --text:        #1e2a38;
  --muted:       #6b7a8d;
  --success:     #27ae60;
  --error:       #c0392b;
  --radius:      8px;
  --shadow:      0 1px 4px rgba(0,0,0,.08);
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  background: var(--brand);
  color: #fff;
  padding: 1.25rem 2rem;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
  flex-shrink: 0;
}

header h1 {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

header .subtitle {
  margin-top: 0.25rem;
  font-size: 0.9rem;
  opacity: 0.7;
}

/* ── Main content area ── */
main {
  flex: 1;
  min-height: 0;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  overflow: hidden;
}

/* ── Search bar ── */
.search-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.search-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.search-bar input[type="search"] {
  flex: 1;
  min-width: 200px;
  max-width: 420px;
  padding: 0.55rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-bar input[type="search"]:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26,26,46,.12);
}

/* ── Buttons ── */
button {
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  padding: 0.55rem 1.4rem;
  transition: background 0.15s, opacity 0.15s;
}

#searchBtn {
  background: var(--brand);
  color: #fff;
}

#searchBtn:hover:not(:disabled) {
  background: var(--brand-hover);
}

#createEbookBtn {
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 1.6rem;
  font-size: 1rem;
}

#createEbookBtn:hover:not(:disabled) {
  background: #c73652;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Status line ── */
.status {
  font-size: 0.875rem;
  color: var(--muted);
  min-height: 1.25em;
}

.status.error   { color: var(--error); }
.status.success { color: var(--success); }
.status.warning { color: #b7770d; }

/* ── Three-column browser ── */
.content-area {
  display: grid;
  grid-template-columns: 1fr 1.6fr 1fr;
  gap: 1rem;
  flex: 1;
  min-height: 0;
}

/* ── Panel (shared card style) ── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.9rem;
  background: #f0f2f5;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-header h2 {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  flex: 1;
}

.panel-controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.album-search-input {
  width: 170px;
  max-width: 42vw;
  font-size: 0.82rem;
  padding: 0.28rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
}

.album-search-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(26, 26, 46, 0.12);
}

.filter-label {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.panel-header select {
  font-size: 0.82rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

/* ── Selectable list ── */
.selectable-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

.selectable-list li {
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  border-bottom: 1px solid #f0f2f5;
  font-size: 0.9rem;
  transition: background 0.1s;
  user-select: none;
}

.selectable-list li:hover {
  background: #f7f8fa;
}

.selectable-list li.selected {
  background: #e8eeff;
  font-weight: 600;
  color: var(--brand);
}

.selectable-list li:last-child {
  border-bottom: none;
}

.selectable-list li.empty-row {
  color: var(--muted);
  font-style: italic;
  cursor: default;
}

.selectable-list li.empty-row:hover {
  background: transparent;
}

.item-name {
  display: block;
}

.item-meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 1px;
}

/* ── Album art ── */
.album-art-wrapper {
  padding: 0.65rem;
  display: flex;
  justify-content: center;
  background: #f0f2f5;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.album-art {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius);
  display: block;
  background: var(--border);
}

/* Placeholder shown when no real art is loaded (src is empty/unset) */
.album-art.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--muted);
  background: #e4e8ee;
  /* Prevent broken-image icon in browsers by hiding the element's default
     broken-image appearance when src is a data-URI placeholder */
}

/* ── Track list ── */
.track-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

.track-list li {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.45rem 0.9rem;
  border-bottom: 1px solid #f0f2f5;
  font-size: 0.875rem;
}

.track-list li:last-child {
  border-bottom: none;
}

.track-num {
  color: var(--muted);
  min-width: 1.8em;
  text-align: right;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.track-title {
  flex: 1;
}

.track-dur {
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ── Action area ── */
.action-area {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

/* ── Progress bar ── */
.progress-container {
  flex: 1;
  min-width: 200px;
  max-width: 480px;
}

.progress-bar {
  height: 7px;
  background: #dde1e7;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.35rem;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.35s ease;
}

.progress-label {
  font-size: 0.82rem;
  color: var(--muted);
}

/* ── Settings panel ── */
.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0 1rem;
}

.settings-section summary {
  padding: 0.75rem 0;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.settings-section summary::-webkit-details-marker { display: none; }

.settings-content {
  padding-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.settings-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

.settings-label input[type="password"] {
  display: block;
  width: 100%;
  max-width: 420px;
  margin-top: 0.3rem;
  padding: 0.45rem 0.8rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

.settings-label input[type="password"]:focus {
  border-color: var(--brand);
}

.settings-label input[type="checkbox"] {
  margin-right: 0.45rem;
  cursor: pointer;
}

.hint {
  font-size: 0.82rem;
  color: var(--muted);
}

.hint a, .hint-inline {
  color: var(--muted);
}

.hint a:hover {
  color: var(--brand);
}

/* ── Footer ── */
footer {
  background: var(--brand);
  color: rgba(255,255,255,0.55);
  text-align: center;
  padding: 0.85rem 1.5rem;
  font-size: 0.8rem;
  flex-shrink: 0;
}

footer a {
  color: rgba(255,255,255,0.75);
  text-decoration: none;
}

footer a:hover {
  color: #fff;
  text-decoration: underline;
}

/* ── Disclaimer notice ── */
.disclaimer-notice {
  background: #fffbe6;
  border: 1px solid #f5e642;
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  font-size: 0.82rem;
  color: #5a4a00;
  flex-shrink: 0;
}

/* ── Responsive ── */
@media (max-width: 780px) {
  body {
    height: auto;
    overflow: auto;
  }

  main {
    overflow: visible;
    min-height: unset;
  }

  .content-area {
    grid-template-columns: 1fr;
    flex: none;
    min-height: unset;
  }

  .panel {
    max-height: 240px;
    min-height: unset;
  }
}

@media (max-width: 480px) {
  header { padding: 1rem; }
  header h1 { font-size: 1.3rem; }
}
