/* Dark mode is the only theme */
:root {
    --background-color: #0d1117;
    --container-bg: #161b22;
    --primary-color: #6c5ce7; /* Purple accent */
    --primary-hover: #8271ff;
    --text-color: #c9d1d9;
    --subtle-text: #8b949e;
    --border-color: #30363d;
    --done-color: #586069;
    --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    --drag-ghost-color: rgba(108, 92, 231, 0.2);
    --success-color: #28a745;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 2rem 1rem;
}

.container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    background-color: var(--container-bg);
    border-radius: 12px;
    box-shadow: var(--box-shadow);
    padding: 2rem;
    border: 1px solid var(--border-color);
}

.app-header {
    text-align: center;
    margin-bottom: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: center;
}

.logo {
    flex-shrink: 0;
}

.logo path {
    stroke: var(--primary-color);
}

.header-text {
    text-align: left;
}

.header-text h1 {
    margin: 0;
    color: var(--text-color);
    line-height: 1.2;
}

.header-text p {
    margin: 0;
    color: var(--subtle-text);
    line-height: 1.4;
}

.app-header {
    position: relative; 
}

.user-avatar {
    transition: transform 0.2s ease;
}

.user-avatar:hover {
    transform: scale(1.05);
}

.dropdown-menu {
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.dropdown-menu[style*="block"] {
    opacity: 1;
    transform: translateY(0);
}

.logout-btn:hover {
    background-color: rgba(255,255,255,0.05) !important;
}

.task-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

#task-input {
    flex-grow: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background-color: var(--background-color);
    color: var(--text-color);
    transition: border-color 0.2s, box-shadow 0.2s;
}

#task-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.2);
}

#add-task-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background-color: var(--primary-color);
    color: white;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#add-task-btn:hover {
    background-color: var(--primary-hover);
}

#add-task-btn:disabled {
    background-color: var(--primary-color);
    opacity: 0.5;
    cursor: not-allowed;
}

.task-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background-color: var(--background-color);
    border-radius: 8px;
    padding: 0.25rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.tab-btn {
    background: none;
    border: none;
    color: var(--subtle-text);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    text-align: center;
    transition: background-color 0.2s, color 0.2s;
}

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

#task-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.task-item {
    background-color: var(--container-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 0.25rem;
    overflow: hidden;
}

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

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    cursor: pointer;
    user-select: none;
    gap: 0.75rem;
}

.task-header-main {
    flex-grow: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.task-header h2 {
    font-size: 1rem;
    font-weight: 500;
    margin: 0;
}

.task-body {
    border-top: 1px solid var(--border-color);
    padding: 0 1rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding 0.3s ease-out;
}

.task-item[data-open="true"] .task-body {
    padding: 1rem;
    max-height: 1000px;
}

/* === FINAL & CORRECTED NOTES SECTION === */
.task-notes {
    margin-top: 0.75rem;
}

/* 1. View Mode (Default) */
.notes-display {
    display: flex;
    align-items: center; /* Align items vertically centered */
    gap: 0.75rem;
    padding: 4px 8px; /* Minimal padding */
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.notes-display:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

.notes-icon {
    width: 18px;
    height: 18px;
    stroke: var(--subtle-text);
    flex-shrink: 0;
    margin-top: 0; /* Remove extra margin */
}

.notes-text {
    flex-grow: 1;
    padding: 0;
    margin: 0;
    color: var(--text-color);
    white-space: nowrap; /* Prevent text wrapping */
    overflow: hidden; /* Hide overflow */
    text-overflow: ellipsis; /* Add ellipsis for long text */
    line-height: 1.4;
    height: 18px; /* Match icon height for single row */
}

.notes-display.is-empty .notes-text {
    color: var(--subtle-text);
    line-height: 1.4;
}

.task-notes.is-editing .notes-display {
    display: none;
}

/* 2. Edit Mode */
.notes-editor {
    display: none;
}

.task-notes.is-editing .notes-editor {
    display: block;
}

.notes-editor textarea {
    width: 100%;
    min-height: 24px; /* Increased to ensure at least one full line */
    padding: 0.25rem 0.5rem; /* Reduced padding */
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    resize: none;
    background-color: var(--background-color);
    color: var(--text-color);
    box-sizing: border-box;
    transition: all 0.2s ease-in-out;
}

.notes-editor textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.2);
}

.notes-editor-actions {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
}

.notes-editor-actions .save-btn {
    padding: 0.5rem 1rem;
    border: none;
    background-color: var(--primary-color);
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.notes-editor-actions .save-btn:hover {
    background-color: var(--primary-hover);
}

.notes-editor-actions .cancel-btn {
    padding: 0.5rem 1rem;
    border: none;
    background-color: transparent;
    color: var(--subtle-text);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.notes-editor-actions .cancel-btn:hover {
    background-color: rgba(255, 255, 255, 0.04);
    color: var(--text-color);
}

/* === END OF NOTES SECTION === */

.subtask-list {
    list-style: none;
    padding: 0;
    margin-top: 0.5rem;
}

.subtask-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.15rem 0;
}

.subtask-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-grow: 1;
}

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

.task-text {
    flex-grow: 1;
    font-size: 0.95rem;
}

.no-subtasks-message {
    color: var(--subtle-text);
    padding: 0.5rem 0;
    text-align: center;
    font-style: italic;
    font-size: 0.9rem;
}

.task-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    margin-left: 1rem;
}

.task-actions button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.2rem;
    color: var(--subtle-text);
    transition: color 0.2s ease, transform 0.2s ease;
}

.task-actions button svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

.task-actions button:hover {
    transform: scale(1.2);
}

.task-actions .edit-btn:hover {
    color: var(--primary-color);
}

.task-actions .delete-btn:hover {
    color: #ff7b72;
}

.edit-input {
    flex-grow: 1;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.95rem;
    font-family: inherit;
    line-height: 1.5;
    background-color: var(--background-color);
    color: var(--text-color);
}

.edit-input.main-task-edit {
    font-size: 1rem;
    font-weight: 500;
}

.edit-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.task-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: background-color 0.2s, border-color 0.2s;
}

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

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

.loading-spinner {
    border: 4px solid rgba(255, 255, 255, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: var(--primary-color);
    animation: spin 1s ease infinite;
    margin: 1rem auto;
}

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

.task-item.sortable-ghost {
    background-color: var(--drag-ghost-color);
    opacity: 0.7;
}

.task-item.sortable-drag {
    opacity: 0.9;
    box-shadow: 0 8px 20px rgba(0,0,0,0.5);
}

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

.app-footer p {
    margin: 0.25rem 0;
    color: var(--subtle-text);
    font-size: 0.9rem;
}

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