/* styles.css */

:root {
    /* Colores modo claro */
    --bg-body: #f5f5f5;
    --bg-container: #ffffff;
    --bg-task: #fafafa;
    --bg-task-hover: #f0f0f0;
    --bg-input: #f5f5f5;
    --bg-input-focus: #fff;
    --text-primary: #222;
    --text-secondary: #555;
    --text-tertiary: #666;
    --text-muted: #777;
    --text-light: #999;
    --border-color: rgba(0, 0, 0, 0.1);
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    --shadow-small: 0 1px 3px rgba(0,0,0,0.1);
}

body.dark-mode {
    /* Colores modo oscuro - MÁS NEGRO */
    --bg-body: #000000;
    --bg-container: #1a1a1a;
    --bg-task: #252525;
    --bg-task-hover: #303030;
    --bg-input: #252525;
    --bg-input-focus: #303030;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-tertiary: #a0a0a0;
    --text-muted: #888;
    --text-light: #666;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    --shadow-small: 0 1px 3px rgba(0,0,0,0.4);
}

* {
    box-sizing: border-box;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    margin: 0;
    padding: 20px;
    background: var(--bg-body);
    color: var(--text-primary);
    overflow-x: hidden;
    transition: background 0.3s, color 0.3s;
}

/* ========== LANDING PAGE ========== */
.landing {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 40px);
    text-align: center;
    padding: 20px;
}

.landing-title {
    font-size: 2.8rem;
    font-weight: 100;
    letter-spacing: 0.02em;
    margin: 0 0 20px 0;
    color: var(--text-primary);
}

.landing-text {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin: 0 0 32px 0;
    line-height: 1.6;
}

.landing .btn-main {
    padding: 14px 36px;
    font-size: 1.1rem;
}

@media (max-width: 640px) {
    .landing-title {
        font-size: 2rem;
    }
    
    .landing-text {
        font-size: 1rem;
    }
    
    .landing .btn-main {
        padding: 12px 28px;
        font-size: 1rem;
    }
}

/* ========== CONTAINER ========== */
.container {
    max-width: 520px;
    margin: 0 auto;
    background: var(--bg-container);
    padding: 20px 18px 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    transition: background 0.3s, box-shadow 0.3s;
}

h1 {
    margin-top: 0;
    text-align: center;
    font-size: 1.6rem;
}

.subtitle {
    text-align: center;
    margin-bottom: 20px;
    color: var(--text-secondary);
}

.header {
    margin-bottom: 18px;
}

.hidden {
    display: none !important;
}

/* DARK MODE TOGGLE SWITCH */
.dark-mode-toggle {
    margin-left: auto;
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
    cursor: pointer;
}

.dark-mode-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ccc;
    border-radius: 24px;
    transition: 0.3s;
}

.toggle-slider:before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.dark-mode-toggle input:checked + .toggle-slider {
    background: #1976d2;
}

.dark-mode-toggle input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

body.dark-mode .toggle-slider {
    background: #1976d2;
}

body.dark-mode .toggle-slider:before {
    transform: translateX(24px);
}

/* SYNC INFO */
.sync-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

.sync-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #4caf50;
    transition: background 0.3s;
}

.sync-indicator[data-status="synced"] { background: #4caf50; }
.sync-indicator[data-status="saving"] { background: #ffc107; animation: pulse 1s infinite; }
.sync-indicator[data-status="error"] { background: #f44336; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* TÍTULO */
.list-title-wrapper {
    text-align: center;
    margin-bottom: 10px;
}

.list-title-text {
    font-size: 1.4rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.list-title-text:hover {
    background: var(--bg-task-hover);
}

.list-title-input {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 8px;
    border: none;
    background: var(--bg-input-focus);
    color: var(--text-primary);
    resize: none;
    overflow: hidden;
    font-family: inherit;
    box-shadow: var(--shadow-small);
    min-width: 200px;
}

.list-title-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.3);
}

/* SHARE BOX */
.share-box {
    margin-top: 8px;
    font-size: 0.9rem;
}

.share-box label {
    display: block;
    margin-bottom: 4px;
}

.share-row {
    display: flex;
    gap: 6px;
    margin-bottom: 4px;
}

.share-row input {
    flex: 1;
}

.share-box small {
    color: var(--text-muted);
    display: block;
    text-align: center;
}

/* BOTONES */
button {
    cursor: pointer;
    border: none;
}

.btn-main {
    background: #1976d2;
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 1rem;
}

.btn-main:hover {
    background: #145aa1;
}

.btn-secondary {
    background: var(--bg-task);
    color: var(--text-primary);
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-task-hover);
}

/* FORM */
.new-task-form {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.new-task-form input[type="text"] {
    flex: 1;
}

input[type="text"] {
    padding: 8px 10px;
    border-radius: 8px;
    border: none;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 1rem;
}

input[type="text"]:focus {
    outline: none;
    background: var(--bg-input-focus);
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.3);
}

/* SECCIONES */
.tasks-section {
    margin-bottom: 20px;
}

.section-title {
    font-size: 0.95rem;
    color: var(--text-tertiary);
    margin: 0 0 8px 0;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* TASK LIST */
.task-list {
    list-style: none;
    padding: 0;
    margin: 0;
    min-height: 20px;
}

.task-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
    background: var(--bg-task);
    margin-bottom: 6px;
    transition: background 0.2s;
    touch-action: pan-y;
}

.task-item:hover {
    background: var(--bg-task-hover);
}

.task-item.dragging {
    opacity: 0.6;
    background: var(--bg-task-hover);
}

/* HANDLE */
.task-drag-handle {
    width: 24px;
    text-align: center;
    font-size: 1.2rem;
    color: var(--text-light);
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    flex-shrink: 0;
    opacity: 0.4;
    transition: opacity 0.2s;
    align-self: center;
}

.task-item:hover .task-drag-handle {
    opacity: 0.8;
}

.task-item.dragging .task-drag-handle {
    cursor: grabbing;
}

/* NÚMERO - CENTRADO */
.task-number {
    width: 28px;
    text-align: center;
    font-weight: 600;
    flex-shrink: 0;
    align-self: center;
}

/* CONTENIDO */
.task-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

/* MODO VISTA */
.task-view-mode {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.task-text-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.task-text-display {
    font-size: 1rem;
    font-weight: 600;
    padding: 4px 6px;
    border-radius: 6px;
    word-break: break-word;
    white-space: pre-wrap;
    line-height: 1.4;
    cursor: pointer;
}

.task-text-display:hover {
    background: var(--bg-task-hover);
}

.task-comment-icon {
    background: transparent;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    padding: 4px;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    opacity: 0.4;
    transition: opacity 0.2s;
    border-radius: 50%;
}

.task-comment-icon:hover {
    opacity: 1;
    background: var(--bg-task-hover);
}

.task-comment-display {
    font-size: 0.9rem;
    color: var(--text-tertiary);
    padding: 4px 6px;
    border-radius: 6px;
    word-break: break-word;
    white-space: pre-wrap;
    line-height: 1.3;
    cursor: pointer;
}

.task-comment-display:hover {
    background: var(--bg-task-hover);
}

/* Enlaces LINK en comentarios */
.comment-link {
    color: #1976d2;
    text-decoration: none;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(25, 118, 210, 0.1);
    transition: background 0.2s;
}

.comment-link:hover {
    background: rgba(25, 118, 210, 0.2);
    text-decoration: underline;
}

/* MODO EDICIÓN */
.task-edit-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.task-text-input,
.task-comment-input {
    width: 100%;
    border-radius: 8px;
    border: none;
    background: var(--bg-input-focus);
    color: var(--text-primary);
    padding: 6px 8px;
    font-size: 1rem;
    resize: none;
    overflow: hidden;
    font-family: inherit;
    line-height: 1.4;
    box-shadow: var(--shadow-small);
}

.task-comment-input {
    font-size: 0.9rem;
}

.task-text-input:focus,
.task-comment-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.3);
}

/* BOTONES DE EDICIÓN */
.task-edit-buttons {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
}

.task-edit-confirm,
.task-edit-cancel {
    background: transparent;
    border: none;
    font-size: 1.1rem;
    padding: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.task-edit-confirm {
    color: #4caf50;
}

.task-edit-confirm:hover {
    background: rgba(76, 175, 80, 0.1);
}

.task-edit-cancel {
    color: #f44336;
}

.task-edit-cancel:hover {
    background: rgba(244, 67, 54, 0.1);
}

/* ACCIONES */
.task-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.2s;
}

.task-item:hover .task-actions {
    opacity: 1;
}

.task-edit,
.task-delete {
    background: transparent;
    border: none;
    font-size: 1rem;
    padding: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.task-edit:hover,
.task-delete:hover {
    background: rgba(25, 118, 210, 0.1);
}

/* CHECK VERDE */
.task-done {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: var(--bg-input-focus);
    box-shadow: 0 0 0 2px #4caf50;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.task-done:hover {
    background: #e8f5e9;
}

.task-done.checked {
    background: #4caf50;
    box-shadow: none;
}

.task-done .checkmark {
    color: #fff;
    font-size: 1rem;
    font-weight: bold;
}

/* STATUS */
.status {
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    min-height: 1.2em;
}

/* PANTALLA INICIAL */
.new-list-form {
    text-align: center;
    margin-top: 20px;
}

.new-list-link {
    margin-top: 35px;
    text-align: center;
}

.new-list-link a {
    color: #1976d2;
    text-decoration: none;
    font-size: 0.80rem;
    opacity: 0.55;
    padding: 4px 6px;
    border-radius: 6px;
    transition: opacity 0.2s, background 0.2s;
}

.new-list-link a:hover {
    opacity: 1;
    background: rgba(25, 118, 210, 0.08);
}

/* ========== MÓVILES ========== */
@media (max-width: 640px) {
    body {
        padding: 10px;
        background: var(--bg-container);
    }

    .container {
        background: transparent;
        padding: 10px 5px;
        border-radius: 0;
        box-shadow: none;
    }

    .sync-info {
        font-size: 0.8rem;
    }

    .dark-mode-toggle {
        width: 42px;
        height: 22px;
    }

    .toggle-slider:before {
        height: 16px;
        width: 16px;
    }

    .dark-mode-toggle input:checked + .toggle-slider:before {
        transform: translateX(20px);
    }

    body.dark-mode .toggle-slider:before {
        transform: translateX(20px);
    }

    .list-title-text {
        font-size: 1.2rem;
    }

    .list-title-input {
        font-size: 1.1rem;
        min-width: 150px;
    }

    .share-box {
        font-size: 0.85rem;
    }

    /* BOTÓN COPIAR SIEMPRE A LA DERECHA */
    .share-row {
        display: flex;
        flex-direction: row;
        gap: 6px;
    }

    .btn-secondary {
        font-size: 0.85rem;
        padding: 8px 10px;
        flex-shrink: 0;
    }

    .new-task-form {
        gap: 6px;
    }

    .new-task-form input[type="text"] {
        font-size: 0.95rem;
    }

    .btn-main {
        padding: 8px 14px;
        font-size: 0.95rem;
    }

    .section-title {
        font-size: 0.85rem;
    }

    .task-item {
        gap: 8px;
        padding: 8px;
    }

    /* Handle más visible */
    .task-drag-handle {
        opacity: 0.6;
        font-size: 1.1rem;
        width: 20px;
    }

    .task-number {
        width: 24px;
        font-size: 0.9rem;
    }

    .task-text-display {
        font-size: 0.95rem;
    }

    .task-comment-display {
        font-size: 0.85rem;
    }

    .task-comment-icon {
        font-size: 0.9rem;
        width: 24px;
        height: 24px;
    }

    /* Acciones siempre visibles */
    .task-actions {
        opacity: 1;
    }

    .task-edit,
    .task-delete {
        width: 26px;
        height: 26px;
        font-size: 0.9rem;
    }

    .task-edit-confirm,
    .task-edit-cancel {
        width: 26px;
        height: 26px;
        font-size: 1rem;
    }

    .task-done {
        width: 26px;
        height: 26px;
    }

    .task-done .checkmark {
        font-size: 0.9rem;
    }

    .task-text-input,
    .task-comment-input {
        font-size: 0.95rem;
    }
}
