/* ReadStash - Styles */

/* ── Reset & Base ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #faf9f6;
  --bg-card: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #555;
  --text-on-border: #444;
  --border: #e0ddd5;
  --accent: #4a6fa5;
  --accent-hover: #3d5d8a;
  --danger: #c0392b;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-hover: 0 2px 8px rgba(0,0,0,0.12);
  --radius: 8px;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: Georgia, 'Times New Roman', Times, serif;
  --header-height: 56px;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── Dark Mode ── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a2e;
    --bg-card: #232340;
    --text: #e8e6e3;
    --text-secondary: #ababbc;
    --text-on-border: #c0c0d0;
    --border: #333355;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-hover: 0 2px 8px rgba(0,0,0,0.4);
  }
}

/* ── Screens ── */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg);
}

.screen.active {
  display: flex;
}

/* ── Header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--header-height);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}

.app-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Buttons ── */
.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: rgba(0,0,0,0.06);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: var(--radius);
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: none;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 10px 24px;
  border-radius: var(--radius);
  font-size: 16px;
  cursor: pointer;
}

.btn-setting {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  margin-bottom: 8px;
}

.btn-setting:hover {
  background: var(--border);
}

.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}

/* ── Online Indicator ── */
.online-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2ecc71;
  display: inline-block;
}

.online-indicator.offline {
  background: #e74c3c;
}

/* ── Search Bar ── */
.search-bar {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-bar input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  background: var(--bg-card);
  color: var(--text);
  outline: none;
}

.search-bar input:focus {
  border-color: var(--accent);
}

/* ── Filter Tabs ── */
.filter-tabs {
  display: flex;
  padding: 8px 16px;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tab {
  flex: 1;
  padding: 8px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Tag Filters ── */
.tag-filters {
  display: flex;
  gap: 6px;
  padding: 8px 16px;
  overflow-x: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}

.tag-filter-chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.tag-filter-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Article List ── */
.article-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 80px;
}

.article-card {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.2s;
}

.article-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}

.card-content {
  flex: 1;
  min-width: 0;
  position: relative;
}

.card-title {
  font-size: 15px;
  font-weight: 400;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-title.unread {
  font-weight: 700;
}

.unread-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  vertical-align: middle;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.card-tags {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.tag-chip-small {
  background: var(--border);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  color: var(--text-on-border);
}

.fetch-pending {
  color: #8a4800;
  font-style: italic;
}

.card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  margin-left: 8px;
}

.card-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
}

.card-btn:hover {
  background: rgba(0,0,0,0.06);
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
  font-size: 16px;
}

/* ── FAB ── */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: transform 0.2s, box-shadow 0.2s;
}

.fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0,0,0,0.25);
}

/* ── Modal ── */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-content {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-content h2 {
  margin-bottom: 16px;
  font-size: 20px;
}

.input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.input-group input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}

.input-group input:focus {
  border-color: var(--accent);
}

.clipboard-suggestion {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(74,111,165,0.08);
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 12px;
}

.clipboard-suggestion span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clipboard-suggestion button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Reader View ── */
.reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.reader-actions {
  display: flex;
  gap: 4px;
}

.font-size-panel {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.size-btn {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: none;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}

.size-btn[data-size="small"] { font-size: 12px; }
.size-btn[data-size="large"] { font-size: 18px; }

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

/* ── Reader Content ── */
.reader-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px 40px;
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
}

.reader-meta {
  margin-bottom: 24px;
}

.reader-title {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 12px;
  letter-spacing: -0.3px;
}

.reader-info {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 14px;
  color: var(--text-secondary);
}

.reader-body {
  font-size: 17px;
  line-height: 1.7;
  letter-spacing: 0.01em;
}

.reader-body[data-font-size="small"] { font-size: 15px; }
.reader-body[data-font-size="large"] { font-size: 20px; line-height: 1.8; }

.reader-body[data-font-family="serif"] {
  font-family: Georgia, 'Times New Roman', Times, serif;
}

.reader-body[data-font-family="sans-serif"] {
  font-family: var(--font-sans);
}

.reader-body p {
  margin-bottom: 16px;
}

.reader-body h1, .reader-body h2, .reader-body h3,
.reader-body h4, .reader-body h5, .reader-body h6 {
  margin: 24px 0 12px;
  line-height: 1.3;
}

.reader-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 16px;
  margin: 16px 0;
  color: var(--text-secondary);
  font-style: italic;
}

.reader-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 16px 0;
}

.reader-body pre {
  background: var(--border);
  padding: 12px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 16px 0;
  font-size: 14px;
}

.reader-body code {
  background: var(--border);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.9em;
}

.reader-body a {
  color: var(--accent);
}

.no-content {
  color: var(--text-secondary);
  font-style: italic;
  text-align: center;
  padding: 40px 0;
}

/* ── Reader Themes ── */
#screen-reader[data-theme="dark"] {
  background: #1a1a2e;
  color: #e8e6e3;
}

#screen-reader[data-theme="dark"] .reader-toolbar {
  border-color: #333355;
}

#screen-reader[data-theme="dark"] .reader-info {
  color: #a0a0b0;
}

#screen-reader[data-theme="dark"] .icon-btn {
  color: #e8e6e3;
}

#screen-reader[data-theme="sepia"] {
  background: #f4ecd8;
  color: #433422;
}

#screen-reader[data-theme="sepia"] .reader-toolbar {
  background: #f4ecd8;
  border-color: #d4c9a8;
}

#screen-reader[data-theme="sepia"] .reader-info {
  color: #7a6a52;
}

#screen-reader[data-theme="light"] {
  background: #faf9f6;
  color: #1a1a2e;
}

/* ── Reader Tags ── */
.reader-tags {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
}

.tag-input-group {
  position: relative;
  margin-bottom: 8px;
}

.tag-input-group input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}

.tag-input-group input:focus {
  border-color: var(--accent);
}

.tag-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  z-index: 10;
  max-height: 150px;
  overflow-y: auto;
}

.tag-suggestion {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
}

.tag-suggestion:hover {
  background: rgba(0,0,0,0.04);
}

.article-tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--border);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 13px;
  color: var(--text-on-border);
}

.tag-remove {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
}

.tag-remove:hover {
  color: var(--danger);
}

/* ── Reading Progress ── */
.reading-progress {
  height: 3px;
  background: var(--border);
  flex-shrink: 0;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.1s linear;
}

/* ── Settings ── */
.settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.settings-section {
  margin-bottom: 24px;
}

.settings-section h3 {
  font-size: 14px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.setting-row label {
  font-size: 15px;
}

.setting-row select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.about-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

/* ── Premium Badge ── */
.premium-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.premium-badge-pro {
  background: linear-gradient(135deg, #f5c842, #e6a817);
  color: #5a4000;
}

.premium-badge-free {
  background: var(--border);
  color: var(--text-on-border);
}

/* ── Premium Modal ── */
.premium-modal .premium-modal-content {
  text-align: center;
}

.premium-modal-title {
  font-size: 22px;
  margin-bottom: 8px;
}

.premium-trigger {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 16px;
}

.premium-feature-list {
  list-style: none;
  text-align: left;
  margin: 16px 0;
  padding: 0;
}

.premium-feature-item {
  padding: 6px 0;
  font-size: 14px;
  position: relative;
  padding-left: 24px;
}

.premium-feature-item::before {
  content: '\2713';
  position: absolute;
  left: 0;
  color: #2ecc71;
  font-weight: 700;
}

.btn-premium-subscribe {
  display: block;
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #f5c842, #e6a817);
  color: #5a4000;
  border: none;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  margin: 16px 0 8px;
  transition: opacity 0.2s;
}

.btn-premium-subscribe:hover {
  opacity: 0.9;
}

.premium-cancel-note {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.btn-premium-restore {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
  display: block;
  margin: 0 auto 12px;
}

.premium-close-btn {
  width: 100%;
}

.premium-restore-desc {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 16px;
}

/* ── Expiry Warning Banner ── */
.expiry-warning-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #fff3cd;
  color: #856404;
  font-size: 13px;
  flex-shrink: 0;
}

.btn-renew {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.btn-dismiss-expiry {
  background: none;
  border: none;
  color: #856404;
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  margin-left: auto;
}

@media (prefers-color-scheme: dark) {
  .expiry-warning-banner {
    background: #433a1a;
    color: #f5c842;
  }

  .btn-dismiss-expiry {
    color: #f5c842;
  }
}

/* ── Hidden Utility ── */
.hidden {
  display: none !important;
}

/* ── Responsive ── */
@media (min-width: 768px) {
  .article-list {
    max-width: 720px;
    margin: 0 auto;
  }

  .modal-content {
    max-width: 480px;
  }

  .reader-content {
    padding: 32px 24px 60px;
  }
}

@media (max-width: 480px) {
  .reader-title {
    font-size: 22px;
  }

  .reader-body {
    font-size: 16px;
  }

  .reader-body[data-font-size="large"] {
    font-size: 18px;
  }
}
