/* === Base === */

html, body {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
}

body > main {
    flex: 1;
    min-height: 0;
}

/* === Layout & Spacing === */

.todo-page h2 {
    margin: 0;
    white-space: nowrap;
}

.section-gap {
    margin-bottom: 1.25rem;
}

/* === Search & Filter Bar === */

.search-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.search-row input[type="search"] {
    margin: 0;
    flex: 0 1 14rem;
    min-width: 8rem;
    font-size: 0.875rem;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
    height: auto;
}

.filter-toggle {
    width: 2rem;
    height: 2rem;
    min-width: 2rem;
    border-radius: 50%;
    border: 1px solid var(--pico-muted-border-color);
    background: none;
    color: var(--pico-secondary);
    cursor: pointer;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.filter-toggle:hover {
    color: var(--pico-primary);
    border-color: var(--pico-primary);
}

.filter-active-dot {
    position: absolute;
    top: 0.2rem;
    right: 0.2rem;
    width: 0.5rem;
    height: 0.5rem;
    background: var(--pico-primary);
    border-radius: 50%;
}

.filter-panel {
    display: none;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    padding-top: 0.5rem;
}

.filter-panel.open {
    display: flex;
}

.filter-panel select {
    margin: 0;
    padding: 0.35rem 0.5rem;
    height: auto;
    width: auto;
    font-size: 0.85rem;
}

.filter-clear {
    font-size: 0.8rem;
    white-space: nowrap;
}

.result-count {
    margin: 0.25rem 0 0;
    color: var(--pico-muted-color);
    font-size: 0.8rem;
}

/* === Add Form === */

.add-form-main {
    margin-bottom: 0;
}

.add-form-options {
    margin-top: 0.5rem;
    margin-bottom: 0;
    border: none;
    padding: 0;
}

.add-form-options summary {
    font-size: 0.85rem;
    color: var(--pico-muted-color);
    cursor: pointer;
    list-style: none;
    padding: 0;
}

.add-form-options summary::-webkit-details-marker {
    display: none;
}

.add-form-options summary::before {
    content: "+ ";
}

.add-form-options[open] summary::before {
    content: "− ";
}

.add-form-options .option-fields {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.add-form-options .option-fields input {
    margin: 0;
    font-size: 0.875rem;
}

.add-form-options .option-fields input[type="date"] {
    max-width: 12rem;
}

.add-form-options .option-fields input[type="text"] {
    max-width: 16rem;
    flex: 1;
    min-width: 10rem;
}

/* === Todo Items === */

.todo-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    margin-bottom: 0.5rem;
}

.todo-toggle {
    margin: 0;
}

.todo-checkbox {
    appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    min-width: 1.25rem;
    border: 2px solid var(--pico-muted-border-color);
    border-radius: 0.25rem;
    background: none;
    cursor: pointer;
    padding: 0;
    margin: 0.15rem 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    line-height: 1;
    color: transparent;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

.todo-checkbox:hover {
    border-color: var(--pico-primary);
}

.todo-checkbox.checked {
    background-color: var(--pico-primary);
    border-color: var(--pico-primary);
    color: #fff;
}

.todo-content {
    flex: 1;
    min-width: 0;
}

.todo-title {
    display: block;
    line-height: 1.4;
}

.todo-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 0.2rem;
}

.todo-due {
    font-size: 0.78rem;
    color: var(--pico-muted-color);
}

.todo-due.overdue {
    color: var(--pico-color-red-500, #e53935);
    font-weight: 600;
}

.todo-tag {
    font-size: 0.7rem;
    padding: 0.1rem 0.45rem;
    border-radius: 1rem;
    line-height: 1.4;
}

.todo-actions {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    flex-shrink: 0;
}

.todo-actions form {
    margin: 0;
}

.todo-actions a,
.todo-actions button {
    margin: 0;
    padding: 0.2rem 0.6rem;
    width: auto;
    font-size: 0.8rem;
}

/* === Completed Todos === */

.completed-section {
    margin-top: 1.5rem;
}

.completed-section summary {
    color: var(--pico-muted-color);
    font-size: 0.9rem;
}

.completed-section .todo-item {
    opacity: 0.6;
}

.completed-section .todo-title {
    text-decoration: line-through;
}

/* === Empty State === */

.empty-state {
    text-align: center;
    color: var(--pico-muted-color);
    padding: 2rem 0;
}

/* === Edit Page === */

.edit-form label {
    font-weight: 500;
}

.edit-form .button-row {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.edit-form .button-row a {
    width: auto;
}

/* === Toast Notifications === */

.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    position: relative;
    overflow: hidden;
    background: var(--pico-card-background-color);
    border: 1px solid var(--pico-primary);
    border-left: 4px solid var(--pico-primary);
    border-radius: 0.25rem;
    padding: 0.75rem 1.25rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 0.9rem;
    max-width: 24rem;
    transition: opacity 0.3s ease;
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    background: var(--pico-primary);
    opacity: 0.5;
    animation: toast-shrink linear forwards;
}

.toast-error .toast-progress {
    background: var(--pico-color-red-500, #e53935);
}

.toast-undo .toast-progress {
    background: var(--pico-color-amber-500, #ff9800);
}

@keyframes toast-shrink {
    from { width: 100%; }
    to { width: 0%; }
}

.toast-error {
    border-color: var(--pico-color-red-500, #e53935);
    border-left-color: var(--pico-color-red-500, #e53935);
}

.toast-undo {
    border-color: var(--pico-color-amber-500, #ff9800);
    border-left-color: var(--pico-color-amber-500, #ff9800);
}

.toast .undo-link {
    color: var(--pico-primary);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
    margin-left: 0.5rem;
}

.toast .undo-link:hover {
    color: var(--pico-primary-hover);
}

/* === Filter auto-submit script === */

/* === Auth Split Layout === */

.auth-main {
    padding: 0;
    overflow: hidden;
}

.auth-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: 100%;
}

.auth-panel {
    background: var(--pico-primary-background);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 2.5rem;
}

.auth-panel-inner {
    max-width: 22rem;
    text-align: center;
}

.auth-panel-inner h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: #fff;
}

.auth-panel-inner p {
    color: rgba(255, 255, 255, 0.75);
    font-size: 1.05rem;
    margin-bottom: 2rem;
}

.auth-illustration {
    width: 100%;
    max-width: 18rem;
    height: auto;
}

.auth-form-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    overflow-y: auto;
}

.auth-form-panel article {
    width: 100%;
    max-width: 22rem;
}

.reg-step-indicator {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
}

.reg-step {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--pico-muted-border-color);
    transition: background 0.2s;
}

.reg-step.active {
    background: var(--pico-primary);
    width: 1.25rem;
    border-radius: 0.25rem;
}

.reg-step2-buttons {
    display: flex;
    gap: 0.75rem;
}

.reg-step2-buttons button {
    flex: 1;
    margin: 0;
}

@media (max-width: 768px) {
    .auth-main {
        height: auto;
        overflow: visible;
    }

    .auth-split {
        grid-template-columns: 1fr;
        height: auto;
    }

    .auth-panel {
        display: none;
    }

    .auth-form-panel {
        padding: 2rem 1.25rem;
        overflow-y: visible;
    }
}
