@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");

/* Base styles: Reset and Font */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}

/* Body: Flex container for sticky header/footer, main content handles scroll */
body {
  transition: background-color 0.3s ease, color 0.3s ease;
  min-height: 100vh; /* Ensures body takes full viewport height */
  display: flex; /* Enables flexbox layout */
  flex-direction: column; /* Stacks header, main, footer vertically */
  overflow-x: hidden; /* Prevents horizontal scrollbar for entire page */
  /* Background gradient applied here to use theme variables */
  background: linear-gradient(
    to bottom right,
    var(--bg-from),
    var(--bg-via),
    var(--bg-to)
  );
  color: var(--text-color);
}

/* Theme variables - Light */
body.theme-light {
  --bg-from: #ffffff;
  --bg-via: #e6f3f5;
  --bg-to: #ffffff;
  --card-bg: rgba(255, 255, 255, 0.9);
  --text-color: #000000;
  --accent: #047857; /* Teal 700 equivalent */
  --btn-outline-bg-light: #cbd5e1; /* Slate 300 equivalent */
  --btn-outline-text-light: #000000;
  --dropdown-hover-bg-light: #e0e0e0;
  --dropdown-hover-text-light: #000000;
  --header-text: #000000;
  --completed-bg-light: #f0f0f0;
  --completed-text-light: #888888;
}

/* Theme variables - Dark */
body.theme-dark {
  --bg-from: #1e293b; /* Slate 800 */
  --bg-via: #0f172a; /* Slate 900 */
  --bg-to: #020617; /* Slate 950 */
  --card-bg: rgba(30, 41, 59, 0.9); /* Slate 800 with transparency */
  --text-color: #ffffff;
  --accent: #34d399; /* Emerald 400 */
  --btn-outline-bg-dark: #374151; /* Gray 700 */
  --btn-outline-text-dark: #ffffff;
  --dropdown-hover-bg-dark: #4a5568; /* Gray 600 */
  --dropdown-hover-text-dark: #ffffff;
  --header-text: #ffffff;
  --completed-bg-dark: #2a3b50;
  --completed-text-dark: #a0a0a0;
}

/* Input Section Styling */
.input-section input,
.input-section select {
  padding: 0.75rem;
  font-size: 1rem;
  min-height: 40px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  color: var(--text-color);
  background-color: #fff;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
}

body.theme-dark .input-section input,
body.theme-dark .input-section select {
  background-color: #1f2937;
  color: white;
  border-color: #4a5568;
}

/* Floating labels for date/time inputs */
.floating-label-group {
  position: relative;
  flex-grow: 1;
  flex-basis: 0;
}

.floating-label-group .input {
  padding-top: 1.5rem;
  padding-bottom: 0.75rem;
  height: auto;
}

.floating-label-group .placeholder-label {
  position: absolute;
  top: 0.5rem;
  left: 0.75rem;
  font-size: 0.75rem;
  color: #6b7280;
  pointer-events: none;
  transition: all 0.2s ease-out;
  background-color: transparent;
  z-index: 1;
}

.schedule-date::before,
.schedule-time::before {
  content: attr(placeholder);
  position: absolute;
  top: 1.5rem;
  left: 0.75rem;
  color: #9ca3af;
  pointer-events: none;
  z-index: 0;
  opacity: 1;
  transition: opacity 0.2s ease-out;
}

.schedule-date:valid::before,
.schedule-date:focus::before,
.schedule-time:valid::before,
.schedule-time:focus::before {
  opacity: 0;
}

body.theme-dark .floating-label-group .placeholder-label {
  color: #9ca3af;
}

body.theme-dark .schedule-date::before,
body.theme-dark .schedule-time::before {
  color: rgba(255, 255, 255, 0.4);
}

/* Placeholder color for text inputs */
.input-section input::placeholder {
  color: #888;
}

body.theme-dark .input-section input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

/* Dropdown (DaisyUI) Theme Alignment */
.dropdown .dropdown-content {
  background-color: var(--card-bg) !important;
  color: var(--text-color) !important;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.dropdown .dropdown-content li {
  color: var(--text-color) !important;
}

.dropdown .dropdown-content li a {
  background-color: transparent !important;
  color: var(--text-color) !important;
  padding: 0.75rem 1rem;
}

body.theme-light .dropdown .dropdown-content li a:hover {
  background-color: var(--dropdown-hover-bg-light) !important;
  color: var(--dropdown-hover-text-light) !important;
}

body.theme-dark .dropdown .dropdown-content li a:hover {
  background-color: var(--dropdown-hover-bg-dark) !important;
  color: var(--dropdown-hover-text-dark) !important;
}

/* Alert Messages */
.alert-message {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
  width: 90%;
  max-width: 400px;
}

.alert-message.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) scale(1);
}

.alert-message.hide {
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) scale(0.95);
}

body.theme-light .alert-message .alert {
  background-color: #f3f4f6 !important;
  color: #1f2937 !important;
  border: 1px solid #d1d5db;
}

body.theme-dark .alert-message .alert {
  background-color: #374151 !important;
  color: var(--text-color) !important;
  border: 1px solid #4a5568 !important;
}

/* Todos List Body */
.todos-list-body {
  display: grid;
  gap: 1rem;
  animation: fadeIn 0.5s ease-in-out;
  width: 100%;
  max-width: 1200px; /* Max width for the entire list grid */
  margin-left: auto;
  margin-right: auto;
}

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

/* Individual Todo Card Styling */
.card {
  background: var(--card-bg);
  padding: 1rem;
  border-radius: 0.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: transform 0.3s ease, box-shadow 0.3s ease,
    background-color 0.3s ease, color 0.3s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Styling for completed tasks */
.card.completed {
  background-color: var(--completed-bg-light);
  color: var(--completed-text-light);
  text-decoration: none;
}

body.theme-dark .card.completed {
  background-color: var(--completed-bg-dark);
  color: var(--completed-text-dark);
}

.card.completed .font-semibold {
  text-decoration: line-through;
}

/* Priority dot styling */
.priority-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.priority-dot.low {
  background-color: #16a34a; /* Green */
}
.priority-dot.medium {
  background-color: #d97706; /* Orange */
}
.priority-dot.high {
  background-color: #dc2626; /* Red */
}

/* Card Item Layout */
.card-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  word-break: break-word;
  padding: 0.25rem 0;
}

.card-item .flex-1 {
  padding-right: 0.5rem;
}

/* Action Buttons within Cards */
.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: nowrap;
}

.actions button {
  padding: 0.25rem;
  font-size: 1rem;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem;
  transition: transform 0.3s ease, background-color 0.3s ease,
    box-shadow 0.3s ease;
}

.actions button:hover {
  transform: scale(1.05);
}

/* Footer Author Text */
.author-text a {
  color: var(--text-color);
  text-decoration: none;
  transition: color 0.3s ease;
}

.author-text a:hover {
  color: var(--accent);
}

/* Progress Card Styling */
.progress-card {
  transition: background-color 0.3s ease, color 0.3s ease,
    border-color 0.3s ease;
}

body.theme-light .progress-card {
  background-color: var(--btn-outline-bg-light) !important;
  color: var(--btn-outline-text-light) !important;
  border: 1px solid var(--btn-outline-bg-light) !important;
}

body.theme-dark .progress-card {
  background-color: var(--btn-outline-bg-dark) !important;
  color: var(--btn-outline-text-dark) !important;
  border: 1px solid var(--btn-outline-bg-dark) !important;
}

/* Styling for Sort by Due Date and Filter buttons */
.btn-outline.text-current {
  background-color: transparent;
  border-color: currentColor;
  color: currentColor;
}

body.theme-light .btn-outline.text-current {
  background-color: var(--btn-outline-bg-light);
  color: var(--btn-outline-text-light) !important;
  border-color: var(--btn-outline-bg-light);
}

body.theme-dark .btn-outline.text-current {
  background-color: var(--btn-outline-bg-dark);
  color: var(--btn-outline-text-dark) !important;
  border-color: var(--btn-outline-bg-dark);
}

body.theme-light .btn-outline.text-current:hover {
  background-color: #c0ccda;
  border-color: #c0ccda;
  color: var(--btn-outline-text-light) !important;
}

body.theme-dark .btn-outline.text-current:hover {
  background-color: #4a5568;
  border-color: #4a5568;
  color: var(--btn-outline-text-dark) !important;
}

/* Header H1 Text Color */
header h1,
header .dropdown .btn.text-current,
header .dropdown .btn.text-current i {
  color: var(--header-text) !important;
}

/* Styling for Search Input and Icon */
.input-group > .search-input,
.input-group > span {
  background-color: transparent !important;
  border: 2px solid transparent !important;
  color: var(--text-color) !important;
  box-shadow: none;
}

body.theme-light .input-group > .search-input,
body.theme-light .input-group > span {
  background-color: var(--btn-outline-bg-light) !important;
  border-color: var(--btn-outline-text-light) !important;
  color: var(--btn-outline-text-light) !important;
}

body.theme-dark .input-group > .search-input,
body.theme-dark .input-group > span {
  background-color: var(--btn-outline-bg-dark) !important;
  border-color: var(--btn-outline-text-dark) !important;
  color: var(--btn-outline-text-dark) !important;
}

/* Placeholder color for search input */
.search-input::placeholder {
  color: var(--text-color);
  opacity: 0.6;
}

body.theme-light .search-input::placeholder {
  color: var(--btn-outline-text-light);
  opacity: 0.7;
}

body.theme-dark .search-input::placeholder {
  color: var(--btn-outline-text-dark);
  opacity: 0.7;
}

/* Consistent focus styles: APPLY FOCUS TO THE PARENT INPUT-GROUP */
.input-group:focus-within > .search-input,
.input-group:focus-within > span {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent);
  border-color: var(--accent) !important;
}

body.theme-light .input-group:focus-within > .search-input,
body.theme-light .input-group:focus-within > span {
  box-shadow: 0 0 0 2px #06b6d4; /* Cyan-500 for better visibility */
  border-color: #06b6d4 !important;
}

body.theme-dark .input-group:focus-within > .search-input,
body.theme-dark .input-group:focus-within > span {
  box-shadow: 0 0 0 2px #06b6d4; /* Cyan-500 for better visibility */
  border-color: #06b6d4 !important;
}

/* Explicit Priority Colors (override Tailwind defaults) */
.text-red-600,
.dark\:text-red-400 {
  color: #dc2626 !important;
}

.text-yellow-600,
.dark\:text-yellow-400 {
  color: #d97706 !important;
}

.text-green-600,
.dark\:text-green-400 {
  color: #16a34a !important;
}

/* Improved Checkbox Visibility */
input[type="checkbox"].complete-button {
  width: 20px;
  height: 20px;
  border: 2px solid #000;
  accent-color: #111;
  cursor: pointer;
}

body.theme-dark input[type="checkbox"].complete-button {
  border-color: #fff;
  accent-color: #ccc;
}

/* Progress Bar Color Classes */
/* Webkit (Chrome, Safari, Edge) */
.progress.progress-error::-webkit-progress-value {
  background-color: #dc2626;
}
.progress.progress-error::-moz-progress-bar {
  background-color: #dc2626;
}
.progress.progress-error {
  background-color: rgba(220, 38, 38, 0.3);
}

.progress.progress-warning::-webkit-progress-value {
  background-color: #d97706;
}
.progress.progress-warning::-moz-progress-bar {
  background-color: #d97706;
}
.progress.progress-warning {
  background-color: rgba(217, 119, 6, 0.3);
}

.progress.progress-success::-webkit-progress-value {
  background-color: #16a34a;
}
.progress.progress-success::-moz-progress-bar {
  background-color: #16a34a;
}
.progress.progress-success {
  background-color: rgba(22, 163, 74, 0.3);
}

/* Specific styling for the Delete All button */
.delete-all-button {
  height: 3rem;
  font-size: 1rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #be123c !important;
  border-color: #be123c !important;
  color: white !important;
}

.delete-all-button:hover {
  background-color: #9f1239 !important;
  border-color: #9f1239 !important;
}

/* Responsive Design */
@media (min-width: 1024px) {
  .todos-list-body {
    grid-template-columns: repeat(3, 1fr);
  }
  .input-section .flex.flex-col.sm\:flex-row {
    flex-wrap: nowrap;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .input-section .flex.flex-col.sm\:flex-row {
    flex-wrap: wrap;
  }
  .todos-list-body {
    grid-template-columns: repeat(2, 1fr);
  }
  .floating-label-group {
    width: 50%;
  }
  .floating-label-group:nth-child(odd) {
    padding-right: 0.5rem;
  }
  .floating-label-group:nth-child(even) {
    padding-left: 0.5rem;
  }
}

@media (max-width: 767px) {
  .todos-list-body {
    grid-template-columns: 1fr;
  }
  .input-section .flex.flex-col.sm\:flex-row {
    flex-direction: column;
    gap: 1rem;
  }
  .floating-label-group {
    width: 100%;
    padding-right: 0 !important;
    padding-left: 0 !important;
  }
  .sidebar-card,
  .input-section,
  .progress-card {
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  header h1 {
    font-size: 1.5rem;
  }
  .card {
    padding: 0.75rem;
  }
  .input-section {
    padding: 1rem;
  }
}

html,
body {
  height: auto !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
}

main {
  flex-grow: 1;
  overflow: visible !important;
}
