/* General Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.8) 0%, rgba(118, 75, 162, 0.8) 100%),
                url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" patternUnits="userSpaceOnUse" width="100" height="100"><circle cx="25" cy="25" r="1" fill="%23ffffff" opacity="0.1"/><circle cx="75" cy="75" r="1.5" fill="%23ffffff" opacity="0.08"/><circle cx="50" cy="10" r="0.8" fill="%23ffffff" opacity="0.12"/><circle cx="10" cy="60" r="1.2" fill="%23ffffff" opacity="0.06"/><circle cx="90" cy="30" r="0.9" fill="%23ffffff" opacity="0.1"/><circle cx="40" cy="80" r="1.1" fill="%23ffffff" opacity="0.09"/><circle cx="70" cy="50" r="0.7" fill="%23ffffff" opacity="0.11"/><circle cx="15" cy="90" r="1.3" fill="%23ffffff" opacity="0.07"/><circle cx="85" cy="15" r="0.6" fill="%23ffffff" opacity="0.13"/><circle cx="35" cy="45" r="1.4" fill="%23ffffff" opacity="0.05"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    background-size: cover, 200px 200px;
    background-attachment: fixed;
    min-height: 100vh;
    padding: 20px;
    transition: all 0.3s ease;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
    padding: 30px 20px;
    position: relative;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    letter-spacing: 1px;
}

.header-buttons {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
}

.theme-toggle-btn, .settings-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.theme-toggle-btn {
    padding: 10px 12px;
    font-size: 16px;
}

.theme-toggle-btn:hover, .settings-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

/* Main Content */
main {
    padding: 30px;
}

/* Add Task Section */
.add-task-section {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    align-items: stretch;
}

#taskInput {
    flex: 1;
    padding: 15px 20px;
    border: 2px solid #e1e8ed;
    border-radius: 10px;
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
}

#taskInput:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#addTaskBtn {
    padding: 15px 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

#addTaskBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* Task List */
.task-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Task Items */
.task-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
}

.task-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.task-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.task-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #667eea;
}

.task-title {
    flex: 1;
    font-size: 18px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.task-title:hover {
    background-color: #f0f0f0;
}

.task-title.completed {
    text-decoration: line-through;
    color: #888;
}

.task-title.editing {
    background-color: white;
    border: 2px solid #667eea;
    outline: none;
}

.task-actions {
    display: flex;
    gap: 10px;
}

.add-subtask-btn, .delete-task-btn, .plan-for-me-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.add-subtask-btn {
    background-color: #28a745;
    color: white;
}

.add-subtask-btn:hover {
    background-color: #218838;
    transform: scale(1.05);
}

.plan-for-me-btn {
    background: linear-gradient(135deg, #8B5CF6 0%, #A855F7 100%);
    color: white;
    position: relative;
    overflow: hidden;
}

.plan-for-me-btn:hover {
    background: linear-gradient(135deg, #7C3AED 0%, #9333EA 100%);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.plan-for-me-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.plan-for-me-btn .loading {
    display: none;
}

.plan-for-me-btn.loading .loading {
    display: inline;
    animation: spin 1s linear infinite;
}

.plan-for-me-btn.loading .plan-text {
    display: none;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.delete-task-btn {
    background-color: #dc3545;
    color: white;
}

.delete-task-btn:hover {
    background-color: #c82333;
    transform: scale(1.05);
}

/* Subtasks */
.subtasks {
    margin-left: 35px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.subtask-item {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
}

.subtask-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.subtask-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #667eea;
}

.subtask-title {
    flex: 1;
    font-size: 16px;
    color: #555;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.subtask-title:hover {
    background-color: #f8f9fa;
}

.subtask-title.completed {
    text-decoration: line-through;
    color: #888;
}

.subtask-title.editing {
    background-color: white;
    border: 2px solid #667eea;
    outline: none;
}

.delete-subtask-btn {
    padding: 6px 10px;
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.delete-subtask-btn:hover {
    background-color: #c82333;
    transform: scale(1.05);
}

/* Add Subtask Input */
.add-subtask-section {
    margin-left: 35px;
    margin-top: 10px;
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.add-subtask-section input {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #e1e8ed;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
}

.add-subtask-section input:focus {
    border-color: #667eea;
}

.add-subtask-section button {
    padding: 10px 15px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.add-subtask-section button:hover {
    background-color: #218838;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-state h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #888;
}

.empty-state p {
    font-size: 1rem;
    color: #aaa;
}

/* Task Progress */
.task-progress {
    margin: 15px 0 10px 35px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.progress-bar-container {
    flex: 1;
    height: 8px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #28a745 0%, #20c997 100%);
    border-radius: 10px;
    transition: width 0.5s ease;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.4) 50%, transparent 100%);
    animation: progress-shine 2s infinite;
}

@keyframes progress-shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-text {
    font-size: 12px;
    color: #666;
    font-weight: 500;
    white-space: nowrap;
}

/* Confetti Animation */
@keyframes confetti-fall {
    0% {
        transform: translateY(-10px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.confetti-piece {
    opacity: 0.8;
}

/* Dark Theme */
.dark-theme {
    background: linear-gradient(135deg, rgba(31, 41, 55, 0.95) 0%, rgba(55, 65, 81, 0.95) 100%),
                url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="dark-grain" patternUnits="userSpaceOnUse" width="100" height="100"><circle cx="25" cy="25" r="1" fill="%23ffffff" opacity="0.03"/><circle cx="75" cy="75" r="1.5" fill="%23ffffff" opacity="0.02"/><circle cx="50" cy="10" r="0.8" fill="%23ffffff" opacity="0.04"/><circle cx="10" cy="60" r="1.2" fill="%23ffffff" opacity="0.01"/><circle cx="90" cy="30" r="0.9" fill="%23ffffff" opacity="0.03"/><circle cx="40" cy="80" r="1.1" fill="%23ffffff" opacity="0.02"/><circle cx="70" cy="50" r="0.7" fill="%23ffffff" opacity="0.04"/><circle cx="15" cy="90" r="1.3" fill="%23ffffff" opacity="0.01"/><circle cx="85" cy="15" r="0.6" fill="%23ffffff" opacity="0.05"/><circle cx="35" cy="45" r="1.4" fill="%23ffffff" opacity="0.01"/></pattern></defs><rect width="100" height="100" fill="url(%23dark-grain)"/></svg>');
    background-size: cover, 200px 200px;
    background-attachment: fixed;
}

.dark-theme .container {
    background: #1f2937;
    color: #e5e7eb;
}

.dark-theme .task-item {
    background: #374151;
    border-color: #4b5563;
}

.dark-theme .task-item:hover {
    background: #4b5563;
}

.dark-theme .task-title:hover {
    background-color: #4b5563;
}

.dark-theme .task-title.editing {
    background-color: #1f2937;
    border-color: #667eea;
    color: #e5e7eb;
}

.dark-theme .subtask-item {
    background: #1f2937;
    border-color: #374151;
}

.dark-theme .subtask-item:hover {
    background: #374151;
}

.dark-theme .subtask-title:hover {
    background-color: #374151;
}

.dark-theme .subtask-title.editing {
    background-color: #1f2937;
    border-color: #667eea;
    color: #e5e7eb;
}

.dark-theme #taskInput,
.dark-theme .add-subtask-section input,
.dark-theme .setting-group input {
    background: #374151;
    border-color: #4b5563;
    color: #e5e7eb;
}

.dark-theme #taskInput:focus,
.dark-theme .add-subtask-section input:focus,
.dark-theme .setting-group input:focus {
    border-color: #667eea;
    background: #1f2937;
}

.dark-theme .progress-bar-container {
    background: #4b5563;
}

.dark-theme .progress-text {
    color: #9ca3af;
}

.dark-theme .settings-modal {
    background: #1f2937;
    color: #e5e7eb;
}

.dark-theme .setting-group label {
    color: #e5e7eb;
}

.dark-theme .setting-group small {
    color: #9ca3af;
}

.dark-theme .empty-state h2 {
    color: #9ca3af;
}

.dark-theme .empty-state p {
    color: #6b7280;
}
@media (max-width: 768px) {
    .container {
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
    }
    
    header {
        padding: 20px 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .settings-btn {
        top: 15px;
        right: 15px;
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .add-task-section {
        flex-direction: column;
    }
    
    .task-header {
        flex-wrap: wrap;
    }
    
    .task-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .plan-for-me-btn, .add-subtask-btn, .delete-task-btn {
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .plan-for-me-btn .plan-text span:first-child {
        display: none;
    }
    
    .subtasks {
        margin-left: 20px;
    }
    
    .add-subtask-section {
        margin-left: 20px;
        flex-direction: column;
    }
    
    .settings-modal {
        width: 95%;
        margin: 20px;
        max-height: calc(100vh - 40px);
    }
    
    .settings-actions {
        flex-direction: column;
    }
    
    .test-connection-btn, .save-settings-btn {
        width: 100%;
    }
}

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

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

/* Settings Modal */
.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.settings-overlay.active {
    display: flex;
}

.settings-modal {
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.settings-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 25px;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.settings-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.close-settings {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.close-settings:hover {
    background: rgba(255, 255, 255, 0.3);
}

.settings-content {
    padding: 25px;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.setting-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
}

.setting-group input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.setting-group small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 12px;
}

.settings-actions {
    display: flex;
    gap: 15px;
    margin-top: 25px;
    flex-wrap: wrap;
}

.test-connection-btn, .save-settings-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.test-connection-btn {
    background: #17a2b8;
    color: white;
    flex: 1;
}

.test-connection-btn:hover {
    background: #138496;
    transform: translateY(-2px);
}

.test-connection-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.save-settings-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    flex: 1;
}

.save-settings-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.connection-status {
    margin-top: 15px;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    display: none;
}

.connection-status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.connection-status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

.connection-status.testing {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
    display: block;
}

/* Responsive Design Updates */
@media (max-width: 768px) {
    .container {
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
    }
    
    header {
        padding: 20px 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .header-buttons {
        top: 15px;
        right: 15px;
        gap: 8px;
    }
    
    .theme-toggle-btn, .settings-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .theme-toggle-btn {
        padding: 8px 10px;
        font-size: 14px;
    }
    
    .add-task-section {
        flex-direction: column;
    }
    
    .task-header {
        flex-wrap: wrap;
    }
    
    .task-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .plan-for-me-btn, .add-subtask-btn, .delete-task-btn {
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .plan-for-me-btn .plan-text span:first-child {
        display: none;
    }
    
    .task-progress {
        margin-left: 20px;
        flex-direction: column;
        gap: 5px;
        align-items: flex-start;
    }
    
    .progress-bar-container {
        width: 100%;
    }
    
    .progress-text {
        font-size: 11px;
    }
    
    .subtasks {
        margin-left: 20px;
    }
    
    .add-subtask-section {
        margin-left: 20px;
        flex-direction: column;
    }
    
    .settings-modal {
        width: 95%;
        margin: 20px;
        max-height: calc(100vh - 40px);
    }
    
    .settings-actions {
        flex-direction: column;
    }
    
    .test-connection-btn, .save-settings-btn {
        width: 100%;
    }
}