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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.stats {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Main content */
main {
    margin: 0 auto;
    padding: 20px 5% 20px 5%;
}

/* Controls */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    gap: 20px;
    flex-wrap: wrap;
}

.reset-button {
    background-color: #e74c3c;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

.reset-button:hover {
    background-color: #c0392b;
}

#search-input {
    flex: 1;
    max-width: 400px;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

#search-input:focus {
    outline: none;
    border-color: #667eea;
}

/* Task sections */
.task-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 15px;
    align-items: start;
}

.task-category {
    background: white;
    margin-bottom: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    height: fit-content;
}

.category-title {
    padding: 15px 20px;
    background-color: #34495e;
    color: white;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background-color 0.3s;
}

.category-title:hover {
    background-color: #2c3e50;
}

.toggle-icon {
    font-size: 1.2rem;
    transition: transform 0.3s;
}

.task-category.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.task-count {
    margin-left: auto;
    font-size: 0.9rem;
    opacity: 0.8;
}

.favorites-section .category-title {
    background-color: #f39c12;
}

.favorites-section .category-title:hover {
    background-color: #e67e22;
}

.completed-section .category-title {
    background-color: #27ae60;
}

.completed-section .category-title:hover {
    background-color: #229954;
}

/* Task list */
.task-list {
    max-height: 600px;
    overflow-y: auto;
    overflow-x: hidden;
    transition: max-height 0.3s ease-out;
}

.task-category.collapsed .task-list {
    max-height: 0;
    overflow: hidden;
}

/* Task items */
.task-item {
    border-bottom: 1px solid #eee;
    transition: background-color 0.3s;
}

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

.task-item:hover {
    background-color: #f8f9fa;
}

.task-header {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    cursor: pointer;
    gap: 10px;
}

.area-image {
    width: 35px;
    height: 35px;
    border-radius: 5px;
    object-fit: cover;
    border: 1px solid #ddd;
    flex-shrink: 0;
}

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

.task-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 3px;
    word-wrap: break-word;
    line-height: 1.3;
}

.task-points {
    color: #666;
    font-size: 0.8rem;
}

.task-status {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.favorite-button {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: #ddd;
    transition: color 0.3s;
    padding: 2px;
}

.favorite-button:hover {
    color: #f39c12;
}

.favorite-button.favorited {
    color: #f39c12;
}

.expand-icon {
    font-size: 1.2rem;
    color: #666;
    transition: transform 0.3s;
}

.task-item.expanded .expand-icon {
    transform: rotate(180deg);
}

/* Task details */
.task-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background-color: #f8f9fa;
    border-top: 1px solid #eee;
}

.task-item.expanded .task-details {
    max-height: 500px;
}

.task-details-content {
    padding: 15px;
}

.detail-section {
    margin-bottom: 15px;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-label {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 5px;
}

.detail-text {
    color: #555;
    line-height: 1.5;
}

.complete-button {
    background-color: #27ae60;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    margin-top: 10px;
    margin-right: 10px;
    transition: background-color 0.3s;
}

.complete-button:hover {
    background-color: #229954;
}

.complete-button.completed {
    background-color: #95a5a6;
    cursor: pointer;
}

.complete-button.completed:hover {
    background-color: #7f8c8d;
}

.uncomplete-button {
    background-color: #e74c3c;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    margin-top: 10px;
    transition: background-color 0.3s;
}

.uncomplete-button:hover {
    background-color: #c0392b;
}

/* Completed tasks styling */
.completed-section .task-item {
    opacity: 0.8;
}

/* Responsive design */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

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

    #search-input {
        max-width: none;
    }

    .task-sections {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .task-header {
        padding: 10px 12px;
        gap: 8px;
    }

    .area-image {
        width: 30px;
        height: 30px;
    }

    .task-title {
        font-size: 0.9rem;
    }

    .task-details-content {
        padding: 12px;
    }

    .favorite-button {
        font-size: 1.1rem;
    }

    main {
        padding: 15px 3% 15px 3%;
    }
}

@media (min-width: 1600px) {
    .task-sections {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 12px;
    }
}

@media (min-width: 2000px) {
    .task-sections {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 10px;
    }
}

/* Hidden class for filtering */
.hidden {
    display: none !important;
}

/* Loading state */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px;
    color: #999;
    font-style: italic;
}