/* Shared component system. Keep this stylesheet last in the document head. */
:root {
  --ui-surface: rgba(15, 23, 38, .92);
  --ui-surface-raised: rgba(21, 31, 49, .96);
  --ui-surface-hover: rgba(31, 45, 67, .96);
  --ui-border: rgba(125, 211, 252, .16);
  --ui-border-strong: rgba(103, 232, 249, .42);
  --ui-radius-sm: 10px;
  --ui-radius-md: 16px;
  --ui-radius-lg: 22px;
  --ui-shadow: 0 18px 46px rgba(0, 0, 0, .28);
  --ui-shadow-hover: 0 20px 50px rgba(0, 0, 0, .36), 0 0 28px rgba(34, 211, 238, .08);
  --ui-space-2: 10px;
  --ui-space-4: 24px;
}

:where(.settings-card, .stat-card, .analytics-card, .training-card,
  .recommendation-card, .profile-header-card) {
  border: 1px solid var(--ui-border);
  background: linear-gradient(145deg, rgba(103, 232, 249, .035), transparent 45%), var(--ui-surface);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .16);
}
:where(.stat-card, .analytics-card, .training-card, .recommendation-card) {
  border-radius: var(--ui-radius-md);
}
:where(.training-card, .recommendation-card, .stat-card) {
  transition: border-color .2s ease, background-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
@media (hover: hover) {
  :where(.training-card, .recommendation-card, .stat-card):hover {
    border-color: var(--ui-border-strong);
    background-color: var(--ui-surface-hover);
    box-shadow: var(--ui-shadow-hover);
    transform: translateY(-2px);
  }
}

:where(.shortcuts-modal, .fav-categories-modal, .install-modal) {
  width: min(92vw, 520px);
  max-height: min(84vh, 720px);
  overflow: auto;
  border: 1px solid var(--ui-border-strong);
  border-radius: var(--ui-radius-lg);
  background: var(--ui-surface-raised);
  box-shadow: var(--ui-shadow);
  color: var(--text-primary);
  scrollbar-gutter: stable;
}
:where(.shortcuts-modal, .fav-categories-modal, .install-modal) :where(h2, h3) {
  margin-top: 0;
  line-height: 1.25;
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-md);
  background: var(--ui-surface);
  scrollbar-gutter: stable;
}
.table-wrap table { min-width: 620px; }
.table-wrap th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--ui-surface-raised);
  letter-spacing: .04em;
}
.table-wrap tbody tr { transition: background-color .16s ease; }
.table-wrap tbody tr:hover { background: rgba(103, 232, 249, .055); }
.table-wrap tbody tr:last-child td { border-bottom: 0; }

:where(.mylist-empty, .fav-categories-empty) {
  display: grid;
  place-items: center;
  gap: var(--ui-space-2);
  min-height: 180px;
  padding: var(--ui-space-4);
  border: 1px dashed var(--ui-border-strong);
  border-radius: var(--ui-radius-md);
  background: linear-gradient(145deg, rgba(103, 232, 249, .045), transparent);
  color: var(--text-muted);
  text-align: center;
}
:where(.mylist-empty, .fav-categories-empty) p { margin: 0; }

@media (max-width: 767px) {
  :root { --ui-radius-lg: 18px; --ui-space-4: 18px; }
  :where(.settings-card, .analytics-card, .training-card) { border-radius: var(--ui-radius-sm); }
  .table-wrap { margin-inline: -4px; }
}
@media (prefers-reduced-motion: reduce) {
  :where(.training-card, .recommendation-card, .stat-card), .table-wrap tbody tr { transition: none; }
}

/* Book cards: cover first, readable title and author underneath. */
.book-card-compact { position: relative; }
.book-card-compact .book-card-open {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}
.book-card-compact .cover-area { width: 100%; flex: 0 0 auto; }
.book-card-compact .info-area {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 11px 12px 13px;
  text-align: left;
}
.book-card-compact .book-title-text { font-size: 13px; line-height: 1.35; }
.book-card-compact .book-author-text {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.book-card-compact .book-card-year { margin-top: 1px; }
.book-card-remove {
  position: absolute;
  top: 7px;
  right: 7px;
  z-index: 5;
  display: grid;
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 50%;
  background: rgba(5, 10, 18, .86);
  box-shadow: 0 5px 16px rgba(0, 0, 0, .35);
  color: #fff;
  font: 700 19px/1 system-ui, sans-serif;
  cursor: pointer;
}
.book-card-remove:hover { border-color: #fda4af; background: #881337; }
.book-card-compact:has(.book-card-remove) .offline-badge { top: 49px; }

/* Book detail actions: one primary action and compact secondary controls. */
#detailScreen .detail-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}
#detailScreen .btn-detail {
  min-height: 42px;
  padding: 10px 15px;
  justify-content: center;
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  background: var(--ui-surface);
  color: var(--text-secondary);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .14);
}
#detailScreen .btn-detail:hover {
  border-color: var(--ui-border-strong);
  background: var(--ui-surface-hover);
  color: var(--text-primary);
  transform: translateY(-1px);
}
#detailScreen .detail-action-primary {
  flex: 1 1 180px;
  color: #041017;
  border-color: transparent;
  background: #67e8f9;
  box-shadow: 0 8px 24px rgba(34, 211, 238, .18);
}
#detailScreen .detail-action-primary:hover { background: #a5f3fc; color: #041017; }
#detailScreen .detail-action-secondary { flex: 1 1 180px; }
#detailScreen .detail-action-admin { margin-left: auto; }
#detailScreen .detail-icon-button {
  flex: 0 0 42px;
  width: 42px;
  padding: 0;
}
#detailScreen .offline-btn-saved {
  border-color: rgba(248, 113, 113, .28);
  background: rgba(127, 29, 29, .12);
  color: #fca5a5;
}
#detailScreen .offline-btn-saved:hover {
  border-color: rgba(248, 113, 113, .62);
  background: rgba(127, 29, 29, .28);
  color: #fecaca;
}
@media (max-width: 620px) {
  #detailScreen .detail-actions { align-items: stretch; }
  #detailScreen .detail-action-primary,
  #detailScreen .detail-action-secondary { flex: 1 1 calc(100% - 51px); }
  #detailScreen .detail-action-admin { flex: 1 1 100%; margin-left: 0; }
}
