/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
    --color-surface: #f8fafc;
    --color-bg-card: #ffffff;
    --color-bg-input: #ffffff;
    --color-text: #0f172a;
    --color-border: #e2e8f0;
    --color-text-muted: #64748b;
    --color-danger: #ef4444;
    --color-success: #10b981;
    --radius-card: 12px;
    --shadow-card: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06);
}

[data-theme="dark"] {
    --color-surface: #0f172a;
    --color-bg-card: #1e293b;
    --color-bg-input: #273548;
    --color-text: #f1f5f9;
    --color-border: #334155;
    --color-text-muted: #94a3b8;
    --shadow-card: 0 1px 3px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.3);
}

/* ── Layout ────────────────────────────────────────────────────────────── */
body {
    background: var(--color-surface);
    min-height: 100vh;
}

.app-header {
    background: var(--color-bg-card);
    border-bottom: 1px solid var(--color-border);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.app-header nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-block: .75rem;
}

.app-header nav ul {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.user-email {
    font-size: .85rem;
    color: var(--color-text-muted);
}

.app-footer {
    text-align: center;
    padding-block: 2rem;
    color: var(--color-text-muted);
}

/* ── About button ──────────────────────────────────────────────────────── */
.about-btn {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 50%;
    width: 2.25rem;
    height: 2.25rem;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: .7;
    transition: opacity .15s, box-shadow .15s;
    z-index: 200;
    padding: 0;
}
.about-btn:hover { opacity: 1; box-shadow: 0 2px 8px rgba(0,0,0,.18); }

.about-dialog article {
    min-width: 220px;
    text-align: center;
}
.about-dialog h3 { margin-top: 0; }
.about-dialog p { margin: .4rem 0; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn-primary {
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: .5rem 1.25rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, transform .1s;
    white-space: nowrap;
}
.btn-primary:hover { background: #4338ca; }
.btn-primary:active { transform: scale(.97); }

.small-btn {
    padding: .25rem .75rem;
    font-size: .85rem;
}

.icon-btn {
    background: none;
    border: none;
    padding: .15rem .3rem;
    cursor: pointer;
    border-radius: 5px;
    font-size: .8rem;
    line-height: 1;
    opacity: .6;
    transition: opacity .15s, background .15s;
    flex-shrink: 0;
}
.icon-btn:hover { opacity: 1; background: rgba(0,0,0,.06); }
.icon-btn.danger:hover { background: rgba(239,68,68,.1); color: var(--color-danger); }

/* ── Auth pages ────────────────────────────────────────────────────────── */
.auth-container {
    display: flex;
    justify-content: center;
    padding-top: 4rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--color-bg-card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 2rem;
}

.auth-card h2 { margin-top: 0; }

.auth-links {
    display: flex;
    gap: .5rem;
    justify-content: center;
    font-size: .875rem;
    margin-top: 1rem;
    color: var(--color-text-muted);
}

/* ── Alerts ────────────────────────────────────────────────────────────── */
.alert {
    padding: .75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: .9rem;
}
.alert-error {
    background: rgba(239,68,68,.1);
    color: #b91c1c;
    border: 1px solid rgba(239,68,68,.3);
}
.alert-success {
    background: rgba(16,185,129,.1);
    color: #065f46;
    border: 1px solid rgba(16,185,129,.3);
}

/* ── Dashboard ─────────────────────────────────────────────────────────── */
.dashboard { padding-block: 2rem; }

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.dashboard-header h1 { margin: 0; }

.lists-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
    align-items: start;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: var(--color-text-muted);
}

/* ── List Card ─────────────────────────────────────────────────────────── */
.list-card {
    background: var(--color-bg-card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.list-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1rem .5rem;
    border-bottom: 1px solid var(--color-border);
    margin: 0;
}

.list-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.list-actions {
    display: flex;
    gap: .25rem;
}

.list-card-footer {
    padding: .75rem;
    border-top: 1px solid var(--color-border);
    margin: 0;
}

/* ── Todo list ─────────────────────────────────────────────────────────── */
.todo-list {
    list-style: none;
    margin: 0;
    padding: .5rem 0;
    min-height: 2rem;
    display: flex;
    flex-direction: column;
}

.todo-empty {
    padding: 1rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: .875rem;
    font-style: italic;
}

/* ── Todo item ─────────────────────────────────────────────────────────── */
.todo-item {
    display: flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .6rem;
    border-radius: 6px;
    margin: 1px .4rem;
    transition: background .15s;
    position: relative;
}

.todo-item:hover { background: rgba(127,127,127,.06); }

.drag-handle {
    cursor: grab;
    color: #94a3b8;
    font-size: 1.1rem;
    line-height: 1;
    flex-shrink: 0;
    user-select: none;
    opacity: 0;
    transition: opacity .15s, color .15s;
}
.todo-item:hover .drag-handle { opacity: 1; }
.drag-handle:hover { color: #64748b; }

.todo-checkbox {
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    cursor: pointer;
    accent-color: var(--list-color, #4f46e5);
}

.todo-text {
    flex: 1;
    font-size: .82rem;
    word-break: break-word;
    line-height: 1.35;
}

.todo-delete {
    flex-shrink: 0;
    opacity: .3;
    transition: opacity .15s;
}
.todo-item:hover .todo-delete { opacity: .8; }
.todo-item .todo-delete:hover { color: var(--color-danger); }

/* Completed items */
.todo-item.completed {
    opacity: .55;
    order: 99;
}
.todo-item.completed .todo-text {
    text-decoration: line-through;
    color: var(--color-text-muted);
}
.todo-item.completed .drag-handle { display: none; }

/* ── Add todo row ──────────────────────────────────────────────────────── */
.add-todo-row {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.add-todo-input {
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: .3rem .6rem;
    font-size: .875rem;
    outline: none;
    transition: border-color .15s;
    background-color: var(--color-bg-input) !important;
    color: var(--color-text) !important;
    box-sizing: border-box;
    height: 2rem;
    color-scheme: light;
}
.add-todo-input:focus { border-color: var(--list-color, #4f46e5); }
.add-todo-input::placeholder { color: var(--color-text-muted); }

[data-theme="dark"] .add-todo-input {
    background-color: #0f172a !important;
    color: #f1f5f9 !important;
    border-color: #475569 !important;
    color-scheme: dark;
}
[data-theme="dark"] .add-todo-input::placeholder { color: #64748b; }

.btn-add {
    width: 100%;
    height: 2.25rem;
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    transition: filter .15s, transform .1s;
    padding: 0 .75rem;
}
.btn-add:hover { filter: brightness(1.1); }
.btn-add:active { transform: scale(.98); }

/* ── Color picker ──────────────────────────────────────────────────────── */
.color-picker-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.color-presets {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
}

.color-swatch {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    transition: transform .15s, border-color .15s;
}
.color-swatch:hover {
    transform: scale(1.2);
    border-color: rgba(0,0,0,.3);
}

/* ── Sortable ghost ────────────────────────────────────────────────────── */
.sortable-ghost {
    opacity: .4;
    background: #e0e7ff;
    border-radius: 6px;
}

/* ── Dialog overrides ──────────────────────────────────────────────────── */
dialog article {
    max-width: 420px;
    border-radius: var(--radius-card);
}

dialog article footer {
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
    margin-top: 1rem;
}

/* ── Text helpers ──────────────────────────────────────────────────────── */
.text-muted { color: var(--color-text-muted); font-size: .9rem; }

/* (estilos de edición en .todo-edit-popover arriba) */

.todo-edit {
    flex-shrink: 0;
    opacity: 0;
    transition: opacity .15s;
}
.todo-item:hover .todo-edit { opacity: .6; }
.todo-item:hover .todo-edit:hover { opacity: 1; }

/* ── Popover edición todo ───────────────────────────────────────────────── */
.todo-edit-popover {
    position: absolute;
    top: calc(100% + 2px);
    left: .4rem;
    right: .4rem;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: .3rem;
    background: var(--color-bg-card);
    border: 1.5px solid var(--list-color, #4f46e5);
    border-radius: 8px;
    padding: .3rem .4rem;
    box-shadow: 0 4px 16px rgba(0,0,0,.18);
    margin: 0;
}

.todo-edit-input {
    flex: 1;
    min-width: 0;
    border: none !important;
    outline: none;
    background: transparent !important;
    color: #0f172a !important;
    font-size: .85rem;
    padding: .2rem .25rem !important;
    margin: 0 !important;
    width: 100% !important;
    height: auto !important;
}

[data-theme="dark"] .todo-edit-input {
    color: #f1f5f9 !important;
}

[data-theme="dark"] .todo-edit-popover {
    background: #1e3a5f;
}

.edit-pop-btn {
    background: none !important;
    border: none !important;
    cursor: pointer;
    border-radius: 5px;
    font-size: .85rem;
    font-weight: 700;
    padding: .1rem .35rem;
    line-height: 1.4;
    flex: 0 0 auto !important;
    width: auto !important;
    opacity: .7;
    transition: opacity .15s, background .15s;
}
.edit-pop-btn:hover { opacity: 1; background: rgba(127,127,127,.1); }
.edit-pop-btn.save-btn { color: var(--color-success); }

/* ── Lista counter badge ────────────────────────────────────────────────── */
.list-counter {
    display: inline-block;
    font-size: .7rem;
    font-weight: 600;
    background: rgba(127,127,127,.12);
    color: var(--color-text-muted);
    border-radius: 99px;
    padding: .1rem .45rem;
    margin-left: .4rem;
    vertical-align: middle;
    line-height: 1.4;
    letter-spacing: .02em;
}

/* ── Botón nueva lista (neutro) ─────────────────────────────────────────── */
.btn-secondary-outline {
    background: transparent;
    color: var(--color-text-muted);
    border: 1.5px solid var(--color-border);
    border-radius: 8px;
    padding: .5rem 1.25rem;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
    white-space: nowrap;
}
.btn-secondary-outline:hover {
    border-color: #94a3b8;
    color: var(--color-text);
    background: rgba(127,127,127,.06);
}

/* ── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--color-text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: .5rem; }
.empty-state h2 { color: var(--color-text); margin: .5rem 0; }
.empty-state p { margin: .25rem 0 1.5rem; font-size: .95rem; }

/* ── Tema toggle ────────────────────────────────────────────────────────── */
#theme-btn {
    font-size: 1.1rem;
    opacity: .75;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
#theme-btn:hover { opacity: 1; }
