/* Anotador — hoja de estilos única.
   Los colores viven en variables para que el tema oscuro sólo las redefina. */

:root {
  --bg: #f7f7fb;
  --panel: #fff;
  --text: #20202a;
  --muted: #77778a;
  --line: #e9e8f0;
  --primary: #5b55e7;
  --primary2: #443dc8;
  --suave: #eeedff;
  --peligro: #d33;
  --shadow: 0 12px 35px #29245b12;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.dark {
  --bg: #17171e;
  --panel: #202028;
  --text: #f3f2f7;
  --muted: #aaa8ba;
  --line: #34333e;
  --suave: #302e55;
  --peligro: #ff6b6b;
  --shadow: 0 12px 35px #0003;
}

* { box-sizing: border-box; }

/* El atributo hidden lo oculta todo, incluso lo que declara su propio display.
   Sin esta regla, un "display: flex" del componente gana y el elemento se ve
   igual: es lo que pasaba con el aviso de cambio y con la fila del enlace. */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input { font: inherit; }
button { cursor: pointer; color: inherit; }
a { color: var(--primary); }
.muted { color: var(--muted); font-size: 13px; }
.rojo { color: var(--peligro); }
.spacer { flex: 1; }

/* ---------- Estructura ---------- */

.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

aside {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.logo { display: flex; align-items: center; gap: 10px; font-size: 20px; }
.logo span, .brand {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #6c63ed, #4338ca);
  color: #fff; border-radius: 11px; font-weight: 800;
}

.new, .primary {
  border: 0; border-radius: 11px;
  background: var(--primary); color: #fff;
  padding: 13px 17px; font-weight: 650;
  box-shadow: 0 7px 16px #5b55e733;
}
.new:hover, .primary:hover { background: var(--primary2); }

.ghost {
  border: 1px solid var(--line); border-radius: 11px;
  background: transparent; color: var(--muted); padding: 12px 16px;
}
.ghost:hover { color: var(--peligro); border-color: var(--peligro); }

nav { display: grid; gap: 5px; }
nav button, .aside-bottom button {
  border: 0; background: transparent; color: var(--muted);
  padding: 11px 13px; text-align: left; border-radius: 9px;
}
nav button.active, nav button:hover, .aside-bottom button:hover {
  background: var(--suave); color: var(--primary);
}
.aside-bottom { display: grid; margin-top: auto; }

main { padding: 0 5vw 60px; min-width: 0; }

header {
  height: 82px; display: flex; align-items: center;
  border-bottom: 1px solid var(--line); gap: 14px;
}
.search {
  max-width: 480px; flex: 1;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 15px; color: var(--muted);
}
.search input { border: 0; outline: 0; background: transparent; color: var(--text); width: 90%; }
.icon-btn { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 9px 12px; color: var(--muted); }
.icon-btn:hover { color: var(--primary); border-color: var(--primary); }
#status { margin-left: auto; color: var(--muted); font-size: 13px; }

.welcome { display: flex; justify-content: space-between; align-items: end; margin: 40px 0 24px; gap: 12px; }
.welcome h1 { font-size: 32px; margin: 0 0 6px; }
.welcome p { margin: 0; color: var(--muted); }
.welcome-actions { display: flex; gap: 8px; }

/* ---------- Tarjetas de nota ---------- */

.notes { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.notes.lista { grid-template-columns: 1fr; }
.notes.lista .note { min-height: 0; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; }
.notes.lista .preview { max-height: 40px; }

.note {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 15px; padding: 19px; min-height: 210px;
  box-shadow: var(--shadow); transition: .18s; overflow: hidden;
}
.note:hover { transform: translateY(-3px); border-color: #cbc8f8; }
.note-head { display: flex; justify-content: space-between; color: #9693b0; align-items: center; }
.note-head small { font-size: 10px; font-weight: 750; color: var(--primary); }
.clip { font-size: 11px; color: var(--muted); }
.note h2 { font-size: 18px; margin: 17px 0 10px; }
.preview { color: var(--muted); font-size: 14px; line-height: 1.5; max-height: 80px; overflow: hidden; white-space: pre-wrap; }
.tagline { margin: 14px 0; display: flex; gap: 5px; flex-wrap: wrap; }
.tagline span { font-size: 11px; background: var(--suave); color: var(--primary); padding: 4px 7px; border-radius: 7px; }
.note time { color: var(--muted); font-size: 11px; }

/* Colores de nota: un borde lateral, sin pisar el tema. */
.note.color-amarillo { border-left: 4px solid #f2c744; }
.note.color-verde { border-left: 4px solid #46bd7f; }
.note.color-azul { border-left: 4px solid #4aa3e8; }
.note.color-rosa { border-left: 4px solid #e878a8; }

.empty {
  grid-column: 1 / -1; min-height: 330px;
  display: grid; place-content: center; text-align: center;
  color: var(--muted); gap: 8px;
}
.empty b { font-size: 22px; color: var(--text); }

/* ---------- Diálogos ---------- */

dialog {
  width: min(760px, 94vw); border: 0; border-radius: 18px; padding: 28px;
  background: var(--panel); color: var(--text);
  box-shadow: 0 30px 100px #17142d55;
}
dialog::backdrop { background: #16152477; backdrop-filter: blur(3px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-head h2 { margin: 0; font-size: 22px; }
.close { border: 0; background: transparent; font-size: 27px; color: var(--muted); line-height: 1; }

.note-title {
  font-size: 27px; font-weight: 700; width: 100%;
  border: 0; outline: 0; background: transparent; color: var(--text);
  padding: 8px 0 18px;
}

.toolbar { display: flex; gap: 4px; border-block: 1px solid var(--line); padding: 10px 0; flex-wrap: wrap; align-items: center; }
.toolbar button, .upload, dialog footer button {
  border: 0; background: transparent; color: var(--muted);
  padding: 7px 10px; border-radius: 7px; font-size: 14px;
}
.toolbar button:hover, .upload:hover, dialog footer button:hover { background: var(--bg); color: var(--text); }
.toolbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.upload { cursor: pointer; }
.upload input { display: none; }

.colors { display: flex; gap: 6px; }
.colors button { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); padding: 0; }
.colors button.elegido { border-color: var(--text); transform: scale(1.15); }
.c-default { background: var(--panel); }
.c-amarillo { background: #f2c744; }
.c-verde { background: #46bd7f; }
.c-azul { background: #4aa3e8; }
.c-rosa { background: #e878a8; }

/* Aviso de cambio hecho en otro dispositivo. No reemplaza nada por su cuenta:
   el texto que se está escribiendo manda hasta que la persona decida. */
.aviso-cambio {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 14px; padding: 10px 14px;
  border: 1px solid var(--primary); border-radius: 10px;
  background: var(--suave); color: var(--text); font-size: 13px;
}
.aviso-cambio button {
  border: 0; background: var(--primary); color: #fff;
  border-radius: 8px; padding: 6px 12px; font-size: 13px;
}

.note-content { min-height: 240px; outline: 0; line-height: 1.65; padding: 22px 3px; }
.note-content:empty:before { content: attr(data-placeholder); color: var(--muted); }
.note-content h1 { font-size: 24px; }
.note-content h2 { font-size: 20px; }
.note-content blockquote {
  margin: 12px 0; padding: 6px 0 6px 14px;
  border-left: 3px solid var(--line); color: var(--muted);
}
.note-content input[type=checkbox] { margin-right: 8px; }
/* Una tarea marcada se ve tachada y apagada, sin tocar el texto guardado. */
.note-content li:has(> input[type=checkbox][checked]) {
  text-decoration: line-through; color: var(--muted);
}
.note-content li:has(> input[type=checkbox][checked]) input[type=checkbox] {
  text-decoration: none;
}
.note-content ul, .note-content ol { padding-left: 22px; }

.tags {
  width: 100%; border: 1px solid var(--line); border-radius: 9px;
  padding: 10px; background: var(--bg); color: var(--text);
}

dialog footer { display: flex; gap: 8px; margin-top: 15px; align-items: center; }
.danger { color: var(--peligro) !important; }

/* ---------- Adjuntos ---------- */

.attachments { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 4px 0 16px; }
.attachments:empty { display: none; }
.attachment { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg); }
.attachment img { width: 100%; height: 110px; object-fit: cover; display: block; }
.attachment .pdf { display: grid; place-items: center; gap: 6px; height: 110px; text-decoration: none; color: var(--muted); padding: 8px; }
.pdf-icon { font-weight: 800; color: var(--peligro); font-size: 18px; }
.pdf-name { font-size: 11px; text-align: center; word-break: break-word; }
.attachment-foot { display: flex; align-items: center; gap: 8px; padding: 6px 8px; font-size: 11px; color: var(--muted); }
.attachment-foot a { margin-left: auto; font-size: 11px; }
.attachment-foot button { border: 0; background: transparent; font-size: 11px; padding: 2px 4px; }

.dropzone {
  display: none; position: absolute; inset: 0;
  place-items: center; border-radius: 18px;
  background: #5b55e7dd; color: #fff; font-weight: 700; font-size: 18px;
  pointer-events: none;
}
dialog.arrastrando { position: relative; }
dialog.arrastrando .dropzone { display: grid; }

/* ---------- Listas de administración ---------- */

.tabs { display: flex; gap: 6px; margin: 18px 0 12px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; color: var(--muted); padding: 10px 14px; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

.list { display: grid; gap: 8px; max-height: 55vh; overflow: auto; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px;
}
.row span { display: flex; flex-direction: column; gap: 3px; }
.row small { color: var(--muted); font-size: 12px; }
.row-between { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.acciones { flex-direction: row !important; gap: 6px !important; }
.acciones button, .row > button {
  border: 1px solid var(--line); background: transparent;
  border-radius: 8px; padding: 7px 11px; font-size: 13px; white-space: nowrap;
}
.acciones button:hover, .row > button:hover { border-color: var(--primary); color: var(--primary); }

.estado { font-size: 11px; font-weight: 700; text-transform: uppercase; }
.estado.pendiente { color: #2f9e63; }
.estado.usada { color: var(--muted); }
.estado.vencida, .estado.revocada { color: var(--peligro); }

.share-row { display: flex; margin: 12px 0 18px; }
.share-row input {
  flex: 1; min-width: 0; padding: 10px;
  border: 1px solid var(--line); border-radius: 9px 0 0 9px;
  background: var(--bg); color: var(--text);
}
.share-row button { border: 0; background: var(--primary); color: #fff; padding: 0 16px; border-radius: 0 9px 9px 0; }

kbd {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 5px; padding: 2px 7px; font-size: 12px; font-family: ui-monospace, monospace;
}

/* ---------- Pantallas de acceso ---------- */

.auth { display: grid; place-items: center; min-height: 100vh; background: radial-gradient(circle at top, #e8e6ff, var(--bg) 45%); }
.dark .auth { background: radial-gradient(circle at top, #262450, var(--bg) 45%); }
.auth-card {
  width: min(390px, 90vw); background: var(--panel); border: 1px solid var(--line);
  padding: 38px; border-radius: 20px; box-shadow: 0 25px 60px #352e7a20;
}
.auth-card .brand { margin-bottom: 20px; }
.auth-card h1 { margin: 0 0 7px; font-size: 28px; }
.auth-card p { color: var(--muted); margin: 0 0 26px; }
.auth-card label { display: grid; gap: 7px; margin: 16px 0; font-size: 13px; font-weight: 600; }
.auth-card input { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--bg); color: var(--text); }
.auth-card > button { width: 100%; border: 0; border-radius: 10px; padding: 13px; background: var(--primary); color: #fff; font-weight: 700; margin-top: 8px; }
.error { color: var(--peligro); font-size: 13px; }

/* ---------- Varios ---------- */

.mobile-menu { display: none; border: 0; background: transparent; font-size: 22px; }
.overlay { display: none; }

/* Barra de estado de la conexión. Va arriba de todo y empuja el contenido en
   lugar de taparlo: es información, no una alarma. */
.sin-conexion {
  padding: 9px 16px;
  background: #6b5b16; color: #fff;
  font-size: 13px; text-align: center;
}
.dark .sin-conexion { background: #4a3f10; }

#toast {
  position: fixed; bottom: 25px; left: 50%;
  transform: translate(-50%, 20px);
  background: #222; color: #fff; padding: 11px 18px; border-radius: 9px;
  opacity: 0; transition: .2s; pointer-events: none; z-index: 10;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Pantallas chicas ---------- */

@media (max-width: 760px) {
  .shell { display: block; }
  aside {
    position: fixed; z-index: 6; inset: 0 auto 0 0; width: 250px;
    transform: translateX(-100%); transition: .2s; box-shadow: 20px 0 50px #0002;
  }
  aside.open { transform: none; }
  .overlay { display: block; position: fixed; inset: 0; background: #0005; z-index: 5; opacity: 0; pointer-events: none; transition: .2s; }
  .overlay.visible { opacity: 1; pointer-events: auto; }
  main { padding: 0 18px 45px; }
  header { height: 65px; gap: 8px; }
  .search { padding: 9px 11px; }
  .search input { width: 100%; }
  #status { display: none; }
  .mobile-menu { display: block; }
  /* En el teléfono el botón de nueva nota queda a la vista dentro de la
     pantalla, ancho y debajo del título: nada de esconderlo en el menú ni
     de dejarlo flotando encima de las notas. */
  .welcome { flex-direction: column; align-items: stretch; margin: 24px 0 18px; }
  .welcome h1 { font-size: 27px; }
  .welcome-actions { width: 100%; }
  .welcome-actions button { flex: 1; padding: 14px; font-size: 16px; }
  .notes { grid-template-columns: 1fr 1fr; gap: 11px; }
  .note { padding: 15px; min-height: 190px; }
  .note h2 { font-size: 16px; }
  dialog { padding: 20px; }
  .note-content { min-height: 200px; }
  .row { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  .notes { grid-template-columns: 1fr; }
  .note { min-height: 170px; }
}
