/* CSS Custom Properties */
:root {
  --primary-color: #4f46e5;
  --secondary-color: #7c3aed;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;
  --bg-color: #f9fafb;
  --card-bg: #ffffff;
  --text-color: #1f2937;
  --text-secondary: #6b7280;
  --border-color: #e5e7eb;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
  --border-radius: 12px;
  --transition: all 0.3s ease;
}

/* Dark Mode Variables */
[data-theme='dark'] {
  --bg-color: #111827;
  --card-bg: #1f2937;
  --text-color: #f9fafb;
  --text-secondary: #9ca3af;
  --border-color: #374151;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
}

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

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

/* Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 2rem;
  padding: 2rem;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  border-radius: var(--border-radius);
  color: white;
}

.header h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.subtitle {
  font-size: 1.1rem;
  opacity: 0.9;
  margin-bottom: 1rem;
}

.last-updated {
  font-size: 0.9rem;
  opacity: 0.8;
}

/* Controls Section */
.controls {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-width: 200px;
}

.control-group label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

input[type="text"],
select {
  padding: 0.75rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--bg-color);
  color: var(--text-color);
  transition: var(--transition);
}

input[type="text"]:focus,
select:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* Buttons */
button {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

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

.btn-primary:hover {
  background: #4338ca;
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--text-secondary);
  color: white;
}

.btn-secondary:hover {
  background: #4b5563;
}

.btn-refresh {
  background: var(--success-color);
  color: white;
}

.btn-refresh:hover {
  background: #059669;
  transform: rotate(180deg);
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  color: var(--text-color);
}

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

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

/* Widget Styles */
.widget {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: var(--transition);
}

.widget:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem;
  background: var(--bg-color);
  border-bottom: 2px solid var(--border-color);
}

.widget-header h2 {
  font-size: 1.25rem;
  color: var(--text-color);
}

.widget-status {
  font-size: 0.85rem;
  padding: 0.25rem 0.75rem;
  background: var(--success-color);
  color: white;
  border-radius: 12px;
  font-weight: 600;
}

.widget-content {
  padding: 1.5rem;
  min-height: 200px;
}

/* Loading Spinner */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 2rem auto;
}

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

/* Weather Widget */
.weather-display {
  text-align: center;
}

.temperature {
  font-size: 3rem;
  font-weight: 700;
  color: var(--primary-color);
  margin: 1rem 0;
}

.weather-details {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-top: 1.5rem;
}

.weather-detail {
  text-align: center;
  padding: 0.75rem;
  background: var(--bg-color);
  border-radius: 8px;
}

.weather-detail .label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: block;
}

.weather-detail .value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-color);
  display: block;
  margin-top: 0.25rem;
}

/* News Widget */
.news-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.news-item {
  padding: 1rem;
  background: var(--bg-color);
  border-radius: 8px;
  border-left: 4px solid var(--primary-color);
  transition: var(--transition);
  cursor: pointer;
}

.news-item:hover {
  transform: translateX(4px);
  background: var(--border-color);
}

.news-item h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: var(--text-color);
}

.news-item p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.news-source {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  font-weight: 600;
}

/* Chart Widget */
.chart-widget .widget-content {
  padding: 1rem;
}

canvas {
  max-height: 300px;
}

/* Facts Widget */
.fact-item {
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  border-radius: 8px;
  text-align: center;
  font-size: 1.1rem;
  line-height: 1.6;
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Crypto Widget */
.crypto-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.crypto-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--bg-color);
  border-radius: 8px;
}

.crypto-name {
  font-weight: 600;
  color: var(--text-color);
}

.crypto-symbol {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-left: 0.5rem;
}

.crypto-price {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--success-color);
}

.price-change {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  margin-left: 0.5rem;
}

.price-change.positive {
  background: var(--success-color);
  color: white;
}

.price-change.negative {
  background: var(--error-color);
  color: white;
}

/* TODO Placeholder */
.todo-placeholder {
  text-align: center;
  padding: 2rem;
  background: var(--warning-color);
  color: white;
  border-radius: 8px;
}

.todo-placeholder code {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.5rem;
  border-radius: 4px;
}

/* Stats Widget */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 1rem;
}

.stat-card {
  text-align: center;
  padding: 1rem;
  background: var(--bg-color);
  border-radius: 8px;
}

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

.stat-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Preferences Panel */
.preferences-panel {
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.preferences-panel h3 {
  margin-bottom: 1rem;
  color: var(--text-color);
}

.pref-group {
  margin-bottom: 1rem;
}

.pref-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  color: var(--text-color);
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* Footer */
.footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.api-credits {
  font-size: 0.8rem;
  margin-top: 0.5rem;
  opacity: 0.7;
}

/* NASA APOD Grid Styles */
.apod-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    max-height: 600px;
    overflow-y: auto;
    padding: 0.5rem;
}

.apod-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
    border: 2px solid transparent;
}

.apod-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.apod-card.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.apod-card-header {
    padding: 1rem;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
}

.apod-card-header h3 {
    font-size: 1rem;
    margin: 0 0 0.5rem 0;
    color: var(--text-color);
    line-height: 1.3;
}

.apod-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.apod-media {
    position: relative;
    height: 180px;
    overflow: hidden;
}

.apod-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.apod-card:hover .apod-media img {
    transform: scale(1.05);
}

.video-link {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
}

.video-link:hover {
    transform: scale(1.02);
}

.apod-card-footer {
    padding: 1rem;
    display: flex;
    gap: 0.5rem;
    background: var(--bg-color);
}

.btn-select {
    flex: 1;
    padding: 0.5rem;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    background: var(--border-color);
    color: var(--text-color);
}

.btn-select:hover {
    background: var(--primary-color);
    color: white;
}

.btn-select.selected {
    background: var(--success-color);
    color: white;
}

.btn-hd {
    padding: 0.5rem 0.75rem;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    background: var(--secondary-color);
    color: white;
}

.btn-hd:hover {
    background: #6d28d9;
    transform: translateY(-1px);
}

/* Comparison Widget Styles */
.comparison-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.comparison-card {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.comparison-card h4 {
    margin: 0 0 1rem 0;
    color: var(--text-color);
    font-size: 1.1rem;
}

.comparison-card p {
    margin: 0.5rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.comparison-card .explanation {
    line-height: 1.4;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.comparison-hint {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 2rem;
}

/* Notification Styles */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    z-index: 1000;
    animation: slideIn 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.notification.success {
    background: var(--success-color);
}

.notification.warning {
    background: var(--warning-color);
}

.notification.error {
    background: var(--error-color);
}

.notification.info {
    background: var(--primary-color);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Enhanced Loading States */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

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

/* Error and Empty States */
.no-data {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 2rem;
}

.error-message {
    background: var(--error-color);
    color: white;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

/* Chart Widget Enhancements */
.chart-widget .widget-content {
    padding: 1rem;
    min-height: 300px;
}

.chart-widget select {
    margin-bottom: 1rem;
    width: 100%;
    max-width: 200px;
}

/* Responsive Design for NASA Dashboard */
@media (max-width: 768px) {
    .apod-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1rem;
    }
    
    .comparison-grid {
        grid-template-columns: 1fr;
    }
    
    .apod-card-footer {
        flex-direction: column;
    }
    
    .btn-select, .btn-hd {
        width: 100%;
        text-align: center;
    }
    
    .notification {
        top: 10px;
        right: 10px;
        left: 10px;
        right: 10px;
    }
}

@media (max-width: 480px) {
    .apod-grid {
        grid-template-columns: 1fr;
        max-height: none;
    }
    
    .apod-media {
        height: 200px;
    }
}

/* Utility Classes */
.hidden {
  display: none;
}

.error-message {
  background: var(--error-color);
  color: white;
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
}

.success-message {
  background: var(--success-color);
  color: white;
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
}
