/* =========================
   GLOBAL STYLES & VARIABLES
========================= */

:root {
    --primary: #2563eb;
    --bg-light: #f4f6f8;
    --bg-dark: #111827;
    --card-light: #ffffff;
    --card-dark: #1f2937;
}

/* Reset default spacing and set base font */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box; /* ensures padding doesn't affect width */
    font-family: system-ui, sans-serif; /* modern system font stack */
}

/* Base page styling */
body {
    background: var(--bg-light);
    color: #333;
    transition: 0.3s; /* smooth theme switching */
}

/* Center app layout */
.app-container {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

/* Main app card */
.todo-app {
    width: 100%;
    max-width: 1000px;
    background: var(--card-light);
    padding: 2rem;
    border-radius: 12px;
}

/* =========================
   HEADER
========================= */

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-icon {
    width: 80px;
}

/* =========================
   INPUT SECTION
========================= */

.task-input {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin: 1.5rem 0;
}

/* Inputs + dropdown styling */
.task-input input,
.task-input select {
    padding: 0.6rem;
    border-radius: 6px;
    border: 1px solid #ccc;
}

/* =========================
   BUTTONS
========================= */

button {
    cursor: pointer;
    border: none;
    border-radius: 6px;
}

/* Primary action button (add task) */
.btn-primary {
    grid-column: span 2;
    background: var(--primary);
    color: white;
    padding: 0.7rem;
}

/* Secondary buttons (edit/delete etc.) */
.btn-secondary {
    background: #e5e7eb;
    padding: 0.6rem;
}

/* =========================
   FILTER CONTROLS
========================= */

.filters {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
}

/* Individual filter buttons */
.filters button {
    font-size: 0.8rem;
    padding: 0.4rem 0.6rem;
    border-radius: 20px;
    background: #e5e7eb;
}

/* Hover effect for filter buttons */
.filters button:hover {
    background: var(--primary);
    color: white;
}

/* =========================
   SEARCH BAR
========================= */

.search-bar {
    margin-bottom: 1rem;
}

#search-input {
    width: 100%;
    padding: 0.6rem;
    border-radius: 6px;
    border: 1px solid #ccc;
}

/* =========================
   TASK LIST
========================= */

.task-list li {
    background: #f1f5f9;
    padding: 0.7rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
}

/* Completed task style (visual strike-through) */
.task-list li.completed {
    text-decoration: line-through;
    background: #d1fae5;
}

/* =========================
   PRIORITY INDICATORS
========================= */

/* Left border indicates priority level */
.task-list li.high { border-left: 5px solid #ef4444; }
.task-list li.medium { border-left: 5px solid #f59e0b; }
.task-list li.low { border-left: 5px solid #10b981; }

/* Overdue task highlight (urgent styling) */
.task-list li.overdue {
    border-left: 5px solid red;
    background: #fee2e2;
}

/* =========================
   PROGRESS SECTION
========================= */

.progress-section {
    text-align: center;
    margin: 1.5rem 0;
}

/* SVG circle background for progress ring */
.progress-bg {
    stroke: #e5e7eb;
    fill: none;
    stroke-width: 10;
}

/* Animated progress stroke */
#progress-bar {
    stroke: var(--primary);
    fill: none;
    stroke-width: 10;
    stroke-dasharray: 314;
    stroke-dashoffset: 314;
}

/* =========================
   DARK MODE STYLES
========================= */

/* Root dark mode toggle */
.dark {
    background: var(--bg-dark);
    color: #f9fafb;
}

/* Card in dark mode */
.dark .todo-app {
    background: var(--card-dark);
    color: #f9fafb;
}

/* Inputs in dark mode */
.dark .task-input input,
.dark .task-input select,
.dark #search-input {
    background: #111827;
    color: #f9fafb;
    border: 1px solid #374151;
}

/* Placeholder text visibility in dark mode */
.dark .task-input input::placeholder,
.dark #search-input::placeholder {
    color: #9ca3af;
}

/* Secondary button dark theme */
.dark .btn-secondary {
    background: #374151;
    color: #f9fafb;
}

/* Primary button remains consistent */
.dark .btn-primary {
    background: #2563eb;
    color: white;
}

/* Filter buttons in dark mode */
.dark .filters button {
    background: #374151;
    color: #f9fafb;
    border: 1px solid #4b5563;
}

/* Hover behavior still applies */
.dark .filters button:hover {
    background: var(--primary);
    color: white;
}

/* Task card dark styling */
.dark .task-list li {
    background: #374151;
    color: #f9fafb;
    border: 1px solid #4b5563;
}

/* Completed task dark mode styling */
.dark .task-list li.completed {
    background: #065f46;
    color: #d1fae5;
}

/* Overdue task dark mode */
.dark .task-list li.overdue {
    background: #7f1d1d;
    color: #fee2e2;
    border-left: 5px solid #ef4444;
}

/* Priority colors adjusted for dark theme */
.dark .task-list li.high { border-left: 5px solid #f87171; }
.dark .task-list li.medium { border-left: 5px solid #fbbf24; }
.dark .task-list li.low { border-left: 5px solid #34d399; }

/* Progress background in dark mode */
.dark .progress-bg {
    stroke: #4b5563;
}

/* Toast notification in dark mode */
.dark #toast {
    background: #1f2937;
    color: #f9fafb;
    border: 1px solid #374151;
}

/* Empty state text contrast */
.dark .empty-state {
    color: #9ca3af;
}

/* Custom scrollbar (dark mode only) */
.dark ::-webkit-scrollbar {
    width: 8px;
}

.dark ::-webkit-scrollbar-thumb {
    background: #374151;
    border-radius: 4px;
}

.dark ::-webkit-scrollbar-track {
    background: #111827;
}

/* Subtask heading contrast */
.dark .subtasks-title {
    color: white;
}

/* Subtask Empty heading in dark mode  */

.dark .empty-subtasks {
    color: white;
    font-style: italic;
}

/* =========================
   TOAST NOTIFICATION
========================= */

/* Toast base styling (notification popup) */
#toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #111;
    color: white;
    padding: 10px 14px;
    border-radius: 6px;
    opacity: 0;
    transition: 0.3s;
}

/* Toast action button */
#toast button {
    margin-left: 10px;
    padding: 3px 8px;
    border-radius: 4px;
    background: white;
    color: #111;
    cursor: pointer;
    font-size: 0.75rem;
}

/* Toast visible state */
#toast.show {
    opacity: 1;
}

/* Toast type variants */
#toast.success { background: #16a34a; }
#toast.error { background: #dc2626; }
#toast.info { background: #2563eb; }
#toast.warning { background: #f59e0b; }

/* =========================
   EMPTY STATE
========================= */

/* Shown when no tasks exist */
.empty-state {
    text-align: center;
    padding: 1.5rem;
    margin-top: 1rem;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;

    background: #f1f5f9;
    color: #475569;
    border: 1px dashed #cbd5f5;

    transition: all 0.3s ease;
}

/* Hover effect adds subtle emphasis */
.empty-state:hover {
    transform: scale(1.01);
}

/* =========================
   FILTER BUTTON STYLES
========================= */

/* Category filter colors */
button[data-filter="all"] { background: #e5e7eb; color: #111; }
button[data-filter="General"] { background: #3b82f6; color: white; }
button[data-filter="Work"] { background: #8b5cf6; color: white; }
button[data-filter="Study"] { background: #f59e0b; color: white; }
button[data-filter="Personal"] { background: #10b981; color: white; }

/* Hover states for filters */
button[data-filter="all"]:hover { background: #cbd5e1; }
button[data-filter="General"]:hover { background: #2563eb; }
button[data-filter="Work"]:hover { background: #7c3aed; }
button[data-filter="Study"]:hover { background: #d97706; }
button[data-filter="Personal"]:hover { background: #059669; }

/* Sorting buttons */
button[data-sort="priority"],
button[data-sort="date"] {
    background: #111827;
    color: white;
}

/* Sort hover effect */
button[data-sort="priority"]:hover,
button[data-sort="date"]:hover {
    background: #374151;
}

/* Click feedback animation */
.filter-group button:active,
.sort-group button:active {
    transform: scale(0.96);
}

/* Dark mode overrides for filters */
.dark button[data-filter="all"] { background: #374151; color: #f9fafb; }
.dark button[data-filter="General"] { background: #2563eb; }
.dark button[data-filter="Work"] { background: #7c3aed; }
.dark button[data-filter="Study"] { background: #d97706; }
.dark button[data-filter="Personal"] { background: #059669; }

/* Dark sort buttons */
.dark button[data-sort="priority"],
.dark button[data-sort="date"] {
    background: #1f2937;
    color: #f9fafb;
    border: 1px solid #374151;
}

/* =========================
   STATS & SUBTASKS
========================= */

/* Stats bar layout */
.stats {
    display: flex;
    justify-content: space-between;
    margin: 1rem 0;
    font-size: 0.9rem;
}

/* Subtask container */
.subtasks {
    margin-top: 5px;
    padding-left: 0;
    font-size: 10pt;
}

/* Remove bullets */
.subtasks li {
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

/* Subtask text expands */
.subtasks span {
    flex: 1;
}

/* Subtask action buttons */
.subtasks li div {
    display: flex;
    gap: 4px;
}

/* Small buttons inside subtasks */
.subtasks button {
    font-size: 0.75rem;
    padding: 2px 6px;
}

/* Subtask heading */
.subtasks-title {
    font-size: 0.8rem;
    margin-top: 8px;
    margin-bottom: 4px;
    color: black;
    transition: color 0.3s ease;
}

/* Subtask empty heading */
.empty-subtasks {
    font-size: 0.8rem;
    color: black;
    margin: 4px 0 10px;
    font-style: italic;
}

/* Pinned task highlight */
.task-list li.pinned {
    border: 2px solid gold;
}

/* =========================
   TASK ANIMATIONS
========================= */

/* Fade in animation for new tasks */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade out animation for removal */
@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
        height: auto;
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
        height: 0;
        margin: 0;
        padding: 0;
    }
}

/* Apply entry animation */
.task-animate {
    animation: fadeInUp 0.3s ease forwards;
}

/* Hover lift effect for tasks */
.task-list li {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Task hover interaction */
.task-list li:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 14px rgba(0,0,0,0.08);
}

/* Button click feedback */
button:active {
    transform: scale(0.95);
}

/* Toast slide animation */
#toast {
    transform: translateY(20px);
    transition: 0.3s ease;
}

/* Toast visible state */
#toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Checkbox animation for interaction feedback */
.task-list input[type="checkbox"] {
    transform: scale(1);
    transition: transform 0.15s ease;
}

/* Checked state emphasis */
.task-list input[type="checkbox"]:checked {
    transform: scale(1.15);
}

/* Smooth progress bar animation */
#progress-bar {
    transition: stroke-dashoffset 0.6s ease;
}