/* DevOps Digest - Modern CSS */

:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --surface: #ffffff;
  --bg: #f7fcff;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --success: #10b981;
  --error: #ef4444;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  padding-bottom: 80px;
}

/* Header */
header {
  padding: 64px 40px 48px;
  background: var(--surface);
  color: var(--text);
  border-bottom: 1px solid var(--border);
  margin-bottom: 48px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
  gap: 32px;
}

.header-main {
  flex: 1;
}

header h1 {
  font-size: 2.75rem;
  margin-bottom: 12px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--text);
  line-height: 1.1;
}

.header-subtitle {
  font-size: 1.125rem;
  color: var(--text-muted);
  font-weight: 400;
  line-height: 1.6;
  max-width: 720px;
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.action-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
}

.action-btn:hover {
  background: var(--bg);
  border-color: var(--primary);
  color: var(--primary);
}

.period-selector {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.period-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
}

.period-btn:hover {
  background: var(--bg);
  border-color: var(--primary);
  color: var(--text);
}

.period-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Filters Section */
.filters-section {
  margin-bottom: 32px;
}

.filter-group {
  margin-bottom: 20px;
}

.filter-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: 0.3px;
}

.topic-filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.topic-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.topic-checkbox:hover {
  background: var(--bg);
  border-color: var(--primary);
}

.topic-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

.topic-checkbox span {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.topic-checkbox input[type="checkbox"]:not(:checked) + span {
  color: var(--text-muted);
}

.header-stats {
  display: flex;
  gap: 30px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
  font-size: 0.95rem;
  opacity: 0.95;
}

.stat {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Navigation Tabs */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 30px;
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  background: none;
  border: none;
  padding: 14px 24px;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab:hover {
  color: var(--text);
  background: rgba(0,0,0,0.02);
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* Views */
.view {
  display: none;
  animation: fadeIn 0.3s ease-in;
}

.view.active {
  display: block;
}

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

.view-title {
  font-size: 1.8rem;
  margin-bottom: 30px;
  color: var(--text);
}

/* Loading State */
.loading {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 20px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Error Box */
.error-box {
  background: #fef2f2;
  border: 2px solid var(--error);
  border-radius: 12px;
  padding: 30px;
  text-align: center;
  color: var(--error);
}

.error-box h3 {
  margin-bottom: 12px;
}

/* Digest Content */
#digest-content {
  background: var(--surface);
  padding: 56px 64px;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  min-height: 400px;
  border: 1px solid #e2e8f0;
}

/* Archive Grid */
.archive-grid {
  display: grid;
  gap: 16px;
}

.archive-item {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.2s;
  cursor: pointer;
}

.archive-item:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  transform: translateY(-2px);
  border-color: var(--primary);
}

.archive-item a {
  display: block;
  padding: 24px;
  text-decoration: none;
  color: inherit;
}

.archive-item h3 {
  color: var(--text);
  margin-bottom: 8px;
  font-size: 1.2rem;
}

.archive-item .date {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 12px;
}

.archive-item .meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.archive-item .meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Trends */
.trends-container {
  background: var(--surface);
  padding: 40px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.trend-item {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.trend-item:last-child {
  border-bottom: none;
}

.trend-name {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
}

.trend-count {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.category-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-top: 30px;
}

.category-card {
  background: var(--bg);
  padding: 20px;
  border-radius: 10px;
  border-left: 4px solid var(--primary);
}

.category-card h4 {
  margin-bottom: 8px;
  color: var(--text);
}

.category-card .count {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

/* About Content */
.about-content {
  background: var(--surface);
  padding: 48px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.about-content h2 {
  margin-bottom: 30px;
}

.about-content h3 {
  margin-top: 30px;
  margin-bottom: 16px;
  color: var(--secondary);
}

.about-content ul, .about-content ol {
  margin-left: 24px;
  margin-bottom: 20px;
}

.about-content li {
  margin-bottom: 10px;
}

/* Markdown Content Overrides */
.markdown-body {
  font-size: 1.0625rem;
  line-height: 1.75;
  color: var(--text);
  max-width: 100%;
}

.markdown-body h1 {
  color: var(--text);
  font-size: 2.25rem;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.markdown-body h2 {
  color: var(--text);
  font-size: 1.75rem;
  margin-top: 48px;
  margin-bottom: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
  line-height: 1.3;
}

.markdown-body h3 {
  color: var(--text);
  font-size: 1.35rem;
  margin-top: 36px;
  margin-bottom: 16px;
  font-weight: 600;
  line-height: 1.4;
}

.markdown-body p {
  margin-bottom: 20px;
  line-height: 1.8;
}

.markdown-body a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}

.markdown-body a:hover {
  color: var(--primary-light);
  text-decoration: underline;
}

.markdown-body code {
  background: #f7fafc;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.9em;
  color: #e53e3e;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Courier New', monospace;
  font-weight: 500;
}

.markdown-body pre {
  background: #1a202c !important;
  padding: 20px;
  border-radius: 12px;
  overflow-x: auto;
  margin: 24px 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.markdown-body pre code {
  background: none;
  padding: 0;
  color: #e2e8f0;
  font-weight: 400;
}

.markdown-body blockquote {
  border-left: 4px solid #667eea;
  padding: 16px 24px;
  margin: 28px 0;
  color: #4a5568;
  background: linear-gradient(to right, #f7fafc 0%, #ffffff 100%);
  border-radius: 8px;
  font-size: 1.05em;
  line-height: 1.7;
}

.markdown-body blockquote p {
  margin: 0;
}

.markdown-body strong {
  color: #2d3748;
  font-weight: 700;
}

.markdown-body ul, .markdown-body ol {
  margin: 20px 0;
  padding-left: 28px;
}

.markdown-body li {
  margin: 12px 0;
  line-height: 1.7;
}

.markdown-body li::marker {
  color: #667eea;
  font-weight: 600;
}

.markdown-body hr {
  border: none;
  border-top: 2px solid #e2e8f0;
  margin: 48px 0;
}

/* Footer */
footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 12px;
    padding-bottom: 100px;
  }

  header {
    padding: 30px 20px 25px;
    border-radius: 12px;
    margin-bottom: 30px;
  }

  .header-content {
    flex-direction: column;
    align-items: center;
    gap: 20px;
  }

  .header-main {
    text-align: center;
  }

  header h1 {
    font-size: 1.8rem;
  }

  .header-subtitle {
    font-size: 0.95rem;
  }

  .header-actions {
    flex-direction: row;
    gap: 8px;
  }

  .action-btn {
    padding: 8px 16px;
    font-size: 0.85rem;
  }

  .period-selector {
    flex-wrap: wrap;
    gap: 8px;
  }

  .period-btn {
    padding: 8px 16px;
    font-size: 0.85rem;
  }

  .header-stats {
    flex-direction: column;
    gap: 12px;
    font-size: 0.85rem;
  }

  #digest-content, .about-content, .trends-container {
    padding: 24px;
  }

  .tab {
    padding: 12px 16px;
    font-size: 0.9rem;
  }

  .view-title {
    font-size: 1.5rem;
  }

  .markdown-body h1 {
    font-size: 1.5rem;
  }

  .markdown-body h2 {
    font-size: 1.3rem;
  }

  .markdown-body h3 {
    font-size: 1.1rem;
  }

  .category-breakdown {
    grid-template-columns: 1fr;
  }
}

/* Print Styles */
@media print {
  header, .tabs, footer, .period-selector, .header-actions {
    display: none;
  }

  .container {
    max-width: 100%;
    padding: 0;
  }

  #digest-content {
    box-shadow: none;
    padding: 20px;
  }
}
