/* ========================================
   API Widgets Styles
   ======================================== */

/* Tech News Widget */
.tech-news-widget {
  display: grid;
  gap: 1rem;
}

.news-item {
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
}

.news-item:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.15);
}

.news-meta {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.news-source {
  color: var(--accent);
  font-weight: 600;
}

.news-title {
  margin: 0.5rem 0;
  font-size: 1.05rem;
  line-height: 1.4;
}

.news-title a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

.news-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 0.5rem 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-stats {
  display: flex;
  gap: 1rem;
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.news-stats span {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.stat-reactions,
.hn-score,
.repo-stars {
  color: var(--success);
  font-weight: 600;
}

.stat-comments,
.hn-comments,
.repo-forks {
  color: var(--info);
  font-weight: 600;
}

.stat-reading-time,
.hn-date,
.repo-language {
  color: var(--text-secondary);
  font-weight: 500;
}

/* Crypto Ticker Widget */
.crypto-ticker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.crypto-item {
  padding: 1rem;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: center;
  transition: all 0.3s ease;
}

.crypto-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(99, 102, 241, 0.2);
}

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

.crypto-symbol {
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--accent);
  font-family: "JetBrains Mono", "Fira Code", "Courier New", monospace;
  letter-spacing: -0.02em;
}

.crypto-name {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.crypto-price {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0.5rem 0 0.25rem 0;
}

.crypto-price-twd {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.crypto-change {
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  display: inline-block;
}

.crypto-change.positive {
  color: var(--success);
  background: rgba(16, 185, 129, 0.1);
}

.crypto-change.negative {
  color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

/* Tech Quote Widget */
.tech-quote {
  padding: 1.5rem;
  background: rgba(99, 102, 241, 0.05);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  margin: 0;
}

.quote-text {
  font-size: 1.1rem;
  font-style: italic;
  color: var(--text-primary);
  line-height: 1.6;
  margin: 0 0 1rem 0;
}

.quote-author {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 600;
}

/* GitHub Stats Widget */
.github-stats {
  display: flex;
  gap: 2rem;
  justify-content: center;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.github-stats .stat-item {
  text-align: center;
}

.github-stats .stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.github-stats .stat-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Hacker News Widget */
.hackernews-widget {
  display: grid;
  gap: 0.75rem;
}

.hn-item {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
}

.hn-item:hover {
  border-color: #ff6600;
  transform: translateX(4px);
  box-shadow: 0 4px 16px rgba(255, 102, 0, 0.15);
}

.hn-rank {
  font-size: 1.25rem;
  font-weight: 700;
  color: #ff6600;
  flex-shrink: 0;
  width: 2rem;
  text-align: center;
}

.hn-content {
  flex: 1;
}

.hn-title {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  line-height: 1.4;
}

.hn-title a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

.hn-title a:hover {
  color: #ff6600;
}

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

/* Weather Widget */
.weather-widget {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
}

.weather-item {
  text-align: center;
  padding: 1rem;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
}

.weather-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.2);
}

.weather-location {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.weather-temp {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.weather-condition {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

/* Widget Section Container */
.widget-section {
  margin: 3rem 0;
}

.widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

/* Error Message */
.error-message {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
  font-style: italic;
}

/* Loading State */
.widget-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-secondary);
}

.widget-loading::before {
  content: "";
  display: inline-block;
  width: 1.5rem;
  height: 1.5rem;
  margin-right: 0.75rem;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* GitHub Trending Widget */
.trending-repo {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
  margin-bottom: 0.75rem;
}

.trending-repo:hover {
  border-color: var(--primary);
  transform: translateX(4px);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.15);
}

.trending-rank {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
  width: 3rem;
  text-align: center;
}

.trending-content {
  flex: 1;
}

.trending-title {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  line-height: 1.4;
}

.trending-title a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

.trending-title a:hover {
  color: var(--primary);
}

.trending-desc {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.5;
  margin: 0.5rem 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.trending-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Carbon Footprint Widget */
.carbon-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.carbon-stat-item {
  text-align: center;
  padding: 1.5rem;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
}

.carbon-stat-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.2);
}

.carbon-icon {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--success);
  margin-bottom: 0.75rem;
  font-family: "JetBrains Mono", "Fira Code", "Courier New", monospace;
  letter-spacing: -0.02em;
}

.carbon-stat-item--primary {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.2);
}

.carbon-stat-item--primary .carbon-value {
  color: #10b981;
}

.carbon-stat-item--secondary {
  background: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.2);
}

.carbon-stat-item--secondary .carbon-value {
  color: var(--accent);
}

.carbon-stat-item--tertiary {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.2);
}

.carbon-stat-item--tertiary .carbon-value {
  color: #f59e0b;
}

.carbon-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: #10b981;
  margin-bottom: 0.5rem;
}

.carbon-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.carbon-note {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 1rem;
}

/* Team Status Widget */
.status-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
  margin-bottom: 0.75rem;
}

.status-item:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.1);
}

.status-flag {
  font-size: 2rem;
  flex-shrink: 0;
}

.status-info {
  flex: 1;
}

.status-location {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.status-time {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-family: 'Courier New', monospace;
}

.status-indicator {
  padding: 0.4rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

/* Scroll to Top Button */
.scroll-to-top {
  position: fixed;
  bottom: 2rem;
  right: 7rem;
  width: 3.5rem;
  height: 3.5rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
  transition: all 0.3s ease;
  opacity: 0;
  visibility: hidden;
  z-index: 999;
}

.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.scroll-to-top:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(99, 102, 241, 0.4);
}

.scroll-to-top:active {
  transform: translateY(-2px);
}

/* Loading Skeleton States */
.skeleton {
  background: rgba(255, 255, 255, 0.05);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 1rem;
  margin-bottom: 0.5rem;
}

.skeleton-title {
  height: 1.5rem;
  width: 60%;
  margin-bottom: 1rem;
}

.skeleton-card {
  height: 200px;
  width: 100%;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Reddit Widget Styles */
.reddit-post {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
  margin-bottom: 0.75rem;
}

.reddit-post:hover {
  border-color: #ff4500;
  transform: translateX(4px);
  box-shadow: 0 4px 16px rgba(255, 69, 0, 0.15);
}

.reddit-rank {
  font-size: 1.25rem;
  font-weight: 700;
  color: #ff4500;
  flex-shrink: 0;
  width: 3rem;
  text-align: center;
}

.reddit-content {
  flex: 1;
}

.reddit-title {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  line-height: 1.4;
}

.reddit-title a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

.reddit-title a:hover {
  color: #ff4500;
}

.reddit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.reddit-subreddit {
  color: #ff4500;
  font-weight: 600;
}

.reddit-score,
.reddit-comments {
  font-weight: 500;
}

/* Wikipedia Widget Styles */
.wiki-article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: grid;
  gap: 1.5rem;
  transition: all 0.3s ease;
}

.wiki-article:hover {
  border-color: var(--primary);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.15);
}

.wiki-image {
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
}

.wiki-image img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.wiki-content {
  display: grid;
  gap: 1rem;
}

.wiki-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.3;
}

.wiki-title a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

.wiki-title a:hover {
  color: var(--primary);
}

.wiki-extract {
  color: var(--text-secondary);
  line-height: 1.7;
  margin: 0;
}

.wiki-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
}

.wiki-source {
  color: var(--text-tertiary);
  font-weight: 500;
}

.wiki-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
}

.wiki-link:hover {
  color: var(--primary-hover);
  transform: translateX(2px);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .crypto-ticker {
    grid-template-columns: repeat(2, 1fr);
  }

  .weather-widget {
    grid-template-columns: repeat(3, 1fr);
  }

  .github-stats {
    flex-direction: column;
    gap: 1.5rem;
  }

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

  .carbon-stats {
    grid-template-columns: 1fr;
  }

  .scroll-to-top {
    bottom: 1rem;
    right: 5rem;
    width: 3rem;
    height: 3rem;
    font-size: 1.25rem;
  }

  .reddit-meta {
    gap: 0.5rem;
    font-size: 0.75rem;
  }

  .reddit-rank {
    width: 2rem;
    font-size: 1rem;
  }
}
