/* RSS Reader - Minimalist Card Design System */
/* NO gradients, NO shadows - Flat design only */

:root {
  /* Color palette from constitution */
  --bg-primary: #FAFAFA;
  --bg-card: #FFFFFF;
  --text-primary: #1A1A1A;
  --text-secondary: #525252;
  --text-tertiary: #737373;
  --accent: #0066CC;
  --border-primary: #E5E5E5;
  --border-secondary: #D4D4D4;

  /* Typography */
  --font-system: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  /* Spacing */
  --radius: 12px;
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 20px;
  --spacing-2xl: 24px;
}

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

html {
  overflow-x: hidden;
  width: 100%;
}

html, body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-system);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  padding-top: 60px;
  min-height: 100vh;
}

/* Main container */
main {
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

/* Header with sticky blur effect */
#app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  padding: 0 var(--spacing-lg);
  gap: var(--spacing-md);
  z-index: 1000;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

#app-header.hidden {
  display: none;
}

#app-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin: 0;
  flex: 1;
}

/* Loading spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-primary);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner.hidden {
  display: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Navigation inline buttons */
#main-nav {
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
}

#main-nav button {
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  color: var(--text-primary);
  font-weight: 500;
  font-size: 14px;
  min-height: 36px;
  width: auto;
  transition: all 0.2s ease;
}

#main-nav button:active {
  transform: scale(0.98);
  background: var(--accent);
  color: var(--bg-card);
  border-color: var(--accent);
}

/* Typography */
h1, h2, h3 {
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--spacing-lg) 0;
  letter-spacing: -0.02em;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 16px;
}

/* View sections */
.view {
  display: block;
  animation: fadeIn 0.3s ease;
}

.view.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Card-based login form */
#login-view {
  max-width: 375px;
  margin: 0 auto;
  width: 100%;
}

#login-view h1 {
  text-align: center;
  margin-bottom: var(--spacing-2xl);
}

#login-form {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius);
  padding: var(--spacing-2xl);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

/* Form elements */
form {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

form.inline {
  flex-direction: row;
  align-items: center;
  gap: var(--spacing-sm);
}

label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  display: block;
}

label input {
  margin-top: var(--spacing-sm);
}

input, button {
  font-family: var(--font-system);
  font-size: 15px;
  padding: var(--spacing-md) var(--spacing-lg);
  border: 1px solid var(--border-primary);
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: var(--radius);
  min-height: 44px;
  width: 100%;
  transition: all 0.2s ease;
}

input:focus {
  outline: none;
  border-color: var(--accent);
}

button {
  background: var(--accent);
  color: var(--bg-card);
  cursor: pointer;
  border: none;
  font-weight: 500;
  position: relative;
  overflow: hidden;
}

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

button:not(:disabled):active {
  transform: scale(0.98);
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-md);
  align-items: center;
  margin-bottom: var(--spacing-lg);
  padding: var(--spacing-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius);
  max-width: 100%;
  overflow: hidden;
}

.toolbar h2 {
  margin: 0;
  flex: 1;
}

.toolbar button {
  width: auto;
  padding: var(--spacing-sm) var(--spacing-lg);
  font-size: 14px;
  min-height: 36px;
}

.toolbar form.inline {
  flex: 1;
  min-width: 200px;
  max-width: 100%;
}

.toolbar form.inline input {
  flex: 1;
  min-height: 36px;
  font-size: 14px;
  padding: var(--spacing-sm) var(--spacing-md);
}

.toolbar form.inline button {
  width: auto;
}

/* Card-based list items */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  width: 100%;
  max-width: 100%;
}

.list li {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  padding: var(--spacing-lg);
  border-radius: var(--radius);
  line-height: 1.5;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
  max-width: 100%;
  overflow: hidden;
}

.list li:active {
  transform: scale(0.98);
}

.list li.read {
  background: var(--bg-primary);
  border-color: var(--border-secondary);
}

.list li.read * {
  color: var(--text-tertiary);
}

.list li:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Feed items */
.feed-item {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.feed-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.feed-item h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.feed-item .feed-url {
  font-size: 12px;
  color: var(--text-tertiary);
  word-break: break-all;
  overflow-wrap: break-word;
  word-wrap: break-word;
  max-width: 100%;
}

.feed-item .unread-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: var(--spacing-xs);
}

/* News items - Card design from option 1 */
.news-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--spacing-sm);
  cursor: default;
  position: relative;
}

/* Read toggle button */
.read-toggle-btn {
  grid-column: 1;
  grid-row: 1 / -1;
  width: 32px;
  min-height: 32px;
  padding: 0;
  margin-top: 2px;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  transition: all 0.2s ease;
  align-self: start;
}

.read-toggle-btn:hover {
  color: var(--accent);
  background: transparent;
}

.read-toggle-btn:active {
  transform: scale(0.95);
}

.read-toggle-btn svg {
  width: 20px;
  height: 20px;
}

.news-item.read .read-toggle-btn {
  color: var(--accent);
}

.news-item .meta {
  grid-column: 2;
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 400;
  margin-bottom: var(--spacing-xs);
}

.news-item .news-source {
  grid-column: 2;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--spacing-xs);
  opacity: 0.8;
}

.news-item .news-title {
  grid-column: 2;
  margin: 0 0 var(--spacing-sm) 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
  overflow-wrap: break-word;
  word-wrap: break-word;
  max-width: 100%;
}

.news-item .news-title a {
  color: var(--text-primary);
  text-decoration: none;
}

.news-item .news-title a:hover {
  color: var(--accent);
}

.news-item .news-excerpt {
  grid-column: 2;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: break-word;
  word-wrap: break-word;
  max-width: 100%;
}

/* Read state styling */
.news-item.read {
  background: var(--bg-primary);
  border-color: var(--border-secondary);
  opacity: 0.75;
}

.news-item.read .meta {
  color: var(--text-tertiary);
}

.news-item.read .news-title,
.news-item.read .news-title a {
  color: var(--text-tertiary);
}

.news-item.read .news-excerpt {
  color: var(--text-tertiary);
  opacity: 0.7;
}

/* Messages */
.msg {
  font-size: 14px;
  min-height: 1.2em;
  color: var(--text-secondary);
  text-align: center;
  padding: var(--spacing-md);
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius);
  margin-top: var(--spacing-lg);
}

.msg:empty {
  display: none;
}

/* Links */
a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Accessibility */
button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  main {
    padding: var(--spacing-md);
  }

  .toolbar {
    padding: var(--spacing-md);
  }

  .toolbar form.inline {
    flex-basis: 100%;
  }
}

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

/* Prevent horizontal overflow */
* {
  box-sizing: border-box;
}

body, main {
  overflow-x: hidden;
}

/* Loading states */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

.loading::after {
  content: '...';
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: var(--spacing-lg) var(--spacing-2xl);
  border-radius: var(--radius);
  border: 1px solid var(--border-primary);
  font-size: 14px;
  font-weight: 500;
  z-index: 10000;
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-success {
  background: #10B981;
  color: white;
  border-color: #059669;
}

.toast-error {
  background: #EF4444;
  color: white;
  border-color: #DC2626;
}

.toast-info {
  background: var(--accent);
  color: white;
  border-color: #0052A3;
}

/* Empty state styling */
.empty-state {
  background: var(--bg-card);
  border: 1px dashed var(--border-secondary);
  padding: var(--spacing-2xl);
  border-radius: var(--radius);
  text-align: center;
  cursor: default;
}

.empty-state:active {
  transform: none;
}

.empty-message {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--spacing-sm) 0;
}

.empty-hint {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

@media (max-width: 640px) {
  .toast {
    bottom: 10px;
    left: 10px;
    right: 10px;
    transform: translateY(100px);
    max-width: none;
  }

  .toast.show {
    transform: translateY(0);
  }
}

/* ========== SUGGESTIONS VIEW ========== */

/* Language toggle buttons */
.lang-toggle {
  display: flex;
  gap: var(--spacing-xs);
  background: var(--bg-primary);
  padding: 4px;
  border-radius: calc(var(--radius) - 4px);
  border: 1px solid var(--border-primary);
}

.lang-btn {
  min-width: 48px;
  min-height: 32px;
  padding: var(--spacing-xs) var(--spacing-md);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  border-radius: calc(var(--radius) - 6px);
  cursor: pointer;
  transition: all 0.2s ease;
}

.lang-btn:hover {
  background: rgba(0, 102, 204, 0.1);
  color: var(--accent);
}

.lang-btn.active {
  background: var(--accent);
  color: white;
}

.lang-btn:active {
  transform: scale(0.96);
}

/* Suggestions container */
#suggestions-container {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2xl);
  padding-bottom: var(--spacing-2xl);
}

/* Category section */
.category-section {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.category-header {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  padding-bottom: var(--spacing-sm);
  border-bottom: 2px solid var(--border-primary);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.category-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: var(--accent);
}

.category-icon svg {
  width: 20px;
  height: 20px;
}

/* Suggestions grid */
.suggestions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--spacing-md);
}

/* Suggestion card */
.suggestion-card {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius);
  padding: var(--spacing-lg);
  display: flex;
  gap: var(--spacing-md);
  align-items: flex-start;
  transition: all 0.2s ease;
  position: relative;
}

.suggestion-card:hover {
  border-color: var(--border-secondary);
}

.suggestion-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  min-width: 0;
}

.suggestion-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.3;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.suggestion-description {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* Add button */
.add-suggestion-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 24px;
  font-weight: 300;
  line-height: 1;
}

.add-suggestion-btn:hover {
  transform: scale(1.1);
  background: #0052A3;
}

.add-suggestion-btn:active {
  transform: scale(0.95);
}

.add-suggestion-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--text-tertiary);
}

.add-suggestion-btn:disabled:hover {
  transform: none;
}

.add-suggestion-btn.added {
  background: #10B981;
  cursor: default;
}

.add-suggestion-btn.added:hover {
  transform: none;
  background: #10B981;
}

.add-suggestion-btn svg {
  width: 20px;
  height: 20px;
}

/* Spinning loader animation */
.spinning {
  animation: spin 1s linear infinite;
}

/* Toolbar actions flex container */
.toolbar-actions {
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
  flex-wrap: wrap;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .suggestions-grid {
    grid-template-columns: 1fr;
  }

  .category-header {
    font-size: 16px;
  }

  #suggestions-container {
    gap: var(--spacing-xl);
  }
}