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

body {
  font-family: "Fira Code", monospace;
  background: #0a0a0a;
  color: #c0c0c0;
  padding: 20px;
  height: 100vh;
  overflow: hidden; /* Prevent body scrolling */
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 600px 1fr;
  grid-template-rows: auto 1fr auto; /* Changed from auto 800px auto */
  gap: 20px;
  height: calc(100vh - 40px); /* Changed from min-height */
}

/* DateTime Widget - Full width at top */
.datetime {
  grid-column: 1 / -1;
  text-align: center;
}

.time {
  font-size: 4rem;
  font-weight: bold;
  margin-bottom: 10px;
  letter-spacing: 2px;
}

.date {
  font-size: 1.2rem;
  color: #888;
}

.widget {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid #333;
  border-radius: 8px;
  padding: 20px;
  backdrop-filter: blur(10px);
}

.widget-title {
  color: #666;
  font-size: 12px;
  margin-bottom: 15px;
  text-transform: lowercase;
  border-bottom: 1px solid #333;
  padding-bottom: 5px;
}


.left-column {
  grid-column: 1;
  grid-row: 2;
  width: 600px;
  height: 100%; /* Changed from 800px */
  min-height: 0; /* Allow shrinking */
}

.image-widget {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.image-container {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  overflow: hidden;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
}

#daily-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  padding: 20px 15px 10px;
  color: #c0c0c0;
}

.image-photographer {
  font-size: 0.75rem;
  color: #888;
}

.image-photographer a {
  color: #888;
  text-decoration: none;
  transition: color 0.2s ease;
}

.image-photographer a:hover {
  color: #c0c0c0;
}

.image-photographer::before {
  content: "📷 ";
}

/* Loading and placeholder states */
.image-container.loading {
  color: #666;
}

.image-container.loading #daily-image {
  display: none;
}

.image-container.loading .image-info {
  display: none;
}

.image-container.loading::after {
  content: "loading image...";
  font-size: 0.9rem;
}

.image-container.placeholder {
  background: linear-gradient(135deg, #333, #555);
  color: #666;
}

.image-container.placeholder #daily-image {
  display: none;
}

.image-container.placeholder .image-info {
  display: none;
}

.image-container.placeholder::after {
  content: "📷 no image available";
  font-size: 0.9rem;
}

/* Right Column - Other Widgets */
.right-column {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100%; /* Changed from 800px */
  overflow-y: auto;
  min-height: 0; /* Allow shrinking */
}

/* Weather Widget */
.weather-info {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.current-weather {
  flex: 1;
}

.temperature {
  font-size: 2.5rem;
  margin-bottom: 5px;
}

.condition {
  color: #888;
  margin-bottom: 15px;
}

.weather-details {
  font-size: 0.9rem;
  line-height: 1.4;
}

.forecast {
  flex: 1;
  margin-left: 20px;
  font-size: 0.85rem;
}

.forecast-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  padding: 2px 0;
}

/* Stats Widget */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* Four columns, one for each stat */
  grid-template-rows: 1fr;               /* Single row */
  gap: 15px;
  align-items: center;    
}

.stat-item {
  text-align: center;                     /* Center text horizontally */
}

.stat-label {
  color: #666;
  font-size: 0.85rem;
}

.stat-value {
  font-size: 1.1rem;
  margin-top: 2px;
}

/* Todo Widget */
.todo-input {
  width: 100%;
  background: transparent;
  border: 1px solid #333;
  color: #c0c0c0;
  padding: 8px;
  margin-bottom: 15px;
  font-family: inherit;
  border-radius: 4px;
}

.todo-input:focus {
  outline: none;
  border-color: #555;
}

.todo-item {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  padding: 5px 0;
  font-size: 0.9rem;
}

.todo-checkbox {
  margin-right: 10px;
  cursor: pointer;
}

.todo-text {
  flex: 1;
  cursor: pointer;
}

.todo-text.completed {
  text-decoration: line-through;
  opacity: 0.5;
}

.todo-tag {
  background: #333;
  color: #888;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 8px;
  font-size: 0.75rem;
}

.todo-due {
  color: #666;
  margin-left: 8px;
  font-size: 0.75rem;
}

.todo-due.overdue {
  color: #ff6b6b;
}

.todo-delete {
  margin-left: 8px;
  color: #666;
  cursor: pointer;
  font-size: 0.8rem;
}

.todo-delete:hover {
  color: #ff6b6b;
}

/* Links Widget - Full width at bottom */
.links {
  grid-column: 1 / -1;
  grid-row: 3;
}

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

.config-btn {
  background: #333;
  color: #c0c0c0;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  font-family: inherit;
}

.config-btn:hover {
  background: #555;
}

.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 30px;
}

.link-category h3 {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 10px;
  text-transform: lowercase;
}

.link-item {
  display: block;
  color: #c0c0c0;
  text-decoration: none;
  padding: 4px 0;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.link-item:hover {
  color: #fff;
}

.link-item::before {
  content: "> ";
  color: #555;
}

/* Widget Title Input */
.widget-title-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid #333;
  color: #666;
  padding: 0 0 5px 0;
  margin-bottom: 15px;
  font-family: inherit;
  font-size: 12px;
  text-transform: lowercase;
  outline: none;
}

.widget-title-input:focus {
  border-bottom-color: #555;
  color: #888;
}

.widget-title-input::placeholder {
  color: #666;
  opacity: 1;
}

/* Config Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
}

.modal-content {
  background: #1a1a1a;
  margin: 5% auto;
  padding: 20px;
  border: 1px solid #333;
  border-radius: 8px;
  width: 80%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid #333;
  padding-bottom: 10px;
}

.close {
  color: #666;
  font-size: 24px;
  cursor: pointer;
}

.close:hover {
  color: #c0c0c0;
}

.config-category {
  margin-bottom: 20px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  border: 1px solid #333;
}

.config-category h4 {
  color: #888;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.config-input {
  width: 100%;
  background: transparent;
  border: 1px solid #333;
  color: #c0c0c0;
  padding: 6px;
  margin-bottom: 8px;
  font-family: inherit;
  border-radius: 4px;
  font-size: 0.85rem;
}

.config-input:focus {
  outline: none;
  border-color: #555;
}

.config-link {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.config-link input {
  flex: 1;
}

.remove-btn,
.add-btn,
.remove-category-btn {
  background: #333;
  color: #c0c0c0;
  border: none;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  font-family: inherit;
}

.remove-btn:hover,
.remove-category-btn:hover {
  background: #ff6b6b;
}

.add-btn:hover {
  background: #555;
}

.add-category-btn {
  background: #333;
  color: #c0c0c0;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  margin-bottom: 15px;
}

.add-category-btn:hover {
  background: #555;
}

.save-btn {
  background: #555;
  color: #c0c0c0;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  float: right;
}

.save-btn:hover {
  background: #666;
}

.import-export-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid #333;
}

.export-btn,
.import-btn {
  background: #333;
  color: #c0c0c0;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  flex: 1;
}

.export-btn:hover {
  background: #555;
}

.import-btn:hover {
  background: #555;
}

/* Responsive Design */
@media (max-width: 768px) {
  body {
    padding: 10px;
    height: 100vh;
  }

  .container {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto; /* Adjusted for mobile */
    gap: 15px;
    height: calc(100vh - 20px); /* Adjusted for smaller padding */
  }

  .datetime {
    grid-column: 1;
    grid-row: 1;
  }

  .left-column {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    height: 40vh; /* Use viewport height instead of fixed px */
    min-height: 200px; /* Minimum height for usability */
  }

  .right-column {
    grid-column: 1;
    grid-row: 3;
    height: auto;
    flex: 1; /* Take remaining space */
    min-height: 0;
  }

  .links {
    grid-column: 1;
    grid-row: 4;
  }

  .search-input {
    max-width: 100%;
    padding: 10px 16px;
    font-size: 0.9rem;
  }
}