/* ────────────────────────────────────────────────────────────────────────────
   Rulfo · app.css
   Componentes propios del proyecto que no existen en Bootstrap.

   Filosofía: Bootstrap nativo cuando alcanza. Sólo dejamos acá las clases
   custom que NO se pueden expresar con utilities/componentes de Bootstrap.
   Para colores y radii usamos variables --bs-* (heredadas del bootstrap.css
   custom del proyecto), para que cualquier ajuste de paleta del template
   propage automáticamente.
   ──────────────────────────────────────────────────────────────────────────── */

/* ─── Compensación para navbar fixed-top ─────────────────────────────────── */
body { padding-top: 4rem; }

/* ─── Única utility custom: min-width: 0 (necesaria para text-truncate dentro
   de flex; Bootstrap 5.3 no la trae). ─────────────────────────────────────── */
.min-w-0 { min-width: 0 !important; }

/* ─── Action cards del dashboard inicial ("¿Qué podés hacer?") ───────────── */
.card-action {
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    cursor: pointer;
}
.card-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}
.card-action.disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}
.card-action .icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--bs-primary-bg-subtle);
    color: var(--bs-primary-text-emphasis);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.auth-card { max-width: 460px; margin: 4rem auto; }

/* ─── View cards (grid de /views) ────────────────────────────────────────── */
.view-card {
    border-radius: var(--bs-border-radius-lg);
    overflow: hidden;
    transition: transform .12s, box-shadow .12s;
}
.view-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .1);
}
.view-thumb {
    position: relative;
    height: 128px;
    overflow: hidden;
    background: var(--bs-primary-bg-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
}
.view-thumb img        { width: 100%; height: 100%; object-fit: cover; }
.view-thumb .thumb-icon { color: var(--bs-primary); opacity: .55; font-size: 2rem; }
.view-card .card-body  { padding: .6rem .75rem; }
.view-card .card-footer {
    padding: .35rem .5rem;
    background: transparent;
    border-top: 1px solid rgba(0, 0, 0, .06);
    display: flex;
    gap: .35rem;
    justify-content: flex-end;
}

/* Badge del kind: flotando abajo-izquierda sobre la miniatura. */
.view-thumb-kind {
    position: absolute;
    bottom: .5rem;
    left: .5rem;
    z-index: 2;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
}

/* Botón eliminar: cruz arriba-derecha sobre la miniatura.
   El form es solo wrapper invisible posicionado absolute. */
.view-thumb-delete-form {
    position: absolute;
    top: .5rem;
    right: .5rem;
    z-index: 3;
    margin: 0;
}
.view-thumb-delete {
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .9);
    color: var(--bs-danger);
    font-size: .75rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
    opacity: 0;
    transition: opacity .12s, background .12s, color .12s;
}
/* Aparece al hacer hover sobre la card o cuando recibe focus por teclado. */
.view-card:hover .view-thumb-delete,
.view-thumb-delete:focus {
    opacity: 1;
}
.view-thumb-delete:hover {
    background: #fff;
    color: var(--bs-danger-text-emphasis);
}

/* Card amarilla del bloque "Notas relacionadas" en el index de Views */
.related-notes-card {
    background: var(--bs-warning-bg-subtle);
    border-left: 3px solid var(--bs-warning);
    cursor: pointer;
}
.related-notes-card:hover { background: #fef3c7; }

/* ─── View show: toolbar / textarea / iframe ─────────────────────────────── */
#view-toolbar     { flex-wrap: wrap; gap: .5rem; }
#title-display    { font-size: 1.25rem; font-weight: 600; }
#title-input      { font-size: 1.1rem; font-weight: 600; max-width: 420px; }
#content-textarea { font-family: monospace; font-size: .85rem; min-height: 400px; resize: vertical; }
#isoflow-frame    { width: 100%; height: calc(100vh - 170px); border: none; display: block; background: #fff; }
#save-status      { font-size: .8rem; min-width: 80px; }

/* ─── Markdown body (consolidado) ────────────────────────────────────────── */
.markdown-body img { max-width: 100%; }
.markdown-body pre {
    background: #f6f8fa;
    border-radius: var(--bs-border-radius);
    padding: 1rem;
    overflow-x: auto;
}
.markdown-body code { font-size: .85em; }
/* Markdown rinde los headings desproporcionados respecto al texto: los achicamos
   y suavizamos. Em-based para que escalen con el contenedor (ej: burbujas .92rem). */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    font-weight: 600;
    line-height: 1.25;
    margin: 1em 0 .4em;
}
.markdown-body h1 { font-size: 1.5em; }
.markdown-body h2 { font-size: 1.3em; }
.markdown-body h3 { font-size: 1.15em; }
.markdown-body h4 { font-size: 1.05em; }
.markdown-body h5,
.markdown-body h6 { font-size: 1em; }
.markdown-body > :first-child { margin-top: 0; }

/* ─── Wizard ─────────────────────────────────────────────────────────────── */
#wizard-steps { gap: .25rem; }
.step-pill {
    padding: .3rem .9rem;
    border-radius: var(--bs-border-radius-pill);
    font-size: .8rem;
    font-weight: 600;
    background: var(--bs-secondary-bg-subtle);
    color: var(--bs-secondary-text-emphasis);
    white-space: nowrap;
}
.step-pill.active { background: var(--bs-primary); color: #fff; }
.step-pill.done   { background: var(--bs-success); color: #fff; }

#chat-messages {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

#suggestions-panel {
    background: var(--bs-tertiary-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-lg);
    padding: .875rem 1rem;
}
#suggestions-list { display: flex; flex-wrap: wrap; gap: .5rem; }

.sug-card {
    width: 100%;
    flex-shrink: 0;
    transition: opacity .2s, border-color .2s;
}
.sug-card.discarded   { opacity: .35; pointer-events: none; }
.sug-card.generating  { border-color: var(--bs-primary) !important; }
.sug-card.done        { border-color: var(--bs-success) !important; }
.sug-card .card-body  { padding: .6rem .75rem; }
.sug-card .sug-title  { font-size: .82rem; font-weight: 600; line-height: 1.25; }
.sug-card .sug-desc   {
    font-size: .75rem;
    color: var(--bs-secondary-color);
    line-height: 1.3;
    margin-top: .25rem;
    margin-bottom: 0;
}
.sug-card .sug-actions { margin-top: .5rem; display: flex; gap: .3rem; }

.btn-xxs { padding: .1rem .45rem; font-size: .72rem; line-height: 1.4; }

.draft-card { transition: opacity .2s; }
.draft-card.discarded { opacity: .35; pointer-events: none; }
.draft-card.accepted  { border-color: var(--bs-success) !important; }
.draft-accepted-badge { display: none; }
.draft-card.accepted .draft-accepted-badge { display: inline-flex; }
.draft-card.accepted .draft-action-btns    { display: none; }

.spinner-border-sm { width: 1rem; height: 1rem; }

/* ─── Chat bubbles unificados (wizard / dashboard / AI panel) ────────────── */
#assistant-chat-messages:not(.d-none),
#chat-messages:not(.d-none) {
    display: flex;
    flex-direction: column;
}

.msg-bubble,
.dchat-bubble,
.ai-bubble {
    max-width: 85%;
    padding: .55rem .9rem;
    border-radius: 1rem;
    font-size: .92rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 1.5rem;
}
.msg-bubble.user,
.dchat-bubble.user,
.ai-bubble.user {
    align-self: flex-end;
    background: var(--bs-primary);
    color: #fff;
    border-bottom-right-radius: .25rem;
}
.msg-bubble.assistant,
.dchat-bubble.assistant,
.ai-bubble.assistant {
    align-self: flex-start;
    background: var(--bs-secondary-bg);
    color: var(--bs-body-color);
    border-bottom-left-radius: .25rem;
}
.msg-bubble.assistant .markdown-body,
.dchat-bubble.assistant .markdown-body,
.ai-bubble.assistant .markdown-body { font-size: .92rem; }
.msg-bubble.assistant .markdown-body p:last-child,
.dchat-bubble.assistant .markdown-body p:last-child,
.ai-bubble.assistant .markdown-body p:last-child { margin-bottom: 0; }

/* ─── Notes FAB (botón flotante para crear nota desde cualquier pantalla) ── */
#notes-fab {
    position: fixed; bottom: 1.75rem; right: 1.75rem;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--bs-info);
    color: #fff;
    border: none;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1039;
    transition: background .15s, transform .15s, box-shadow .15s, filter .15s;
}
#notes-fab:hover {
    filter: brightness(1.1);
    transform: scale(1.07);
    box-shadow: 0 6px 22px rgba(var(--bs-primary-rgb), .55);
}

/* ─── AI floating panel ──────────────────────────────────────────────────── */
#ai-fab {
    position: fixed; bottom: 6rem; right: 1.75rem;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--bs-dark);
    color: #fff;
    border: none;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1040;
    transition: background .15s, transform .15s, box-shadow .15s;
}
#ai-fab:hover {
    background: var(--bs-primary);
    filter: brightness(1.1);
    transform: scale(1.07);
    box-shadow: 0 6px 22px rgba(var(--bs-primary-rgb), .55);
}
#ai-fab.open {
    background: var(--bs-primary);
    filter: brightness(.85);
}

#ai-panel {
    position: fixed; top: 0; right: -440px;
    width: 420px; max-width: 100vw; height: 100vh;
    z-index: 1050;
    background: #fff;
    box-shadow: -4px 0 24px rgba(0, 0, 0, .13);
    display: flex;
    flex-direction: column;
    transition: right .28s cubic-bezier(.4, 0, .2, 1);
}
#ai-panel.open { right: 0; }

.ai-panel-header {
    background: var(--bs-primary);
    color: #fff;
    flex-shrink: 0;
}

.ai-bubble.error {
    align-self: flex-start;
    background: var(--bs-danger-bg-subtle);
    color: var(--bs-danger-text-emphasis);
    border-bottom-left-radius: .25rem;
}
.ai-typing {
    align-self: flex-start;
    color: var(--bs-secondary-color);
    font-size: .8rem;
    font-style: italic;
    padding: .25rem .5rem;
}
.ai-warn {
    align-self: flex-start;
    color: var(--bs-warning-text-emphasis);
    font-size: .75rem;
    padding: .2rem .5rem;
}

#ai-mode-tabs {
    display: flex;
    flex-shrink: 0;
    border-bottom: 1px solid var(--bs-border-color);
    background: var(--bs-tertiary-bg);
}
.ai-mode-tab {
    flex: 1;
    padding: .5rem .75rem;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    font-size: .8rem;
    font-weight: 500;
    color: var(--bs-secondary-color);
    cursor: pointer;
    transition: color .15s, border-color .15s, background .15s;
}
.ai-mode-tab:hover {
    color: var(--bs-primary);
    background: rgba(var(--bs-primary-rgb), .04);
}
.ai-mode-tab.active {
    color: var(--bs-primary);
    border-bottom-color: var(--bs-primary);
    font-weight: 600;
}

#ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    background: var(--bs-body-bg);
}

#ai-input-row {
    display: flex;
    gap: .5rem;
    padding: .75rem;
    border-top: 1px solid var(--bs-border-color);
    background: #fff;
}
#ai-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    padding: .45rem .7rem;
    font-size: .92rem;
    line-height: 1.4;
}
#ai-input:focus {
    outline: none;
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb), .15);
}
#ai-send { flex-shrink: 0; align-self: flex-end; }

/* ─── Dashboard chat card ────────────────────────────────────────────────── */
.dashboard-chat-card { border-radius: var(--bs-border-radius-xl); }

#dashboard-chat-messages {
    min-height: 180px;
    max-height: 360px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: .6rem;
}

/* Signal chips (tareas pendientes del dashboard) */
.signal-chip {
    font-size: .72rem;
    padding: .25rem .55rem;
    border-radius: var(--bs-border-radius-pill);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    border: 1px solid transparent;
    transition: transform .08s, box-shadow .08s;
    text-decoration: none;
}
.signal-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
}
.signal-chip.severity-critical {
    background: var(--bs-danger-bg-subtle);
    color: var(--bs-danger-text-emphasis);
    border-color: var(--bs-danger-border-subtle);
}
.signal-chip.severity-warning {
    background: var(--bs-warning-bg-subtle);
    color: var(--bs-warning-text-emphasis);
    border-color: var(--bs-warning-border-subtle);
}
.signal-chip.severity-info {
    background: var(--bs-info-bg-subtle);
    color: var(--bs-info-text-emphasis);
    border-color: var(--bs-info-border-subtle);
}

/* Suggestion chips (debajo del input del dashboard chat) */
.suggestion-chip {
    font-size: .8rem;
    padding: .4rem .8rem;
    border-radius: var(--bs-border-radius-pill);
    cursor: pointer;
    background: #fff;
    border: 1px solid var(--bs-border-color);
    transition: background .1s, border-color .1s;
}
.suggestion-chip:hover {
    background: var(--bs-primary-bg-subtle);
    border-color: var(--bs-primary);
}
.suggestion-chip[data-mode="link"] {
    background: var(--bs-success-bg-subtle);
    border-color: var(--bs-success-border-subtle);
    color: var(--bs-success-text-emphasis);
}
.suggestion-chip[data-mode="link"]:hover { background: #dcfce7; }

/* Action cards (acciones propuestas por el bot que requieren confirm) */
.actions-block {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    align-self: flex-start;
    max-width: 92%;
    margin: -.2rem 0 .4rem 0;
}
.action-card {
    margin-top: .3rem;
    background: var(--bs-warning-bg-subtle);
    border: 1px dashed var(--bs-warning);
    border-radius: .6rem;
    padding: .55rem .8rem;
}
.action-card[data-action-state="done"] {
    background: var(--bs-success-bg-subtle);
    border-color: var(--bs-success);
    border-style: solid;
}
.action-card[data-action-state="error"] {
    background: var(--bs-danger-bg-subtle);
    border-color: var(--bs-danger);
    border-style: solid;
}
.action-card[data-action-state="discarded"] {
    background: var(--bs-secondary-bg-subtle);
    border-color: var(--bs-border-color);
    border-style: solid;
    opacity: .6;
}
.action-card[data-action-state="running"] {
    background: var(--bs-info-bg-subtle);
    border-color: var(--bs-info);
}
.action-card-body {
    display: flex;
    align-items: center;
    gap: .75rem;
}

/* Reset button in the assistant chat header — matches the Bootstrap close button (icon-only, muted, same box). */
.assistant-reset-btn {
    box-sizing: content-box;
    width: 1em;
    height: 1em;
    padding: .25em;
    line-height: 1;
    border: 0;
    background: transparent;
    color: #000;
    opacity: .5;
    border-radius: .375rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.assistant-reset-btn:hover,
.assistant-reset-btn:focus {
    opacity: .75;
}
.assistant-reset-btn i {
    font-size: 1em;
}
/* Keep Reset glued to Close: Bootstrap gives .modal-header .btn-close its own
   margin-left:auto. Combined with the Reset's ms-auto that makes TWO auto margins,
   and flexbox splits the free space 50/50 — leaving Reset floating mid-header.
   Zeroing the close's auto margin makes Reset the only pusher, so both sit
   together at the right edge.
   Only when Reset is actually shown: it starts hidden (.d-none, out of flow), and
   the adjacent-sibling selector matches regardless of display — so without the
   :not(.d-none) guard the close loses its auto margin and jumps next to the title
   with nothing left to push it to the corner. */
.modal-header .assistant-reset-btn:not(.d-none) + .btn-close {
    margin-left: 0;
}

/* ────────────────────────────────────────────────────────────────────────────
   Sprint Gantt — timeline propia (Mermaid no permite varias barras por fila).
   Una fila por miembro; las barras se posicionan en % sobre un track de N días
   (--sg-cols). El track dibuja una grilla diaria de fondo. */
.sprint-gantt {
    --sg-label-w: 150px;
    --sg-row-h: 30px;
    font-size: .8rem;
    overflow-x: auto;
}
.sprint-gantt .sg-row {
    display: flex;
    align-items: stretch;
    min-height: var(--sg-row-h);
}
.sprint-gantt .sg-row + .sg-row {
    border-top: 1px solid #f1f1f1;
}
.sprint-gantt .sg-label {
    flex: 0 0 var(--sg-label-w);
    width: var(--sg-label-w);
    padding: 4px 8px;
    display: flex;
    align-items: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.sprint-gantt .sg-track {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    /* Grilla diaria de fondo: una línea cada 1/cols del ancho. */
    background-image: linear-gradient(to right, #eee 1px, transparent 1px);
    background-size: calc(100% / var(--sg-cols)) 100%;
}
/* Ruler */
.sprint-gantt .sg-ruler {
    display: flex;
    background-image: none;
}
.sprint-gantt .sg-ruler-row {
    border-bottom: 1px solid #dee2e6;
}
.sprint-gantt .sg-cell {
    flex: 1 1 0;
    text-align: center;
    color: #adb5bd;
    font-size: .7rem;
    line-height: var(--sg-row-h);
    border-left: 1px solid #f1f1f1;
}
.sprint-gantt .sg-cell:first-child { border-left: 0; }
.sprint-gantt .sg-cell-today {
    color: #dc3545;
    font-weight: 600;
}
/* Vertical markers */
.sprint-gantt .sg-vline {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    z-index: 1;
}
.sprint-gantt .sg-today { border-left: 2px solid rgba(220, 53, 69, .65); }
.sprint-gantt .sg-end   { border-left: 2px dashed rgba(33, 37, 41, .35); }
/* Bars */
.sprint-gantt .sg-bar {
    position: absolute;
    top: 4px;
    bottom: 4px;
    z-index: 2;
    border-radius: 4px;
    padding: 0 6px;
    display: flex;
    align-items: center;
    color: #fff;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
    cursor: pointer;
    text-decoration: none;
}
.sprint-gantt .sg-bar:hover {
    text-decoration: none;
    opacity: .88;
}
.sprint-gantt .sg-bar > span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: .72rem;
}
.sprint-gantt .sg-bar.bg-warning,
.sprint-gantt .sg-bar.bg-info,
.sprint-gantt .sg-bar.bg-light {
    color: #212529;
}
.sprint-gantt .sg-overdue {
    background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.18) 0 6px, transparent 6px 12px);
}
/* Flashes flotantes: chicos, centrados arriba. El close no debe agrandar el alert. */
.flash-stack { width: auto; max-width: 92vw; }
.flash-stack .alert { min-width: 240px; }
.flash-stack .alert-dismissible .btn-close { padding: .55rem .65rem; background-size: .7em; }

/* Carryover: traída de otro sprint. Barra negra (bg-dark) con borde punteado claro;
   si ya está done, verde oscuro. */
.sprint-gantt .sg-carryover {
    outline: 2px dashed rgba(255, 255, 255, .6);
    outline-offset: -3px;
}
.sprint-gantt .sg-carryover-done {
    background-color: #14532d !important; /* verde oscuro */
}
