/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --primary-dark: #5a67d8;
    --secondary-color: #764ba2;
    --accent-color: #f093fb;
    --success-color: #48bb78;
    --danger-color: #f56565;
    --warning-color: #ed8936;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --text-muted: #a0aec0;
    --bg-primary: #ffffff;
    --bg-secondary: #f7fafc;
    --bg-tertiary: #edf2f7;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Priority colors */
    --priority-high: #dc2626;
    --priority-medium: #d97706;
    --priority-low: #16a34a;
}

/* Dark mode variables */
[data-theme="dark"] {
    --text-primary: #f7fafc;
    --text-secondary: #cbd5e0;
    --text-muted: #718096;
    --bg-primary: #1a202c;
    --bg-secondary: #2d3748;
    --bg-tertiary: #4a5568;
    --border-color: #4a5568;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px 0 rgba(0, 0, 0, 0.15);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.15);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 50%, var(--accent-color) 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 16px;
    overflow-x: hidden;
    transition: all 0.3s ease;
}

[data-theme="dark"] body {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f172a 100%);
}

/* App container */
.app-container {
    min-height: 100vh;
    padding: 2rem 1rem;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.todo-app {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 500px;
    overflow: hidden;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.app-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 2rem 2rem 1.5rem;
    position: relative;
    overflow: hidden;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.app-title {
    font-size: 2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
    z-index: 1;
}

.title-icon {
    font-size: 2.25rem;
    animation: bounce 2s infinite;
}

@keyframes bounce {

    0%,
    20%,
    53%,
    80%,
    100% {
        transform: translateY(0);
    }

    40%,
    43% {
        transform: translateY(-8px);
    }

    70% {
        transform: translateY(-4px);
    }

    90% {
        transform: translateY(-2px);
    }
}

.header-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.theme-toggle {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.theme-toggle .sun-icon,
.theme-toggle .moon-icon {
    position: absolute;
    transition: all 0.3s ease;
}

.theme-toggle .moon-icon {
    opacity: 0;
    transform: rotate(180deg);
}

[data-theme="dark"] .theme-toggle .sun-icon {
    opacity: 0;
    transform: rotate(-180deg);
}

[data-theme="dark"] .theme-toggle .moon-icon {
    opacity: 1;
    transform: rotate(0deg);
}

.header-stats {
    display: flex;
    gap: 2rem;
    margin-bottom: 1rem;
    justify-content: center;
}

.stat-item {
    text-align: center;
    flex: 1;
}

.stat-number {
    display: block;
    font-size: 1.875rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.875rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #48bb78, #38a169);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-size: 0.875rem;
    font-weight: 500;
    min-width: 80px;
    text-align: right;
}

/* Search section */
.search-section {
    padding: 1.5rem 2rem 0;
    background: var(--bg-secondary);
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    z-index: 1;
}

#search-input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 3rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-family: inherit;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.2s ease;
    outline: none;
}

#search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#search-input::placeholder {
    color: var(--text-muted);
}

.clear-search {
    position: absolute;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clear-search:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

/* Input section */
.input-section {
    padding: 1.5rem 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.input-container {
    position: relative;
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

#new-task-input {
    flex: 1;
    padding: 1rem 1.25rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-family: inherit;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.2s ease;
    outline: none;
}

#new-task-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

#new-task-input::placeholder {
    color: var(--text-muted);
}

.priority-select {
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.2s ease;
    outline: none;
    cursor: pointer;
    min-width: 100px;
}

.priority-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.add-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.add-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.add-btn:active {
    transform: translateY(0);
}

/* Tasks section */
.tasks-section {
    min-height: 200px;
    max-height: 450px;
    overflow-y: auto;
}

.task-list {
    list-style: none;
}

.task-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
    transition: all 0.2s ease;
    animation: slideInLeft 0.3s ease-out;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.task-item:hover {
    background: var(--bg-secondary);
    transform: translateX(4px);
}

.task-item.completed {
    opacity: 0.6;
    background: var(--bg-tertiary);
}

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

.task-item.hidden {
    display: none;
}

.task-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.task-details {
    flex: 1;
    min-width: 0;
}

.task-text {
    font-size: 1rem;
    color: var(--text-primary);
    word-break: break-word;
    display: block;
    margin-bottom: 0.25rem;
}

.task-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.priority-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.priority-high {
    background: rgba(220, 38, 38, 0.1);
    color: var(--priority-high);
    border: 1px solid rgba(220, 38, 38, 0.2);
}

.priority-medium {
    background: rgba(217, 119, 6, 0.1);
    color: var(--priority-medium);
    border: 1px solid rgba(217, 119, 6, 0.2);
}

.priority-low {
    background: rgba(22, 163, 74, 0.1);
    color: var(--priority-low);
    border: 1px solid rgba(22, 163, 74, 0.2);
}

.task-checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    outline: none;
    position: relative;
}

.task-checkbox:hover {
    border-color: var(--success-color);
    background: rgba(72, 187, 120, 0.05);
}

.task-checkbox.checked {
    background: var(--success-color);
    border-color: var(--success-color);
}

.check-icon {
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s ease;
    color: white;
}

.task-checkbox.checked .check-icon {
    opacity: 1;
    transform: scale(1);
}

.delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.8);
    outline: none;
}

.task-item:hover .delete-btn {
    opacity: 1;
    transform: scale(1);
}

.delete-btn:hover {
    background: rgba(245, 101, 101, 0.1);
    color: var(--danger-color);
}

/* Empty states */
.empty-state,
.no-search-results {
    padding: 3rem 2rem;
    text-align: center;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.empty-state h3,
.no-search-results h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 600;
}

.empty-state p,
.no-search-results p {
    color: var(--text-muted);
}

/* Footer */
.app-footer {
    padding: 1.5rem 2rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-tabs {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 0.25rem;
    border: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.filter-btn {
    background: none;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    outline: none;
    white-space: nowrap;
}

.filter-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.filter-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.clear-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    outline: none;
}

.clear-btn:hover {
    background: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}

.clear-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive design */
@media (max-width: 640px) {
    .app-container {
        padding: 1rem 0.5rem;
    }

    .todo-app {
        max-width: none;
        margin: 0;
        border-radius: var(--radius-lg);
    }

    .app-header {
        padding: 1.5rem 1.5rem 1rem;
    }

    .app-title {
        font-size: 1.5rem;
    }

    .header-stats {
        gap: 1rem;
    }

    .stat-number {
        font-size: 1.5rem;
    }

    .input-section,
    .search-section,
    .task-item,
    .app-footer {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }

    .input-container {
        flex-direction: column;
        align-items: stretch;
    }

    .priority-select {
        order: -1;
    }

    .app-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .filter-tabs {
        justify-content: center;
    }

    .filter-btn {
        padding: 0.5rem 0.5rem;
        font-size: 0.8rem;
    }
}

/* Scroll styles */
.tasks-section::-webkit-scrollbar {
    width: 6px;
}

.tasks-section::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

.tasks-section::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.tasks-section::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Focus styles for accessibility */
.task-checkbox:focus,
.delete-btn:focus,
.filter-btn:focus,
.clear-btn:focus,
.add-btn:focus,
.theme-toggle:focus,
.priority-select:focus,
.clear-search:focus {
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.5);
}

/* Loading animation for new tasks */
.task-item.adding {
    animation: slideInLeft 0.3s ease-out;
}

/* Remove task animation */
.task-item.removing {
    animation: slideOutRight 0.3s ease-out forwards;
}

@keyframes slideOutRight {
    to {
        opacity: 0;
        transform: translateX(100%);
        height: 0;
        padding: 0;
        margin: 0;
        border: 0;
    }
}

/* Search highlight */
.search-highlight {
    background: rgba(102, 126, 234, 0.2);
    padding: 0.125rem 0.25rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

/* Theme transition */
* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}