:root {
    /* Define rainbow colors as CSS variables */
    --red: #FF6B6B;
    --orange: #FFA07A;
    --yellow: #FFD700;
    --green: #81C784;
    --blue: #64B5F6;
    --indigo: #7986CB;
    --violet: #BA68C8;

    --text-dark: #333;
    --text-light: #fff;
    --bg-gradient: linear-gradient(135deg, #f0f8ff, #e6e6fa);
    --completed-bg: #e0e0e0;
    --completed-text: #888;
}

body {
    font-family: 'Arial', sans-serif;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    /* Align to the top */
    min-height: 100vh;
    background: var(--bg-gradient);
    margin: 20px;
    color: var(--text-dark);
}

.todo-container {
    background-color: #fff;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    padding: 30px;
    /* width: 90%; */
    max-width: 600px;
    /* min-width:400px; */
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

h1 {
    font-size: 2.5em;
    color: var(--text-dark);
    margin-bottom: 30px;
    text-align: center;
}

.task-input-area {
    width: 100%;
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

#taskInput {
    flex-grow: 1;
    /* Allows input to take up available space */
    padding: 12px 15px;
    border: 2px solid var(--blue);
    border-radius: 10px;
    font-size: 1.1em;
    box-sizing: border-box;
    /* Include padding in width */
    transition: border-color 0.3s ease;
}

#taskInput:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 8px rgba(129, 199, 132, 0.5);
}

#addTaskBtn {
    background: linear-gradient(45deg, var(--green), var(--blue));
    color: var(--text-light);
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: bold;
    transition: all 0.3s ease;
    white-space: nowrap;
    /* Prevent button text from wrapping */
}

#addTaskBtn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

.task-list {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.task-item {
    background-color: #f9f9f9;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, background-color 0.3s ease, opacity 0.3s ease;
    cursor: pointer;
    /* To indicate clickable for completion */
}

.task-item:hover {
    transform: translateY(-3px);
}

/* Rainbow left border for tasks */
.task-item:nth-child(7n+1) {
    border-left: 8px solid var(--red);
}

.task-item:nth-child(7n+2) {
    border-left: 8px solid var(--orange);
}

.task-item:nth-child(7n+3) {
    border-left: 8px solid var(--yellow);
}

.task-item:nth-child(7n+4) {
    border-left: 8px solid var(--green);
}

.task-item:nth-child(7n+5) {
    border-left: 8px solid var(--blue);
}

.task-item:nth-child(7n+6) {
    border-left: 8px solid var(--indigo);
}

.task-item:nth-child(7n+7) {
    border-left: 8px solid var(--violet);
}

.task-content {
    flex-grow: 1;
    /* Allow content to take most space */
    font-size: 1.1em;
    line-height: 1.4;
    word-wrap: break-word;
    /* Ensure long words wrap */
    margin-right: 15px;
    /* Space between text and buttons */
    transition: text-decoration 0.3s ease, color 0.3s ease;
}

.task-item.completed {
    background-color: var(--completed-bg);
    opacity: 0.7;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

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

.task-actions {
    display: flex;
    gap: 8px;
    /* Space between action buttons */
}

.delete-btn {
    background-color: var(--red);
    color: var(--text-light);
    border: none;
    border-radius: 50%;
    /* Make it a circle */
    width: 30px;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.9em;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s ease, background-color 0.2s ease;
}

.delete-btn:hover {
    opacity: 1;
    background-color: #e55a5a;
}

/* No tasks message */
#taskList:empty::before {
    content: "No tasks yet! Add your first rainbow task.";
    display: block;
    text-align: center;
    color: #888;
    font-style: italic;
    padding: 30px;
}