/* ==========================================================================
   Tareas · Aloriz — Hoja de estilos
   Diseño moderno inspirado en ClickUp: limpio, con acento morado.
   Organización: 1) Variables  2) Base  3) Login  4) Topbar/Toolbar
                 5) Tablero  6) Tarjetas  7) Lista  8) Modal
                 9) Componentes (botones, chips, avatares, toasts)
   ========================================================================== */

/* 1) VARIABLES ------------------------------------------------------------- */
:root {
  --accent: #7b68ee;          /* morado ClickUp */
  --accent-dark: #6c5ce7;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --ink: #1f2733;
  --muted: #6b7280;
  --line: #e6e8ec;
  --line-soft: #eef0f3;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.06);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.18);
  --radius: 12px;
  --radius-sm: 8px;
  /* prioridades */
  --p-urgent: #ef4444;
  --p-high:   #f59e0b;
  --p-normal: #3b82f6;
  --p-low:    #9ca3af;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* 2) BASE ------------------------------------------------------------------ */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink);
  background: var(--bg); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}
body.is-dragging { cursor: grabbing; -webkit-user-select: none; user-select: none; }
h1, h2, h3 { margin: 0; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 14px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.right { text-align: right; }
.sub { font-size: 13px; color: var(--muted); margin: 0 0 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* 3) LOGIN ----------------------------------------------------------------- */
.login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #efeaff 0%, var(--bg) 55%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; padding: 34px 30px;
  box-shadow: var(--shadow-lg); text-align: center;
}
.login-logo { font-size: 40px; }
.login-title { font-size: 24px; margin-top: 6px; }
.login-sub { color: var(--muted); margin: 4px 0 22px; }
.login-card .fld { text-align: left; }
.login-error {
  background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
  padding: 9px 12px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 13px;
}

/* 4) TOPBAR / TOOLBAR ------------------------------------------------------ */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: 56px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 7px; }
.brand-mark { font-size: 18px; }
.brand-dim { color: var(--muted); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.user-name { font-size: 13px; }

.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 18px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 56px; z-index: 15;
}
.toolbar-spacer { flex: 1 1 auto; }
.toolbar-search {
  height: 36px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0 12px; min-width: 220px; background: var(--bg);
}
.toolbar-search:focus { outline: none; border-color: var(--accent); background: #fff; }
.toolbar-select {
  height: 36px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0 10px; background: var(--surface); color: var(--ink);
}
.toolbar-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }

/* Conmutador de vistas */
.view-switch { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 2px; }
.view-btn { border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; font-weight: 600; color: var(--muted); font-size: 13px; }
.view-btn.is-active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }

/* 5) TABLERO --------------------------------------------------------------- */
.main { flex: 1 1 auto; overflow: auto; padding: 18px; }
.board { display: flex; gap: 14px; align-items: flex-start; min-height: 100%; }
.col {
  flex: 0 0 300px; width: 300px; background: #f1f2f4; border-radius: var(--radius);
  display: flex; flex-direction: column; max-height: calc(100vh - 150px);
}
.col-header { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px; }
.col-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.col-title {
  font-weight: 700; font-size: 14px; outline: none; border-radius: 4px;
  padding: 2px 4px; max-width: 170px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.col-title:focus { background: #fff; box-shadow: 0 0 0 2px var(--accent); white-space: normal; }
.col-count { font-size: 12px; color: var(--muted); background: #e2e4e8; padding: 1px 8px; border-radius: 10px; }
.col-del { margin-left: auto; border: 0; background: transparent; color: #aab1bd; font-size: 18px; line-height: 1; opacity: 0; transition: opacity .15s; }
.col:hover .col-del { opacity: 1; }
.col-del:hover { color: var(--p-urgent); }
.col-list { padding: 4px 8px 8px; overflow-y: auto; flex: 1 1 auto; min-height: 24px; }
.col-addcard {
  margin: 0 8px 10px; border: 0; background: transparent; color: var(--muted);
  text-align: left; padding: 8px 8px; border-radius: var(--radius-sm); font-weight: 600;
}
.col-addcard:hover { background: #e7e9ed; color: var(--ink); }
.col-add { flex: 0 0 240px; }
.col-add-btn { width: 100%; border: 1px dashed #cdd2da; background: transparent; color: var(--muted); padding: 12px; border-radius: var(--radius); font-weight: 600; }
.col-add-btn:hover { border-color: var(--accent); color: var(--accent); }

/* 6) TARJETAS -------------------------------------------------------------- */
.card {
  background: var(--surface); border-radius: var(--radius-sm); padding: 11px 12px;
  box-shadow: var(--shadow); margin-bottom: 9px; cursor: pointer;
  border-left: 3px solid var(--p-normal); transition: box-shadow .15s, transform .05s;
  /* Táctil: sin selección ni menú contextual al mantener presionado (drag) */
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; touch-action: manipulation;
}
.card:hover { box-shadow: 0 4px 12px rgba(16,24,40,.14); }
.card:active { transform: scale(.998); }
.card.is-ghost { display: none; }            /* original oculto mientras se arrastra */
.drag-clone {                                 /* clon flotante que sigue el puntero */
  position: fixed; z-index: 1000; margin: 0; pointer-events: none;
  box-shadow: var(--shadow-lg); opacity: .96;
  transform: rotate(2.5deg) scale(1.03); cursor: grabbing;
}
.card.is-done { opacity: .62; }
.card.is-done .card-title { text-decoration: line-through; color: var(--muted); }
.card.prio-urgent { border-left-color: var(--p-urgent); }
.card.prio-high   { border-left-color: var(--p-high); }
.card.prio-normal { border-left-color: var(--p-normal); }
.card.prio-low    { border-left-color: var(--p-low); }

.card-top { display: flex; align-items: center; gap: 6px; min-height: 18px; margin-bottom: 4px; }
.card-title { font-weight: 600; font-size: 14px; margin: 2px 0; word-break: break-word; }
.card-desc {
  color: var(--muted); font-size: 12.5px; margin: 4px 0 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-labels { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; gap: 8px; }
.card-foot-left { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.card-avatars { display: flex; }
.card-avatars .avatar { margin-left: -6px; border: 2px solid #fff; }
.card-avatars .avatar:first-child { margin-left: 0; }

/* Check de completar */
.card-check {
  width: 19px; height: 19px; border-radius: 50%; border: 2px solid #cdd2da;
  background: #fff; color: #fff; font-size: 11px; line-height: 1; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center; margin-left: auto;
}
.card-check:hover { border-color: var(--accent); }
.card-check.is-checked { background: #22c55e; border-color: #22c55e; }

/* Placeholder de drop */
.drop-ph { height: 54px; border: 2px dashed var(--accent); border-radius: var(--radius-sm); background: #f3f0ff; margin-bottom: 9px; }

.recur { font-size: 12px; }

/* 7) LISTA ----------------------------------------------------------------- */
.list { max-width: 1100px; margin: 0 auto; }
.list-group { margin-bottom: 22px; }
.list-group-head { display: flex; align-items: center; gap: 8px; padding: 6px 4px; margin-bottom: 6px; }
.list-group-title { font-weight: 700; }
.list-table { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list-empty { color: var(--muted); padding: 12px 14px; font-size: 13px; }
.list-row {
  display: grid; grid-template-columns: 24px 1fr 90px 110px 90px; align-items: center;
  gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line-soft); cursor: pointer;
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: #faf9ff; }
.list-row.is-done .list-title { text-decoration: line-through; color: var(--muted); }
.list-row .card-check { margin-left: 0; }
.list-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.list-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-avatars { display: flex; justify-content: flex-end; }
.list-avatars .avatar { margin-left: -6px; border: 2px solid #fff; }

.prio-pill { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; text-align: center; white-space: nowrap; }
.prio-pill--urgent { background: #fee2e2; color: #b91c1c; }
.prio-pill--high   { background: #fef3c7; color: #92400e; }
.prio-pill--normal { background: #dbeafe; color: #1e40af; }
.prio-pill--low    { background: #f1f5f9; color: #475569; }

/* Vencimiento */
.due { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.due--none { color: #c1c7d0; }
.due--soon { color: #b45309; }
.due--today { color: #b45309; background: #fef3c7; padding: 2px 7px; border-radius: 8px; }
.due--late { color: #b91c1c; background: #fee2e2; padding: 2px 7px; border-radius: 8px; }

/* 8) MODAL ----------------------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(16,24,40,.45);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px;
  opacity: 0; transition: opacity .18s; z-index: 50; overflow-y: auto;
}
.modal-overlay.is-open { opacity: 1; }
.modal-panel {
  width: 100%; max-width: 600px; background: var(--surface); border-radius: 16px;
  box-shadow: var(--shadow-lg); transform: translateY(-8px); transition: transform .18s;
}
.modal-overlay.is-open .modal-panel { transform: translateY(0); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-title { font-size: 18px; }
.modal-x { border: 0; background: transparent; font-size: 24px; line-height: 1; color: var(--muted); }
.modal-x:hover { color: var(--ink); }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); }
.modal-foot-meta { font-size: 12px; color: var(--muted); }

/* Campos de formulario */
.fld { display: block; margin-bottom: 14px; }
.fld-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.inp {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 11px; background: var(--surface); color: var(--ink); transition: border-color .12s, box-shadow .12s;
}
.inp:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(123,104,238,.15); }
textarea.inp { resize: vertical; min-height: 70px; }
.inp--inline { width: auto; }
.inp--mini { padding: 5px 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* Selección de responsables */
.assignees { display: flex; flex-wrap: wrap; gap: 8px; }
.assignee {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px 5px 5px;
  border: 1px solid var(--line); border-radius: 20px; background: var(--surface); font-weight: 600; font-size: 13px; color: var(--ink);
}
.assignee.is-on { border-color: var(--accent); background: #f3f0ff; color: var(--accent-dark); }
.recur-row { display: flex; align-items: center; gap: 10px; }
.recur-row input[type=checkbox] { width: 16px; height: 16px; }

/* Gestión de usuarios */
.user-list { display: flex; flex-direction: column; gap: 8px; }
.user-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.user-row.is-inactive { opacity: .55; }
.user-info { flex: 1 1 auto; min-width: 0; }
.user-row-name { font-weight: 600; }
.user-row-email { font-size: 12.5px; color: var(--muted); }
.user-actions { display: flex; align-items: center; gap: 6px; }
.user-add { }

/* 9) COMPONENTES ----------------------------------------------------------- */
.btn {
  border: 1px solid transparent; border-radius: var(--radius-sm); padding: 9px 15px;
  font-weight: 600; font-size: 13.5px; background: var(--surface); color: var(--ink);
  display: inline-flex; align-items: center; gap: 6px; transition: background .12s, box-shadow .12s, opacity .12s;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn--primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(123,104,238,.4); }
.btn--primary:hover { background: var(--accent-dark); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn--ghost:hover { background: var(--bg); color: var(--ink); }
.btn--block { width: 100%; justify-content: center; margin-top: 6px; padding: 11px; }
.btn--danger-ghost { background: transparent; color: var(--p-urgent); border-color: transparent; }
.btn--danger-ghost:hover { background: #fef2f2; }
.btn--mini { padding: 5px 9px; font-size: 12px; border-color: var(--line); background: var(--surface); color: var(--muted); }
.btn--mini.is-off { color: var(--p-urgent); }

.chip { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; line-height: 1.6; }
.chip--client { background: #ede9fe; color: var(--accent-dark); }
.chip--label { background: #eef0f3; color: #475569; }

.avatar {
  display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
  color: #fff; font-weight: 700; flex: 0 0 auto; line-height: 1; user-select: none;
}

/* Botón flotante "nueva tarea" (FAB) — se muestra sólo en móvil */
.fab {
  display: none; position: fixed; z-index: 40;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(18px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: #fff; border: 0;
  font-size: 30px; font-weight: 300; line-height: 1;
  align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(123,104,238,.5);
}
.fab:active { transform: scale(.93); background: var(--accent-dark); }

/* Toasts */
.toasts {
  position: fixed; right: 20px; z-index: 80;
  bottom: calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 500;
  transform: translateX(120%); opacity: 0; transition: transform .25s, opacity .25s; max-width: 320px;
}
.toast--in { transform: translateX(0); opacity: 1; }
.toast--success { background: #16a34a; }
.toast--error { background: #dc2626; }
.toast--info { background: #334155; }

/* ==========================================================================
   RESPONSIVE / MÓVIL (iPhone-first)
   ========================================================================== */
@media (max-width: 900px) {
  .main { padding: 14px; }
}

@media (max-width: 768px) {
  /* La app ocupa el alto real del visor (sin saltos por la barra del navegador) */
  .app { height: 100vh; height: 100dvh; }

  /* Login a ancho completo */
  .login { padding: 16px; }
  .login-card { max-width: 100%; padding: 30px 22px; }

  /* Inputs >=16px: evita el zoom automático de iOS al enfocar */
  .inp, .toolbar-search, .toolbar-select { font-size: 16px; }

  /* --- Topbar compacta + safe area --- */
  .topbar {
    height: 52px;
    padding-left: calc(12px + env(safe-area-inset-left));
    padding-right: calc(12px + env(safe-area-inset-right));
  }
  .brand { font-size: 15px; }
  .brand-dim, .user-name { display: none; }     /* sólo lo esencial */
  .topbar-right { gap: 6px; }
  .topbar-right .btn { padding: 8px 11px; }

  /* --- Toolbar: una fila deslizable horizontal --- */
  .toolbar {
    top: 52px; gap: 8px; padding: 9px 12px;
    flex-wrap: nowrap; overflow-x: auto;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .toolbar::-webkit-scrollbar { display: none; }
  .toolbar > * { flex: 0 0 auto; }
  .toolbar-spacer { display: none; }
  .toolbar-search { min-width: 150px; }
  .toolbar-check { white-space: nowrap; }
  .toolbar-newbtn { display: none; }            /* reemplazado por el FAB */
  .fab { display: inline-flex; }

  /* --- Tablero: columnas tipo "swipe" con snap --- */
  .main {
    padding: 0; overflow-x: auto; overflow-y: hidden;
    scroll-snap-type: x mandatory; scroll-padding-left: 12px;
  }
  .board { gap: 12px; padding: 12px; height: 100%; }
  .col {
    flex: 0 0 86vw; width: 86vw; max-width: 380px;
    max-height: 100%; scroll-snap-align: center;
  }
  .col-list { padding-bottom: 90px; }           /* el último card no queda bajo el FAB */
  .col-add { flex: 0 0 60vw; }
  .col-del { opacity: 1; }                       /* no hay hover en táctil */

  /* Toques cómodos */
  .card { padding: 13px 14px; }
  .card-check { width: 22px; height: 22px; }

  /* --- Modales como hoja inferior (bottom-sheet) --- */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-panel {
    max-width: 100%; width: 100%;
    border-radius: 18px 18px 0 0; max-height: 92dvh;
    display: flex; flex-direction: column;
    transform: translateY(100%);
  }
  .modal-overlay.is-open .modal-panel { transform: translateY(0); }
  .modal-head { position: sticky; top: 0; background: var(--surface); z-index: 1; border-radius: 18px 18px 0 0; }
  .modal-body { overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1 1 auto; }
  .modal-foot {
    position: sticky; bottom: 0; background: var(--surface); flex-wrap: wrap;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
  .modal-foot-meta { width: 100%; order: 3; }

  /* Lista en móvil */
  .grid-2 { grid-template-columns: 1fr; }
  .list { padding: 12px; }
  .list-row { grid-template-columns: 24px 1fr auto; gap: 10px; }
  .list-row .prio-pill { display: none; }
  .assignees { gap: 6px; }
}

/* Móvil en horizontal: caben más columnas a la vista */
@media (max-width: 820px) and (orientation: landscape) {
  .col { flex-basis: 54vw; width: 54vw; }
}

/* Pantallas muy chicas (iPhone SE / mini) */
@media (max-width: 380px) {
  .col { flex-basis: 90vw; width: 90vw; }
}
