/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Theme variables */
:root {
  /* Text */
  --color-text: #333;
  --color-text-secondary: #666;
  --color-text-tertiary: #757575;
  --color-text-disabled: #999;

  /* Backgrounds */
  --color-bg: #fff;
  --color-bg-secondary: #f9f9f9;
  --color-bg-tertiary: #f5f5f5;
  --color-bg-hover: #f0f0f0;
  --color-bg-active: #e8e8e8;

  /* Accent */
  --color-accent: #0066cc;
  --color-accent-hover: #0052a3;
  --color-accent-bg: #e6f2ff;
  --color-accent-focus: rgba(0, 102, 204, 0.15);

  /* Borders */
  --color-border: #ddd;
  --color-border-light: #e8e8e8;
  --color-border-dark: #ccc;

  /* Success */
  --color-success-bg: #e8f5e9;
  --color-success-text: #2e7d32;
  --color-success-border: #c8e6c9;

  /* Error */
  --color-error-bg: #fce4ec;
  --color-error-text: #c62828;
  --color-error-border: #f8bbd0;

  /* Shadows */
  --shadow-card: rgba(0, 0, 0, 0.08);
  --shadow-dialog: rgba(0, 0, 0, 0.2);
  --shadow-backdrop: rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Text */
    --color-text: #e0e0e0;
    --color-text-secondary: #a0a0a0;
    --color-text-tertiary: #888;
    --color-text-disabled: #666;

    /* Backgrounds */
    --color-bg: #1a1a1a;
    --color-bg-secondary: #222;
    --color-bg-tertiary: #2a2a2a;
    --color-bg-hover: #333;
    --color-bg-active: #444;

    /* Accent */
    --color-accent: #4da6ff;
    --color-accent-hover: #80bfff;
    --color-accent-bg: rgba(77, 166, 255, 0.15);
    --color-accent-focus: rgba(77, 166, 255, 0.25);

    /* Borders */
    --color-border: #444;
    --color-border-light: #333;
    --color-border-dark: #555;

    /* Success */
    --color-success-bg: #1b3a1e;
    --color-success-text: #66bb6a;
    --color-success-border: #2e5731;

    /* Error */
    --color-error-bg: #3a1a1e;
    --color-error-text: #ef9a9a;
    --color-error-border: #5c2a30;

    /* Shadows */
    --shadow-card: rgba(0, 0, 0, 0.3);
    --shadow-dialog: rgba(0, 0, 0, 0.5);
    --shadow-backdrop: rgba(0, 0, 0, 0.7);
  }
}

/* Flash messages */
.flash-notice,
.flash-alert {
  padding: 12px 16px;
  font-size: 14px;
}

.flash-notice {
  background: var(--color-success-bg);
  color: var(--color-success-text);
  border-bottom: 1px solid var(--color-success-border);
}

.flash-alert {
  background: var(--color-error-bg);
  color: var(--color-error-text);
  border-bottom: 1px solid var(--color-error-border);
}

/* Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
}

body:has(.three-pane-layout) {
  height: 100vh;
  overflow: hidden;
}

/* 3-pane layout */
.three-pane-layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  height: 100vh;
  gap: 0;
}

/* Left pane: Feed list */
.feed-list-pane {
  border-right: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.feed-list-pane .pane-header {
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.feed-list-pane h1 {
  font-size: 20px;
  margin-bottom: 8px;
}

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

.pin-list-link {
  font-size: 12px;
  color: var(--color-accent);
  text-decoration: none;
}

.pin-list-link:hover {
  text-decoration: underline;
}

.pin-badge {
  display: inline-block;
  background: var(--color-text-secondary);
  color: #fff;
  font-size: 10px;
  font-weight: bold;
  padding: 1px 5px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
}

.settings-dropdown {
  position: relative;
}

.settings-dropdown-toggle {
  background: none;
  border: none;
  font-size: 12px;
  color: var(--color-accent);
  cursor: pointer;
  padding: 6px 8px;
}

.settings-dropdown-toggle:hover,
.settings-dropdown-toggle:focus-visible {
  background: var(--color-bg-hover);
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.settings-dropdown-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 4px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-shadow: 0 4px 12px var(--shadow-dialog);
  min-width: 160px;
  z-index: 100;
  padding: 4px 0;
}

.settings-dropdown-item {
  display: block;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--color-text);
  text-decoration: none;
}

.settings-dropdown-item:hover {
  background: var(--color-bg-hover);
}

.settings-dropdown-item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
  background: var(--color-bg-hover);
}

.reload-button {
  background: none;
  border: none;
  color: var(--color-accent);
  cursor: pointer;
  padding: 2px;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

.reload-button:hover {
  color: var(--color-text);
}

.rate-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.rate-filter-link {
  font-size: 11px;
  color: var(--color-accent);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 3px;
}

.rate-filter-link:hover {
  background: var(--color-bg-hover);
}

.rate-filter-link:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.rate-filter-link--active {
  background: var(--color-accent-bg);
  color: var(--color-text);
  font-weight: bold;
}

.feed-list {
  overflow-y: auto;
  flex: 1;
}

.feed-folder-header {
  padding: 6px 16px;
  font-size: 11px;
  font-weight: bold;
  color: var(--color-text-secondary);
  background: var(--color-bg-tertiary);
  border-top: 1px solid var(--color-border);
  letter-spacing: 0.02em;
}

.feed-folder-header:first-child {
  border-top: none;
}

.feed-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border-light);
  text-decoration: none;
  color: var(--color-text);
  background: var(--color-bg);
  transition: background 0.2s;
}

.feed-item:hover {
  background: var(--color-bg-hover);
}

.feed-item[data-active="true"] {
  background: var(--color-accent-bg);
  border-left: 3px solid var(--color-accent);
}

.feed-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unread-badge {
  display: inline-block;
  background: var(--color-accent);
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

/* Right pane: Content area */
.content-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.entry-list-pane,
.entry-detail-pane {
  overflow-y: auto;
  background: var(--color-bg);
}

.entry-list-pane {
  flex: 1;
  border-bottom: 1px solid var(--color-border);
}

.entry-detail-pane {
  flex: 1;
}

.pane-header {
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
}

.pane-header h2 {
  font-size: 16px;
  font-weight: 600;
}

/* Entry list */
.entry-list {
  display: flex;
  flex-direction: column;
}

.entry-item {
  display: block;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border-light);
  text-decoration: none;
  color: var(--color-text);
  transition: background 0.2s;
}

.entry-item:hover {
  background: var(--color-bg-secondary);
}

.entry-item[data-active="true"] {
  background: var(--color-accent-bg);
  border-left: 3px solid var(--color-accent);
}

.entry-unread {
  font-weight: 600;
}

.entry-read {
  opacity: 0.5;
}

.entry-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.pin-icon {
  font-size: 12px;
}

.entry-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

/* Hatena Bookmark count (Hatena brand orange) */
.hatena-count {
  font-size: 11px;
  color: #ff6600;
}

.hatena-count-clickable {
  cursor: pointer;
}

.hatena-count-clickable:hover {
  text-decoration: underline;
}

/* Entry detail */
.entry-detail {
  padding: 24px;
  max-width: 800px;
  margin: 0 auto;
}

.entry-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border-light);
}

.entry-header h2 {
  font-size: 24px;
  margin-bottom: 8px;
  line-height: 1.4;
}

.entry-header .entry-meta {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 12px;
}

.entry-actions {
  display: flex;
  gap: 12px;
}

.pin-button,
.external-link {
  font-size: 13px;
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg);
  color: var(--color-text);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s;
}

.pin-button:hover,
.external-link:hover {
  background: var(--color-bg-hover);
}

.entry-body {
  font-size: 15px;
  line-height: 1.8;
  color: var(--color-text);
}

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

.entry-body a {
  color: var(--color-accent);
  text-decoration: none;
}

.entry-body a:hover {
  text-decoration: underline;
}

.entry-body img {
  max-width: 100%;
  height: auto;
  margin: 16px 0;
}

.entry-body pre {
  background: var(--color-bg-tertiary);
  padding: 12px;
  border-radius: 4px;
  overflow-x: auto;
  margin-bottom: 16px;
}

.entry-body code {
  font-family: Monaco, Consolas, "Courier New", monospace;
  font-size: 13px;
}

.entry-body blockquote {
  border-left: 4px solid var(--color-border);
  padding-left: 16px;
  margin: 16px 0;
  color: var(--color-text-secondary);
}

@media (prefers-color-scheme: dark) {
  .entry-body img {
    opacity: 0.9;
  }
}

/* Empty message */
.empty-message {
  padding: 32px;
  text-align: center;
  color: var(--color-text-tertiary);
}

.empty-message p {
  margin-bottom: 8px;
}

.empty-message a {
  color: var(--color-accent);
}

/* Focus styles */
.feed-item:focus-visible,
.entry-item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

/* Management pages (feeds, import) */
.manage-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
}

.manage-page h1 {
  font-size: 24px;
  margin-bottom: 16px;
}

.manage-nav {
  margin-bottom: 16px;
}

.manage-nav a {
  color: var(--color-accent);
  text-decoration: none;
  font-size: 14px;
}

.manage-nav a:hover {
  text-decoration: underline;
}

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

.manage-action-link:hover {
  text-decoration: underline;
}

.manage-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}

.manage-table th,
.manage-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border-light);
  text-align: left;
}

.manage-table th {
  background: var(--color-bg-secondary);
  font-weight: 600;
  font-size: 13px;
  color: var(--color-text-secondary);
}

.manage-table-url {
  font-size: 13px;
  color: var(--color-text-secondary);
  word-break: break-all;
}

/* Management form */
.manage-form {
  margin-top: 16px;
}

.manage-form-field {
  margin-bottom: 16px;
}

.manage-form-field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

.manage-submit {
  padding: 8px 20px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
}

.manage-submit:hover {
  background: var(--color-accent-hover);
}

/* Feed status badges */
.status-ok { color: var(--color-success-text); }
.status-error { color: var(--color-error-text); }
.feed-error-message { font-size: 12px; color: var(--color-error-text); margin-top: 2px; }

/* Management actions & buttons */
.manage-actions { display: flex; gap: 8px; align-items: center; }
.manage-btn-small { padding: 4px 10px; font-size: 13px; border: 1px solid var(--color-border); border-radius: 4px; background: var(--color-bg); color: var(--color-text); text-decoration: none; cursor: pointer; }
.manage-btn-small:hover { background: var(--color-bg-hover); }
.manage-btn-danger { color: var(--color-error-text); border-color: var(--color-error-border); }
.manage-btn-danger:hover { background: var(--color-error-bg); }

/* Management form inputs */
.manage-input { width: 100%; padding: 8px 12px; border: 1px solid var(--color-border); border-radius: 4px; font-size: 14px; }
.manage-select { width: 100%; padding: 8px 12px; border: 1px solid var(--color-border); border-radius: 4px; font-size: 14px; background: var(--color-bg); }

/* Form error messages */
.form-errors { background: var(--color-error-bg); color: var(--color-error-text); padding: 12px 16px; border-radius: 4px; margin-bottom: 16px; }
.form-errors ul { margin-left: 16px; }

/* Help dialog */
.help-dialog {
  max-width: 480px;
  width: 90%;
  border: none;
  border-radius: 8px;
  box-shadow: 0 8px 32px var(--shadow-dialog);
  padding: 24px;
  background: var(--color-bg);
  color: var(--color-text);
}

.help-dialog::backdrop {
  background: var(--shadow-backdrop);
}

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

.help-dialog-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.help-dialog-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--color-text-secondary);
  padding: 4px 8px;
}

.help-dialog-close:hover {
  color: var(--color-text);
}

.help-dialog h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin: 16px 0 8px;
}

.help-dialog table {
  width: 100%;
  border-collapse: collapse;
}

.help-dialog td {
  padding: 4px 8px;
  font-size: 13px;
}

.help-dialog td:first-child {
  width: 100px;
  white-space: nowrap;
}

.help-dialog kbd {
  display: inline-block;
  padding: 2px 6px;
  font-family: Monaco, Consolas, "Courier New", monospace;
  font-size: 12px;
  border: 1px solid var(--color-border-dark);
  border-radius: 3px;
  background: var(--color-bg-tertiary);
}

/* Login page */
.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: var(--color-bg-tertiary);
}

.login-card {
  width: 100%;
  max-width: 360px;
  padding: 40px 32px;
  background: var(--color-bg);
  border-radius: 8px;
  box-shadow: 0 2px 8px var(--shadow-card);
}

.login-title {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 32px;
  color: var(--color-text);
}

.login-field {
  margin-bottom: 16px;
}

.login-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 14px;
}

.login-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-accent-focus);
}

.login-submit {
  width: 100%;
  padding: 10px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}

.login-submit:hover {
  background: var(--color-accent-hover);
}

/* Mobile back button and entry nav (hidden on desktop) */
.mobile-back-button,
.mobile-entry-nav {
  display: none;
}

/* Mobile responsive layout */
@media (max-width: 767px) {
  .three-pane-layout {
    display: block;
    position: relative;
    height: 100dvh;
  }

  .feed-list-pane,
  .content-pane {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: none;
    overflow-y: auto;
  }

  .settings-dropdown-toggle {
    min-height: 44px;
    padding: 10px 12px;
  }

  /* feeds pane */
  .three-pane-layout[data-mobile-pane="feeds"] .feed-list-pane {
    display: block;
  }

  /* entries pane: show content-pane with entry-list-pane only */
  .three-pane-layout[data-mobile-pane="entries"] .content-pane {
    display: flex;
    flex-direction: column;
  }
  .three-pane-layout[data-mobile-pane="entries"] .entry-list-pane {
    display: block;
    flex: 1;
  }
  .three-pane-layout[data-mobile-pane="entries"] .entry-detail-pane {
    display: none;
  }

  /* detail pane: show content-pane with entry-detail-pane only */
  .three-pane-layout[data-mobile-pane="detail"] .content-pane {
    display: flex;
    flex-direction: column;
  }
  .three-pane-layout[data-mobile-pane="detail"] .entry-list-pane {
    display: none;
  }
  .three-pane-layout[data-mobile-pane="detail"] .entry-detail-pane {
    display: block;
    flex: 1;
  }

  /* Mobile back button */
  .mobile-back-button {
    display: block;
    padding: 12px 16px;
    background: var(--color-bg-secondary);
    border: none;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    font-size: 14px;
    color: var(--color-accent);
    cursor: pointer;
    width: 100%;
    min-height: 44px;
  }
  .mobile-back-button:active {
    background: var(--color-bg-active);
  }

  /* Mobile entry prev/next navigation */
  .mobile-entry-nav {
    display: flex;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg-secondary);
    position: sticky;
    bottom: 0;
  }
  .mobile-entry-nav-button {
    flex: 1;
    padding: 14px 16px;
    background: none;
    border: none;
    font-size: 15px;
    color: var(--color-accent);
    cursor: pointer;
    min-height: 48px;
  }
  .mobile-entry-nav-button:first-child {
    text-align: left;
    border-right: 1px solid var(--color-border);
  }
  .mobile-entry-nav-button:last-child {
    text-align: right;
  }
  .mobile-entry-nav-button:active {
    background: var(--color-bg-active);
  }
  .mobile-entry-nav-button:disabled {
    color: var(--color-text-disabled);
    opacity: 0.5;
    cursor: not-allowed;
  }

  /* Touch targets */
  .pin-button,
  .external-link {
    padding: 12px 16px;
    min-height: 44px;
  }

  /* Management table horizontal scroll */
  .manage-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}
