/* ===================================
   CSS CUSTOM PROPERTIES (VARIABLES)
   =================================== */

:root {
  /* Color Palette */
  --color-primary: #667eea;
  --color-secondary: #764ba2;
  --color-accent: #4299e1;

  /* Backgrounds */
  --color-bg-light: #f7fafc;
  --color-bg-white: #ffffff;

  /* Text Colors */
  --color-text-dark: #2d3748;
  --color-text-muted: #718096;

  /* UI Elements */
  --color-border: #e2e8f0;
  --color-error: #e53e3e;
  --color-error-bg: #fff5f5;
  --color-error-border: #fc8181;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.15);

  /* Spacing */
  --space-sm: 12px;
  --space-md: 20px;
  --space-lg: 32px;

  /* Typography */
  --font-size-sm: 14px;
  --font-size-base: 16px;
  --font-size-lg: 18px;
  --font-size-xl: 20px;
  --font-size-2xl: 24px;
  --font-size-3xl: 32px;
}

/* Dark Theme - Override Variables */
body.theme-dark {
  /* Backgrounds */
  --color-bg-light: #1a202c;
  --color-bg-white: #2d3748;

  /* Text Colors */
  --color-text-dark: #f7fafc;
  --color-text-muted: #cbd5e0;

  /* UI Elements */
  --color-border: #4a5568;

  /* Accent Colors (lighter in dark mode) */
  --color-accent: #63b3ed;

  /* Shadows (darker in dark mode) */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.5);

  /* Error Colors (adjusted for dark mode) */
  --color-error-bg: #742a2a;

  /* Header Gradient (different colors for dark mode) */
  --color-primary: #4a5568;
  --color-secondary: #2d3748;
}

/* Global Reset */

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

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--color-bg-light);
  color: var(--color-text-dark);
}

/* Header */

header {
  text-align: center;
  margin-top: 30px;
  margin-bottom: 30px;
}

header h1 {
  color: var(--color-text-dark);
}

header p {
  margin-bottom: 10px;
  line-height: 1.2;
}

header p:last-of-type {
  margin-bottom: 0;
}

.header-content {
  display: flex;
  justify-content: center;
  align-items: center;
  max-width: 1400px;
  margin: 0 auto;
  gap: 10px;
}

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

/* Theme Toggle */

.theme-toggle {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(20deg);
}

.theme-icon {
  font-size: 24px;
}

/* Change Name Button */

#change-name-btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    transform 0.1s ease;
}

#change-name-btn:hover {
  background: var(--color-bg-white);
  color: var(--color-accent);
  border-color: var(--color-accent);
  transform: translateY(-1px);
}

#change-name-btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

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

/* Dashboard Layout */

.dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-md);
  padding: var(--space-md);
  max-width: 1200px;
  margin: 0 auto;
}

/* Responsive: stack on mobile */
@media (max-width: 768px) {
  .dashboard {
    grid-template-columns: 1fr;
    padding: var(--space-sm);
  }
}

.widgets-container {
  display: grid;
  gap: var(--space-md);
}

/* Flowing layout: weather full-width on top, tasks + quotes/game below */
@media (min-width: 900px) {
  .widgets-container {
    grid-template-columns: 3fr 2fr;
    grid-template-rows: auto auto;
    grid-template-areas:
  "tasks   side"
  "weather weather";
  }

  .weather-widget {
    grid-area: weather;
  }

  .tasks-widget {
    grid-area: tasks;
  }

  .widget-column-small {
    grid-area: side;
  }
}

@media (max-width: 899px) {
  .widgets-container {
    grid-template-columns: 1fr;
  }
}

.widget {
  background: var(--color-bg-white);
  padding: var(--space-md);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  min-height: 200px;
}

.widget h2 {
  margin-bottom: 15px;
  color: var(--color-text-dark);
  font-size: 1.2em;
  border-bottom: 2px solid var(--color-border);
}

.widget-column {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* ===========================
   Weather Widget Styles
   =========================== */

.weather-current {
  text-align: center;
  margin-bottom: 20px;
}

.weather-icon {
  font-size: 64px;
  margin-bottom: 10px;
}

.weather-temp {
  font-size: 48px;
  font-weight: bold;
  color: var(--color-text-dark);
  margin: 10px 0;
}

.weather-location {
  font-size: 18px;
  color: var(--color-text-muted);
  margin: 5px 0;
}

.weather-condition {
  font-size: 16px;
  color: var(--color-text-muted);
  font-weight: 500;
}

/* Evenly spaced detail row */
.weather-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 15px;
  border-top: 1px solid var(--color-border);
  margin-top: 20px;
  gap: 15px;
}

.weather-detail {
  flex: 1;
  text-align: center;
}

.weather-detail span {
  display: block;
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: 5px;
}

.weather-detail strong {
  font-size: 18px;
  color: var(--color-text-dark);
}

/* Error Message Styles */
.error-message {
  text-align: center;
  padding: var(--space-md);
}

.error-icon {
  font-size: 48px;
  margin-bottom: 10px;
}

.error-message p {
  color: var(--color-error);
  font-size: var(--font-size-base);
  margin: 5px 0;
}

.error-hint {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm) !important;
}

/* Weather Forecast Styles */

.weather-forecast {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--color-border);
}

.forecast-day {
  text-align: center;
  padding: 10px;
  background: var(--color-bg-light);
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
  font-size: var(--font-size-sm);
}

.forecast-day .forecast-icon {
  font-size: 24px;
  margin-bottom: 6px;
}

.forecast-day .forecast-day-name {
  font-weight: 600;
  color: var(--color-text-dark);
  margin-bottom: 4px;
}

.forecast-day .forecast-condition {
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.forecast-day .forecast-temps {
  font-weight: 500;
  color: var(--color-text-dark);
}

/* Mobile: stack forecast vertically */
@media (max-width: 768px) {
  .weather-forecast {
    grid-template-columns: 1fr;
  }
}

/* ===========================
   Quotes Widget Styles
   =========================== */

.quotes-widget {
  background: var(--color-bg-white);
  padding: var(--space-md);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.quote-card {
  text-align: center;
  padding: 30px 20px;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.quote-text {
  font-size: var(--font-size-xl);
  line-height: 1.6;
  color: var(--color-text-dark);
  font-style: italic;
  margin-bottom: 15px;
  max-width: 600px;
}

.quote-author {
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
  font-weight: 500;
}

.btn-primary {
  background: var(--color-accent);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s ease;
  width: 100%;
  margin-top: 15px;
}

.btn-primary:hover {
  background: #3182ce;
}

.btn-primary:active {
  transform: scale(0.98);
}

.quote-card {
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===========================
   Tasks Widget Styles
   =========================== */

.tasks-widget {
  background: var(--color-bg-white);
  padding: var(--space-md);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

/* Form: top row text + category, bottom row date + submit */
.task-form {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-areas:
    "text category"
    "date submit";
  gap: 10px;
  margin-bottom: 20px;
}

/* Task text input */
#task-input {
  grid-area: text;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  font-size: var(--font-size-sm);
}

#task-input:focus {
  outline: none;
  border-color: var(--color-accent);
}

/* Category dropdown */
#task-category {
  grid-area: category;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  font-size: var(--font-size-sm);
  background: var(--color-bg-white);
  color: var(--color-text-dark);
}

/* Date input */
#task-date {
  grid-area: date;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  font-size: var(--font-size-sm);
}

/* Submit button */
.task-form button[type="submit"] {
  grid-area: submit;
  padding: 10px 16px;
  border-radius: 5px;
  border: none;
  cursor: pointer;
  font-size: var(--font-size-sm);
  font-weight: 600;
  background: var(--color-accent);
  color: #fff;
  transition: background 0.2s ease, transform 0.1s ease;
}

.task-form button[type="submit"]:hover {
  background: #3182ce;
  transform: translateY(-1px);
}

.task-form button[type="submit"]:active {
  transform: translateY(0);
}

/* Mobile: stack form elements */
@media (max-width: 600px) {
  .task-form {
    grid-template-columns: 1fr;
    grid-template-areas:
      "text"
      "category"
      "date"
      "submit";
  }
}

/* ===========================
   Mini Game Widget Styles
   =========================== */

.game-widget {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
}

.game-container-with-overlay {
  position: relative;
}

.game-board-wrapper {
  position: relative;
  display: flex;
  justify-content: center;
}

.block-game-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  width: 100%;
  max-width: 220px;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-light);
  box-shadow: var(--shadow-sm);
  min-height: 150px;
  margin-bottom: 12px;
}

.game-over-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(252, 129, 129, 0.95); /* red fill */
}

.game-replay-btn {
  padding: 8px 18px;
  border-radius: 999px;
  border: none;
  background: #fff5f5;
  color: #c53030;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
}

.game-replay-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  background: #fff0f0;
}

.game-replay-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.block-cell {
  width: 100%;
  padding-bottom: 100%; /* square */
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.15s ease;
}

.block-cell-inner {
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.block-cell:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.block-cell.color-0 .block-cell-inner { background: #f97373; }
.block-cell.color-1 .block-cell-inner { background: #60a5fa; }
.block-cell.color-2 .block-cell-inner { background: #34d399; }
.block-cell.color-3 .block-cell-inner { background: #fbbf24; }
.block-cell.color-4 .block-cell-inner { background: #a855f7; }

.block-cell.empty {
  cursor: default;
}

.block-cell.empty .block-cell-inner {
  background: transparent;
}

.game-controls {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.game-controls .btn-primary {
  width: auto;
  margin-top: 0;
  padding-inline: 16px;
}

.game-scores-row {
  display: flex;
  gap: 8px;
}

.game-score-box {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 6px 10px;
  border-radius: 8px;
  background: linear-gradient(135deg, #edf2f7, #e2e8f0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  min-width: 72px;
}

/* Metallic-style background just for the best-score box */
.game-score-box.best-score {
  background: linear-gradient(135deg, #fed7e2, #bee3f8);
}

.game-score-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #4a5568;
}

.game-score-value {
  font-size: 18px;
  font-weight: 700;
  color: #1a202c;
  line-height: 1.1;
}

.game-hint {
  font-size: 12px;
  color: var(--color-text-muted);
  text-align: center;
  margin-top: 8px;
}

/* Category filters */

.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 15px;
}

.category-filters button {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-white);
  font-size: 12px;
  cursor: pointer;
  color: var(--color-text-muted);
  transition:
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    transform 0.1s ease;
}

.category-filters button:hover {
  background: var(--color-bg-light);
  color: var(--color-text-dark);
  transform: translateY(-1px);
}

/* Base active state */
.category-filters button.active {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}

/* Category-specific filter colors (inactive state) */
.category-filters button[data-filter="work"] {
  border-color: #667eea;
  color: #667eea;
}

.category-filters button[data-filter="personal"] {
  border-color: #f97316;
  color: #f97316;
}

.category-filters button[data-filter="study"] {
  border-color: #22c55e;
  color: #22c55e;
}

.category-filters button[data-filter="other"] {
  border-color: #eab308;
  color: #eab308;
}

/* Category-specific active colors */
.category-filters button.active[data-filter="work"] {
  background: #667eea;
  color: #fff;
  border-color: #667eea;
}

.category-filters button.active[data-filter="personal"] {
  background: #f97316;
  color: #fff;
  border-color: #f97316;
}

.category-filters button.active[data-filter="study"] {
  background: #22c55e;
  color: #fff;
  border-color: #22c55e;
}

.category-filters button.active[data-filter="other"] {
  background: #eab308;
  color: #fff;
  border-color: #eab308;
}

/* Task stats bar */

.task-stats {
  display: flex;
  justify-content: space-around;
  padding: 15px;
  background: var(--color-bg-light);
  border-radius: 5px;
  margin-bottom: 15px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.task-stats .stat strong {
  color: var(--color-text-dark);
}

.tasks-list {
  max-height: 300px;
  overflow-y: auto;
}

/* Task item: grid layout with two rows */
.task-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  grid-template-areas:
    "checkbox main delete"
    "checkbox meta delete";
  gap: 6px 10px;
  padding: var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: 5px;
  margin-bottom: 8px;
  background: var(--color-bg-white);
  transition: background 0.2s ease;
}

.task-item:hover {
  background: var(--color-bg-light);
}

/* Checkbox on the left */
.task-item input[type="checkbox"] {
  grid-area: checkbox;
  width: 18px;
  height: 18px;
  cursor: pointer;
  margin-top: 4px;
}

/* Main task text (first line) */
.task-item .task-text {
  grid-area: main;
  font-size: var(--font-size-sm);
  color: var(--color-text-dark);
}

/* Completed style */
.task-item.completed .task-text {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

/* Delete button on the right */
.task-item .btn-delete {
  grid-area: delete;
  padding: 6px 12px;
  background: var(--color-error-border);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.task-item .btn-delete:hover {
  background: var(--color-error);
}

/* Meta container under main text */
.task-meta {
  grid-area: meta;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  font-size: 11px;
}

/* Category badge */
.task-category {
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: capitalize;
  color: #fff;
}

/* Category badge colors */
.task-category.work {
  background: #667eea;   /* purple */
}

.task-category.personal {
  background: #f97316;   /* orange */
}

.task-category.study {
  background: #22c55e;   /* green */
}

.task-category.other {
  background: #eab308;   /* yellow */
}

/* Due date text */
.task-date {
  color: var(--color-text-muted);
}

/* Overdue tasks */
.task-item.overdue {
  border-left: 4px solid var(--color-error);
  background: var(--color-error-bg);
}

.no-tasks {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}