* { box-sizing: border-box; margin: 0; padding: 0; font-family: Arial, sans-serif; }
body { background-color: #f1f3f4; color: #202124; }

/* Login Styles */
#login-container { display: flex; justify-content: center; align-items: center; height: 100vh; padding: 15px; }
.login-box { background: white; padding: 2rem; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); text-align: center; width: 100%; max-width: 350px; }
.login-box h2 { margin-bottom: 1rem; color: #188038; }
.login-box input { width: 100%; padding: 10px; margin-bottom: 1rem; border: 1px solid #ccc; border-radius: 4px; font-size: 16px;}
.login-box button { width: 100%; }

/* App Styles */
main { max-width: 800px; margin: 1rem auto; padding: 0 1rem; }
.controls { position: relative; z-index: 50; background: white; padding: 1rem; border-radius: 8px; margin-bottom: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,0.1); display: flex; gap: 10px; align-items: center; justify-content: space-between;}

/* Switch Toggle */
.switch-container { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: bold; width: 85px;}
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0;}
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 22px;}
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%;}
input:checked + .slider { background-color: #188038; }
input:checked + .slider:before { transform: translateX(18px); }

/* Búsqueda */
.search-wrapper { position: relative; flex-grow: 1; min-width: 80px; display: flex; align-items: center;}
#search-input { width: 100%; padding: 8px 24px 8px 8px; border: 1px solid #dadce0; border-radius: 4px; font-size: 14px; }
#clear-search-btn { position: absolute; right: 8px; background: none; border: none; font-size: 18px; color: #5f6368; cursor: pointer; font-weight: bold;}
#clear-search-btn:hover { color: #d93025; }

/* Dropdown */
.dropdown { position: relative; display: inline-block; flex-shrink: 0;}
.dropdown-content { display: none; position: absolute; right: 0; top: 100%; background-color: #ffffff; min-width: 170px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); z-index: 1000; border-radius: 4px; overflow: hidden; margin-top: 5px; border: 1px solid #dadce0;}
.dropdown-content a, .dropdown-content label { color: #202124; padding: 12px 16px; text-decoration: none; display: block; cursor: pointer; font-size: 14px; font-weight: normal; text-align: left;}
.dropdown-content a:hover, .dropdown-content label:hover { background-color: #f1f3f4; }
.dropdown:hover .dropdown-content { display: block; }

/* Botones y Listas */
.btn { background-color: #e8f0fe; color: #1967d2; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-weight: bold; display: inline-block; text-align: center; font-size: 14px;}
.btn-primary { background-color: #1a73e8; color: white; }
ul { list-style: none; }
li.task-item { padding: 1rem; border-radius: 8px; margin-bottom: 0.5rem; display: flex; align-items: flex-start; gap: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); border: 1px solid #e0e0e0; transition: opacity 0.2s; }
li.task-item.completed { opacity: 0.85; }
li.task-item.completed .task-name { text-decoration: line-through; }
.task-content { flex-grow: 1; overflow: hidden; word-wrap: break-word;}
.task-name { font-weight: bold; margin-bottom: 4px; font-size: 1.1em;}
.task-detail { font-size: 0.9em; color: #3c4043; white-space: pre-wrap; margin-bottom: 4px;}
.task-date { font-size: 0.8em; color: #d93025; font-weight: bold;}
input[type="checkbox"] { width: 20px; height: 20px; margin-top: 2px; cursor: pointer; flex-shrink: 0;}
.edit-btn { background: none; border: none; color: #1a73e8; cursor: pointer; font-weight: bold; font-size: 18px; padding: 0 5px;}

/* Modal Styles */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; justify-content: center; align-items: center; z-index: 1000; }
.modal-content { background: white; padding: 20px; border-radius: 8px; width: 90%; max-width: 400px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 4px 6px rgba(0,0,0,0.2); }
.modal-content input[type="text"], .modal-content input[type="date"], .modal-content select { width: 100%; padding: 8px; border: 1px solid #dadce0; border-radius: 4px; font-size: 14px; }
.modal-content textarea { width: 100%; padding: 8px; border: 1px solid #dadce0; border-radius: 4px; font-size: 14px; resize: vertical; font-family: inherit;}
.modal-actions { display: flex; gap: 10px; margin-top: 5px; }
/* Cantidad en la tarea */
.task-quantity { display: inline-block; margin-left: 6px; background-color: #188038; color: #ffffff; border-radius: 10px; padding: 1px 8px; font-size: 0.75em; vertical-align: middle; }
li.completed .task-quantity { background-color: #5f6368; text-decoration: none; }

/* Etiquetas de los formularios */
.field-label { font-size: 0.8em; color: #5f6368; font-weight: bold; margin-bottom: -6px; }
.modal-content input[type="number"] { width: 100%; padding: 8px; border: 1px solid #dadce0; border-radius: 4px; font-size: 14px; }

/* Gestión de categorías */
.category-list { max-height: 240px; overflow-y: auto; border: 1px solid #dadce0; border-radius: 4px; }
.category-list li { padding: 8px 10px; margin: 0; border: none; border-bottom: 1px solid #f1f3f4; border-radius: 0; box-shadow: none; display: flex; align-items: center; gap: 8px; background: #ffffff; }
.category-list li:last-child { border-bottom: none; }
.category-empty { color: #5f6368; font-size: 0.9em; justify-content: center; }
.category-swatch { width: 18px; height: 18px; border-radius: 4px; border: 1px solid #dadce0; flex-shrink: 0; }
.category-item-name { flex-grow: 1; font-size: 0.95em; word-break: break-word; }
.category-item-count { font-size: 0.75em; color: #5f6368; background: #f1f3f4; border-radius: 10px; padding: 1px 8px; }
.delete-cat-btn { background: none; border: none; color: #d93025; cursor: pointer; font-weight: bold; font-size: 20px; padding: 0 5px; line-height: 1; }
.category-form { display: flex; flex-direction: column; gap: 10px; }
.category-form-row { display: flex; gap: 8px; align-items: center; }
.category-form-row input[type="text"] { flex-grow: 1; padding: 8px; border: 1px solid #dadce0; border-radius: 4px; font-size: 14px; }
.category-form-row input[type="color"] { width: 44px; height: 36px; padding: 2px; border: 1px solid #dadce0; border-radius: 4px; background: #fff; cursor: pointer; flex-shrink: 0; }

/* ===== Barra de categorías (salto rápido) ===== */
.quick-nav { position: sticky; top: 0; z-index: 20; display: flex; gap: 6px; align-items: center; height: 46px; padding: 6px 0; margin-bottom: 4px; background: #f1f3f4; }
.nav-chips { display: flex; gap: 6px; align-items: center; flex-grow: 1; overflow-x: auto; overflow-y: hidden; padding: 2px 0; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.nav-chips::-webkit-scrollbar { display: none; }
.nav-home { flex-shrink: 0; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; background: #ffffff; border: 1px solid #dadce0; border-radius: 50%; font-size: 16px; line-height: 1; cursor: pointer; padding: 0; }
.nav-home:hover { background: #e8f0fe; border-color: #1a73e8; }
.nav-chip { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; background: #ffffff; border: 1px solid #dadce0; border-radius: 16px; padding: 5px 10px; font-size: 13px; color: #3c4043; cursor: pointer; white-space: nowrap; }
.nav-chip.active { background: #188038; border-color: #188038; color: #ffffff; font-weight: bold; }
.nav-chip.done { opacity: 0.65; }
.nav-chip-dot { width: 10px; height: 10px; border-radius: 50%; border: 1px solid #dadce0; flex-shrink: 0; }
.nav-chip-count { font-size: 0.85em; opacity: 0.75; }

/* ===== Cabecera de categoría fija al hacer scroll ===== */
.category-header { position: sticky; top: 46px; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 8px; background: #ffffff; border-left: 5px solid #dadce0; border-radius: 4px; padding: 8px 12px; margin-bottom: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.12); }
#task-list.no-nav .category-header { top: 0; }
.category-header-name { font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.6px; font-weight: bold; color: #202124; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-header-count { font-size: 0.75em; color: #5f6368; background: #f1f3f4; border-radius: 10px; padding: 1px 8px; flex-shrink: 0; }
.category-header.done { opacity: 0.7; }
.category-header.done .category-header-name { color: #5f6368; }

/* Separador entre pendientes y completadas */
.block-separator { display: flex; align-items: center; justify-content: center; font-size: 0.75em; text-transform: uppercase; letter-spacing: 1px; font-weight: bold; color: #5f6368; margin: 18px 0 8px; padding: 0; border-top: 1px solid #dadce0; padding-top: 10px; }

/* Cada grupo es su propio contenedor para que la cabecera fija no se
   superponga con la del grupo siguiente */
.task-group { display: block; padding: 0; margin: 0 0 14px; background: none; border: none; box-shadow: none; }
.group-tasks { list-style: none; }

/* ===== Legibilidad sobre cualquier color de categoría =====
   Los valores los calcula app.js comparando cada color con el fondo */
.task-item { color: var(--fg, #202124); }
.task-item .task-name { color: var(--fg, #202124); }
.task-item .task-detail { color: var(--fg-soft, #3c4043); }
.task-item .task-date { color: var(--fg-date, #d93025); }
.task-item .edit-btn { color: var(--fg-edit, #1a73e8); }
.task-item input[type="checkbox"] { accent-color: var(--fg, #188038); }
.task-item.completed .task-name { color: var(--fg-soft, #5f6368); }
/* La pastilla de cantidad se invierte contra la tarjeta: siempre legible */
.task-item .task-quantity { background-color: var(--fg, #188038); color: var(--bg, #ffffff); }
