/* Cloudflare & HomeLab Hub - Stylesheet */

:root {
  --bg-dark: #090a0f;
  --bg-dark-accent: #0f111a;
  --panel-bg: rgba(18, 20, 32, 0.55);
  --panel-border: rgba(255, 255, 255, 0.08);
  
  --text-main: #f3f4f6;
  --text-secondary: #d1d5db;
  --text-muted: #9ca3af;
  
  --color-primary: #ab73ff;
  --color-purple: #ab73ff;
  --color-blue: #3b82f6;
  --color-cyan: #00f0ff;
  --color-pink: #ff2e93;
  --color-green: #10b981;
  
  --purple-glow: 0 0 25px rgba(171, 115, 255, 0.25);
  --cyan-glow: 0 0 25px rgba(0, 240, 255, 0.25);
  --pink-glow: 0 0 25px rgba(255, 46, 147, 0.25);
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: 'Outfit', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Background Blur Auras */
.aura {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  pointer-events: none;
  opacity: 0.15;
}

.aura-purple {
  background-color: var(--color-purple);
  width: 400px;
  height: 400px;
  top: -100px;
  right: -50px;
}

.aura-blue {
  background-color: var(--color-blue);
  width: 500px;
  height: 500px;
  bottom: -100px;
  left: -100px;
}

.aura-cyan {
  background-color: var(--color-cyan);
  width: 350px;
  height: 350px;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(18, 20, 32, 0.5);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Layout Container */
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 24px 80px 24px;
  position: relative;
  z-index: 10;
}

/* Header styling */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  margin-bottom: 40px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 32px;
  height: 32px;
  color: var(--color-cyan);
  filter: drop-shadow(var(--cyan-glow));
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #fff 0%, #aaa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--panel-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: var(--purple-glow);
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-purple) 0%, var(--color-blue) 100%);
  color: white;
  border: none;
  box-shadow: var(--purple-glow);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
}

/* Hero Section */
.hero-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 48px;
  gap: 32px;
}

.hero-title {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.2;
  margin-bottom: 12px;
}

.gradient-text {
  background: linear-gradient(135deg, var(--color-cyan) 0%, var(--color-purple) 50%, var(--color-pink) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: glow-pulse 3s infinite alternate;
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 700px;
  margin: 0 auto;
  line-height: 1.6;
}

/* Stats dashboard */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  width: 100%;
  margin-top: 16px;
}

.stat-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  transition: var(--transition-smooth);
}

.stat-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.15);
}

.stat-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
}

.stat-icon-wrapper.purple {
  background: rgba(171, 115, 255, 0.1);
  color: var(--color-purple);
}

.stat-icon-wrapper.blue {
  background: rgba(59, 130, 246, 0.1);
  color: var(--color-blue);
}

.stat-icon-wrapper.cyan {
  background: rgba(0, 240, 255, 0.1);
  color: var(--color-cyan);
}

.stat-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: white;
  line-height: 1;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Controls Section */
.controls-section {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.search-box {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

#search-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--panel-border);
  padding: 14px 20px 14px 48px;
  font-size: 1rem;
  border-radius: 12px;
  color: white;
  transition: var(--transition-smooth);
}

#search-input:focus {
  outline: none;
  border-color: var(--color-purple);
  box-shadow: var(--purple-glow);
}

/* Filters */
.filter-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.filter-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  min-width: 80px;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  padding: 6px 14px;
  font-size: 0.85rem;
  border-radius: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.chip:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.chip.active {
  background: linear-gradient(135deg, rgba(171, 115, 255, 0.2), rgba(0, 240, 255, 0.2));
  border-color: var(--color-purple);
  color: white;
  box-shadow: 0 0 10px rgba(171, 115, 255, 0.2);
}

/* Articles Section */
.articles-section {
  margin-bottom: 40px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  position: relative;
  padding-left: 14px;
}

.section-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 20px;
  border-radius: 2px;
  background: linear-gradient(to bottom, var(--color-purple), var(--color-cyan));
}

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

/* Articles Grid */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 24px;
}

/* Card */
.article-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  cursor: pointer;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.15);
  transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), border-color 0.3s ease, box-shadow 0.3s ease;
  height: 100%;
}

.article-card:hover {
  transform: translateY(-6px);
  border-color: rgba(171, 115, 255, 0.3);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3), 0 0 15px rgba(171, 115, 255, 0.1);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-badge {
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(171, 115, 255, 0.1);
  color: var(--color-purple);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(171, 115, 255, 0.2);
}

.card-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.card-title {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.4;
  color: white;
  /* Multi-line ellipsis */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 3.36rem;
}

.card-summary {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  /* Multi-line ellipsis */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 4.05rem;
}

.card-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.tag-badge {
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 4px;
}

/* Reader Slide-in Drawer */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  height: 100vh;
  z-index: 1000;
  pointer-events: none;
  visibility: hidden;
  transition: visibility 0.4s;
}

.drawer.active {
  pointer-events: auto;
  visibility: visible;
}

.drawer-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.drawer.active .drawer-overlay {
  opacity: 1;
}

.drawer-content {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 850px;
  height: 100%;
  background: #0d0f17;
  border-left: 1px solid var(--panel-border);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.drawer.active .drawer-content {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(25, 28, 41, 0.5);
  backdrop-filter: blur(10px);
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.btn-close:hover {
  color: var(--color-pink);
  transform: scale(1.1);
}

.drawer-meta {
  margin-left: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.drawer-badge {
  font-size: 0.8rem;
  background: rgba(0, 240, 255, 0.1);
  color: var(--color-cyan);
  border: 1px solid rgba(0, 240, 255, 0.2);
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 600;
}

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

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 40px;
}

.drawer-title {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 24px;
  line-height: 1.3;
  color: white;
}

.drawer-link-container {
  margin-bottom: 32px;
}

.article-origin-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-cyan);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
  transition: var(--transition-smooth);
}

.article-origin-link:hover {
  text-decoration: underline;
  color: var(--color-purple);
}

/* Markdown Rendering Custom Styles */
.markdown-body {
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 1.05rem;
}

.markdown-body h2 {
  font-size: 1.45rem;
  color: white;
  margin: 32px 0 16px 0;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
}

.markdown-body h3 {
  font-size: 1.2rem;
  color: white;
  margin: 24px 0 12px 0;
  font-weight: 600;
}

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

.markdown-body blockquote {
  border-left: 4px solid var(--color-purple);
  padding: 8px 20px;
  margin: 20px 0;
  background: rgba(171, 115, 255, 0.05);
  border-radius: 0 8px 8px 0;
  font-style: italic;
}

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

.markdown-body pre {
  background: #08090e;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 16px;
  overflow-x: auto;
  margin: 24px 0;
}

.markdown-body code {
  font-family: 'Fira Code', monospace;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  color: #fb7185;
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
  color: #e2e8f0;
}

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

.markdown-body li {
  margin-bottom: 8px;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 0.95rem;
}

.markdown-body th, .markdown-body td {
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 14px;
  text-align: left;
}

.markdown-body th {
  background: rgba(255, 255, 255, 0.03);
  color: white;
  font-weight: 600;
}

.markdown-body tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.01);
}

/* Modals */
.modal-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  opacity: 0;
}

.modal-wrapper.active {
  pointer-events: auto;
  visibility: visible;
  opacity: 1;
}

.modal-overlay {
  position: absolute;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
}

.modal-box {
  background: #0f111a;
  border: 1px solid var(--panel-border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  border-radius: 16px;
  width: 90%;
  max-width: 600px;
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.modal-wrapper.active .modal-box {
  transform: translateY(0);
}

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

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-close-modal:hover {
  color: white;
}

.modal-body {
  padding: 24px;
}

.guide-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 16px;
}

.guide-list li {
  border-left: 2px solid var(--color-cyan);
  padding-left: 16px;
}

.guide-list li strong {
  display: block;
  font-size: 0.95rem;
  color: white;
  margin-bottom: 4px;
}

.guide-list li p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.guide-list a {
  color: var(--color-cyan);
  text-decoration: none;
}

.guide-list a:hover {
  text-decoration: underline;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--panel-border);
  display: flex;
  justify-content: flex-end;
}

/* Footer Section */
.footer {
  text-align: center;
  padding: 40px 0 20px 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  margin-top: 40px;
}

/* Responsive Media Queries */
@media (max-width: 768px) {
  .hero-title {
    font-size: 2.2rem;
  }
  .drawer-content {
    max-width: 100%;
  }
  .drawer-body {
    padding: 24px;
  }
  .stat-card {
    padding: 16px;
  }
  .header {
    margin-bottom: 24px;
  }
}

@keyframes glow-pulse {
  from {
    filter: drop-shadow(0 0 10px rgba(0, 240, 255, 0.1));
  }
  to {
    filter: drop-shadow(0 0 20px rgba(171, 115, 255, 0.3));
  }
}
