/* ============================================================================
   VARIABLES Y RESET
   ============================================================================ */

:root {
  --bg-primary: #1a1a1a;
  --bg-secondary: #252525;
  --bg-hover: #2f2f2f;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0a0;
  --text-muted: #707070;
  --accent: #4a9eff;
  --accent-hover: #3a8eef;
  --border: #3a3a3a;
  --read-opacity: 0.5;
  --transition: all 0.2s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================================
   LAYOUT
   ============================================================================ */

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 1200px;
  margin: 0 auto;
}

.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.logo {
  font-size: 1.5rem;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.update-time {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: right;
}

/* ============================================================================
   TABS
   ============================================================================ */

.tabs {
  display: flex;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  position: sticky;
  top: 85px;
  z-index: 99;
  -webkit-overflow-scrolling: touch;
}

.tabs::-webkit-scrollbar {
  height: 3px;
}

.tabs::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 3px;
}

.tab {
  padding: 0.75rem 1.5rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
  transition: var(--transition);
  border-bottom: 2px solid transparent;
}

.tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

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

/* ============================================================================
   CONTENT
   ============================================================================ */

.content {
  flex: 1;
  padding: 1.5rem 1rem;
}

.category-section {
  display: none;
}

.category-section[data-category].active {
  display: block;
}

/* ============================================================================
   NEWS LIST
   ============================================================================ */

.news-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.news-item {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 1.25rem;
  transition: var(--transition);
  cursor: pointer;
  border: 1px solid transparent;
}

.news-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.news-item.read {
  opacity: var(--read-opacity);
}

.news-item.read .news-title {
  text-decoration: line-through;
  text-decoration-color: var(--text-muted);
}

.news-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.news-title {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
  margin: 0;
}

.news-priority {
  flex-shrink: 0;
  background: var(--accent);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.news-summary {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.news-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.news-sources {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.source-tag {
  background: var(--bg-hover);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
}

.portada-badge {
  background: #ff6b6b;
  color: white;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ============================================================================
   COMICS
   ============================================================================ */

.comics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.comic-card {
  background: var(--bg-secondary);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}

.comic-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.comic-image {
  width: 100%;
  height: auto;
  display: block;
}

.comic-title {
  padding: 0.75rem;
  font-weight: 500;
  text-align: center;
  background: var(--bg-hover);
}

/* ============================================================================
   LIGHTBOX
   ============================================================================ */

.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-close {
  position: absolute;
  top: -2rem;
  right: 0;
  background: transparent;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  padding: 0.5rem;
  line-height: 1;
}

.lightbox img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 4px;
}

.lightbox-title {
  color: white;
  margin-top: 1rem;
  font-size: 1.1rem;
  font-weight: 500;
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

.btn-icon {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
}

.btn-icon:hover {
  background: var(--accent);
  border-color: var(--accent);
}

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

.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: var(--transition);
}

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

.date-selector {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: var(--transition);
}

.date-selector:hover {
  border-color: var(--accent);
}

/* ============================================================================
   STATES
   ============================================================================ */

.loading,
.error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 1rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: 0.75rem;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .tabs {
    top: 115px;
  }

  .tab {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }

  .news-header {
    flex-direction: column;
    gap: 0.5rem;
  }

  .news-priority {
    align-self: flex-start;
  }

  .comics-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================================
   PULL TO REFRESH
   ============================================================================ */

@media (hover: none) and (pointer: coarse) {
  body {
    overscroll-behavior-y: contain;
  }
}
