/* Base Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  transition: background 0.3s, color 0.3s;
}

:root {
  --bg: #f4f4f4;
  --text: #333;
  --accent: #007bff;
  --low: #28a745;
  --medium: #ffc107;
  --high: #dc3545;
}

body.dark {
  --bg: #1e1e1e;
  --text: #e4e4e4;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.controls {
  display: flex;
  gap: 0.5rem;
}

/* Inputs */
input, select, button {
  padding: 0.6rem;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 1rem;
}

input:focus, select:focus, button:focus {
  outline: 2px solid var(--accent);
}

/* Task Input */
.task-input {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}

/* Filters */
.filters {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
}

/* Task List */
#task-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Task Item */
.task {
  background: rgba(0, 0, 0, 0.03);
  border-left: 5px solid var(--medium);
  padding: 1rem;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  align-items: center;
  transition: all 0.3s ease-in-out;
}

.task.low { border-color: var(--low); }
.task.high { border-color: var(--high); }

.task.completed {
  text-decoration: line-through;
  opacity: 0.6;
}

.task-content {
  flex: 1;
}

.task-actions {
  display: flex;
  gap: 0.4rem;
}

.task button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
}

/* Clock */
footer {
  margin-top: auto;
  text-align: center;
  padding: 1rem;
}

/* Dark Mode */
body.dark input,
body.dark select,
body.dark button {
  background-color: #333;
  color: #f4f4f4;
  border: 1px solid #555;
}

/* Responsive */
@media (max-width: 768px) {
  .task-input, .filters {
    flex-direction: column;
  }

  .task {
    flex-direction: column;
    align-items: flex-start;
  }

  .task-actions {
    margin-top: 0.5rem;
  }
}

.sub-tasks {
  margin-top: 0.5rem;
  padding-left: 1.2rem;
  border-left: 2px dashed #ccc;
}

.sub-tasks li {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  padding: 0.2rem 0;
}

.sub-tasks li.completed {
  text-decoration: line-through;
  opacity: 0.6;
}

.sub-task-actions button {
  font-size: 0.8rem;
  margin-left: 0.3rem;
  cursor: pointer;
}

.progress-bar-container {
  position: relative;
  background: #e0e0e0;
  border-radius: 5px;
  height: 8px;
  margin-top: 6px;
  width: 100%;
  max-width: 200px;
}

.progress-bar {
  background: #4caf50;
  height: 100%;
  border-radius: 5px;
  transition: width 0.3s ease-in-out;
}

.progress-text {
  font-size: 12px;
  margin-left: 5px;
  display: inline-block;
  vertical-align: top;
  color: #333;
}

/* Collapsible Subtasks Styles */
.subtask-toggle {
  cursor: pointer;
  padding: 8px 0;
  font-weight: 600;
  color: #666;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.subtask-toggle:hover {
  color: #333;
}

.toggle-icon {
  font-size: 12px;
  transition: transform 0.2s ease;
  display: inline-block;
  width: 12px;
}

.sub-tasks.collapsed {
  display: none;
}

.sub-tasks {
  display: block;
  margin: 8px 0;
  padding-left: 0;
  list-style: none;
}

.progress {
  width: 100%;
  height: 8px;
  background-color: #e0e0e0;
  border-radius: 4px;
  margin: 8px 0;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #4CAF50, #45a049);
  transition: width 0.3s ease;
  border-radius: 4px;
}

/* Dark theme styles */
.dark .subtask-toggle {
  color: #ccc;
}

.dark .subtask-toggle:hover {
  color: #fff;
}

.dark .progress {
  background-color: #444;
}

/* Animation for smooth expand/collapse */
.sub-tasks {
  transition: max-height 0.3s ease, opacity 0.3s ease;
  overflow: hidden;
}

.sub-tasks.collapsed {
  max-height: 0;
  opacity: 0;
  margin: 0;
}

.sub-tasks:not(.collapsed) {
  max-height: 1000px;
  opacity: 1;
}