/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary-color: #ec4899;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --border-color: #334155;
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.container {
    display: grid;
    grid-template-columns: 1fr 2fr;
    grid-template-rows: auto 1fr;
    gap: 20px;
    padding: 20px;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.header {
    grid-column: 1 / -1;
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: 30px;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.app-title {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: 12px;
}

.theme-toggle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: var(--shadow-lg);
}

/* Progress Bar */
.progress-container {
    margin-top: 20px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.progress-percentage {
    color: var(--primary-color);
    font-weight: 600;
}

.progress-bar {
    height: 12px;
    background: var(--bg-tertiary);
    border-radius: 100px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 100px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    padding-right: 10px;
}

/* Controls */
.controls {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-md);
}

.search-box {
    position: relative;
    margin-bottom: 15px;
}

.search-box i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
}

#searchInput {
    width: 100%;
    padding: 12px 15px 12px 45px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: var(--transition);
}

#searchInput:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.filter-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-btn {
    flex: 1;
    min-width: 120px;
    padding: 10px 20px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.filter-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
}

.filter-btn.active {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow-md);
}

/* Add Task Section */
.add-task-section {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-md);
}

.task-form {
    width: 100%;
}

.form-row {
    display: flex;
    gap: 10px;
}

.task-input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: var(--transition);
}

.task-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.priority-select {
    padding: 14px 18px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.priority-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.add-btn {
    padding: 14px 30px;
    border: none;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 8px;
}

.add-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.add-btn:active {
    transform: translateY(0);
}

/* Stats */
.stats {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.stat-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.stat-card i {
    font-size: 2rem;
    color: var(--primary-color);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-number {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Main Content */
.main-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Tasks Container */
.tasks-container {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 25px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.tasks-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.tasks-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.clear-completed {
    padding: 10px 20px;
    border: 2px solid var(--danger-color);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--danger-color);
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.clear-completed:hover {
    background: var(--danger-color);
    color: white;
    transform: translateY(-2px);
}

/* Tasks List */
.tasks-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    flex: 1;
    padding-right: 10px;
}

/* Task Item */
.task-item {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: var(--transition);
    cursor: move;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.task-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.task-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
}

.task-item.completed {
    opacity: 0.6;
}

.task-item.completed .task-text {
    text-decoration: line-through;
    color: var(--text-tertiary);
}

/* Priority Badge */
.priority-badge {
    width: 8px;
    height: 40px;
    border-radius: 100px;
    flex-shrink: 0;
}

.priority-badge.low {
    background: var(--success-color);
}

.priority-badge.medium {
    background: var(--warning-color);
}

.priority-badge.high {
    background: var(--danger-color);
}

/* Checkbox */
.task-checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.task-checkbox:hover {
    border-color: var(--primary-color);
}

.task-checkbox.checked {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-color: transparent;
}

.task-checkbox i {
    color: white;
    font-size: 0.9rem;
}

/* Task Content */
.task-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.task-text {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
    word-break: break-word;
}

.task-meta {
    display: flex;
    gap: 15px;
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

/* Task Actions */
.task-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.task-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.edit-btn {
    background: transparent;
    color: var(--text-tertiary);
}

.edit-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

.copy-btn {
    background: transparent;
    color: var(--text-tertiary);
}

.copy-btn:hover {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.subtask-btn {
    background: transparent;
    color: var(--text-tertiary);
}

.subtask-btn:hover {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

.image-btn {
    background: transparent;
    color: var(--text-tertiary);
}

.image-btn:hover {
    background: rgba(236, 72, 153, 0.1);
    color: var(--secondary-color);
}

.toggle-subtasks-btn {
    background: transparent;
    color: var(--text-tertiary);
}

.toggle-subtasks-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

.favorite-btn {
    background: transparent;
    color: var(--text-tertiary);
}

.favorite-btn:hover {
    background: rgba(251, 191, 36, 0.1);
    color: #fbbf24;
}

.favorite-btn.active {
    color: #fbbf24;
}

.delete-btn {
    background: transparent;
    color: var(--text-tertiary);
}

.delete-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

/* Priority Selector */
.priority-selector {
    display: flex;
    align-items: center;
    gap: 5px;
}

.priority-change {
    padding: 2px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.75rem;
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.priority-change:hover {
    border-color: var(--primary-color);
}

.priority-change:focus {
    outline: none;
    border-color: var(--primary-color);
}

.priority-change:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Subtasks */
.subtasks-container {
    margin-top: 12px;
    padding-left: 20px;
    border-left: 3px solid var(--border-color);
    display: none;
    animation: slideDown 0.3s ease;
}

.subtasks-container.show {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 500px;
    }
}

.subtask-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    transition: var(--transition);
}

.subtask-item:hover {
    background: var(--bg-primary);
}

.subtask-item.completed .subtask-text {
    text-decoration: line-through;
    color: var(--text-tertiary);
}

.subtask-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.subtask-checkbox:hover {
    border-color: var(--primary-color);
}

.subtask-checkbox.checked {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-color: transparent;
}

.subtask-checkbox i {
    color: white;
    font-size: 0.7rem;
}

.subtask-text {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.subtask-delete {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.subtask-delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.subtasks-count {
    color: #8b5cf6;
    font-weight: 600;
}

.subtasks-count {
    color: #8b5cf6;
    font-weight: 600;
}

.images-count {
    color: var(--secondary-color);
    font-weight: 600;
}

/* Task Images */
.task-images {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.task-image-wrapper {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 2px solid var(--border-color);
    transition: var(--transition);
}

.task-image-wrapper:hover {
    border-color: var(--secondary-color);
    transform: scale(1.05);
}

.task-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    transition: var(--transition);
}

.task-image:hover {
    opacity: 0.8;
}

.image-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
    font-size: 0.7rem;
}

.task-image-wrapper:hover .image-delete {
    opacity: 1;
}

.image-delete:hover {
    background: var(--danger-color);
    transform: scale(1.1);
}

/* Image Modal */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.image-modal.show {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.image-modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.image-modal-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
}

.image-modal-close {
    position: absolute;
    top: -15px;
    right: -15px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--danger-color);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: var(--shadow-lg);
}

.image-modal-close:hover {
    background: #dc2626;
    transform: scale(1.1) rotate(90deg);
}

/* Empty State */
.empty-state {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-state.show {
    display: flex;
}

.empty-state i {
    font-size: 4rem;
    color: var(--text-tertiary);
    margin-bottom: 20px;
}

.empty-state p {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state span {
    font-size: 0.95rem;
    color: var(--text-tertiary);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: white;
    padding: 16px 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    transform: translateX(400px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

.toast.show {
    transform: translateX(0);
}

.toast i {
    font-size: 1.2rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
    }
    
    .sidebar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 15px;
        overflow-y: visible;
    }
    
    .stats {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .stat-card {
        flex: 1;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
        gap: 10px;
    }
    
    .app-title {
        font-size: 1.5rem;
    }
    
    .header {
        padding: 20px;
    }
    
    .sidebar {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .add-btn {
        width: 100%;
        justify-content: center;
    }
    
    .filter-buttons {
        flex-direction: column;
    }
    
    .filter-btn {
        width: 100%;
    }
    
    .tasks-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .clear-completed {
        width: 100%;
        justify-content: center;
    }
    
    .stats {
        flex-direction: column;
    }
    
    .toast {
        right: 10px;
        left: 10px;
        bottom: 10px;
    }
}

@media (max-width: 480px) {
    .app-title {
        font-size: 1.3rem;
    }
    
    .task-item {
        padding: 12px;
    }
    
    .task-text {
        font-size: 0.9rem;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

.sidebar::-webkit-scrollbar,
.tasks-list::-webkit-scrollbar {
    width: 6px;
}
