/* CSS Reset and Base Styles */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #e0e7ff;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.2s ease;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    max-width: 640px;
    margin: 0 auto;
    padding: 2rem 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.app-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Main Content */
.main-content {
    flex: 1;
}

/* Add Task Section */
.add-task-section {
    margin-bottom: 1.5rem;
}

.task-form {
    display: flex;
    gap: 0.75rem;
    background: var(--card-bg);
    padding: 1rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.task-input {
    flex: 1;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
    transition: var(--transition);
    background: var(--bg-color);
}

.task-input:focus {
    border-color: var(--primary-color);
    background: var(--card-bg);
}

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

.add-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.add-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

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

.btn-icon {
    font-size: 1.25rem;
    line-height: 1;
}

/* Filter Section */
.filter-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.filter-buttons {
    display: flex;
    gap: 0.5rem;
    background: var(--card-bg);
    padding: 0.375rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.filter-btn {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

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

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

.task-stats {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Tasks Section */
.tasks-section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

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

.task-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--card-bg);
    transition: var(--transition);
    cursor: grab;
}

.task-item:last-child {
    border-bottom: none;
}

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

.task-item.dragging {
    opacity: 0.5;
    background: var(--primary-light);
    cursor: grabbing;
}

.task-item.drag-over {
    border-top: 2px solid var(--primary-color);
}

.drag-handle {
    display: flex;
    flex-direction: column;
    gap: 2px;
    cursor: grab;
    padding: 0.25rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.drag-handle:hover {
    color: var(--text-secondary);
}

.drag-handle span {
    display: block;
    width: 12px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
}

.task-checkbox {
    position: relative;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.task-checkbox input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 1;
}

.task-checkbox .checkmark {
    position: absolute;
    top: 0;
    left: 0;
    width: 22px;
    height: 22px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    transition: var(--transition);
}

.task-checkbox input:hover + .checkmark {
    border-color: var(--primary-color);
}

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

.task-checkbox input:checked + .checkmark::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 3px;
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

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

.task-text {
    font-size: 1rem;
    color: var(--text-primary);
    word-break: break-word;
    transition: var(--transition);
}

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

.task-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    opacity: 0;
}

.task-item:hover .delete-btn {
    opacity: 1;
}

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

.delete-btn svg {
    width: 18px;
    height: 18px;
}

/* Empty State */
.empty-state {
    padding: 3rem 1.5rem;
    text-align: center;
    display: none;
}

.empty-state.visible {
    display: block;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Actions Section */
.actions-section {
    margin-top: 1rem;
    text-align: center;
}

.clear-btn {
    padding: 0.625rem 1.25rem;
    background: transparent;
    border: 2px solid var(--danger-color);
    border-radius: var(--radius-md);
    color: var(--danger-color);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

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

/* Footer */
.app-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.app-footer p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.app-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.app-footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

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

    .app-header h1 {
        font-size: 1.5rem;
    }

    .logo {
        width: 36px;
        height: 36px;
    }

    .task-form {
        flex-direction: column;
    }

    .add-btn {
        justify-content: center;
    }

    .btn-text {
        display: inline;
    }

    .filter-section {
        flex-direction: column;
        align-items: stretch;
    }

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

    .task-stats {
        text-align: center;
    }

    .task-item {
        padding: 0.875rem 1rem;
    }

    .delete-btn {
        opacity: 1;
    }
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.task-item {
    animation: slideIn 0.2s ease;
}

/* Touch Device Optimizations */
@media (hover: none) {
    .delete-btn {
        opacity: 1;
    }
}

/* Focus Styles for Accessibility */
.add-btn:focus,
.filter-btn:focus,
.delete-btn:focus,
.clear-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.task-input:focus {
    outline: none;
}

/* Print Styles */
@media print {
    .add-task-section,
    .filter-section,
    .actions-section,
    .delete-btn,
    .drag-handle {
        display: none;
    }

    .task-item {
        break-inside: avoid;
    }
}
