/* ramas.css — Vista de Ramas y Sub-ramas */

/* ─── Layout ──────────────────────────────────────────────────────────────── */

.ramas-layout {
    display: grid;
    grid-template-columns: 35fr 65fr;
    gap: 1.25rem;
    align-items: start;
}

.ramas-panel--sub {
    animation-delay: .08s;
}

/* Altura fija para que cada panel tenga su propio scroll interno */
.ramas-panel {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 172px);
}

/* ─── Lista ───────────────────────────────────────────────────────────────── */

.ramas-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: .35rem;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 2px;
}

/* Scrollbar personalizada */
.ramas-list::-webkit-scrollbar {
    width: 5px;
}
.ramas-list::-webkit-scrollbar-track {
    background: transparent;
}
.ramas-list::-webkit-scrollbar-thumb {
    background: rgba(16, 94, 166, .25);
    border-radius: 999px;
}
.ramas-list::-webkit-scrollbar-thumb:hover {
    background: rgba(16, 94, 166, .45);
}

/* ─── Item ────────────────────────────────────────────────────────────────── */

.ramas-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem .85rem;
    border-radius: 12px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
    animation: hbs-pop-in .28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    animation-delay: calc(var(--i, 0) * 0.05s);
    position: relative;
}

.ramas-item:hover {
    background: rgba(16, 94, 166, .04);
    border-color: rgba(16, 94, 166, .12);
}

.ramas-item.is-active {
    background: rgba(16, 94, 166, .09);
    border-color: rgba(16, 94, 166, .3);
    box-shadow: inset 3px 0 0 var(--hbs-primary);
}

@keyframes ramas-item-out {
    from { opacity: 1; transform: scale(1) translateX(0); }
    to   { opacity: 0; transform: scale(.92) translateX(-12px); }
}

.ramas-item.is-removing {
    animation: ramas-item-out .24s ease forwards;
    pointer-events: none;
}

/* Avatar */
.ramas-item__avatar {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 1rem;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
    transition: transform .18s ease;
    user-select: none;
}

.ramas-item:hover .ramas-item__avatar {
    transform: scale(1.08) rotate(-2deg);
}

.ramas-item.is-active .ramas-item__avatar {
    transform: scale(1.05);
}

/* Body */
.ramas-item__body {
    flex: 1;
    min-width: 0;
}

.ramas-item__name {
    font-size: .92rem;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.35;
    word-break: break-word;
}

.ramas-item__meta {
    font-size: .77rem;
    color: var(--hbs-muted, #64748b);
    margin-top: .1rem;
}

/* Badge de conteo */
.ramas-item__badge {
    display: inline-flex;
    align-items: center;
    padding: .12rem .55rem;
    border-radius: 999px;
    background: rgba(46, 184, 203, .12);
    color: #0c7fa8;
    font-size: .73rem;
    font-weight: 700;
    flex-shrink: 0;
    transition: background .15s;
}

.ramas-item.is-active .ramas-item__badge {
    background: rgba(16, 94, 166, .14);
    color: var(--hbs-primary, #105ea6);
}

/* Botones de acción */
.ramas-item__actions {
    display: flex;
    gap: .3rem;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity .15s ease;
}

.ramas-item:hover .ramas-item__actions,
.ramas-item.is-active .ramas-item__actions {
    opacity: 1;
}

.ramas-item__btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid;
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: .8rem;
    transition: background .15s ease, transform .15s ease;
    background: transparent;
}

.ramas-item__btn:hover {
    transform: scale(1.1);
}

.ramas-item__btn--edit {
    background: rgba(16, 94, 166, .07);
    border-color: rgba(16, 94, 166, .2);
    color: var(--hbs-primary, #105ea6);
}

.ramas-item__btn--edit:hover {
    background: rgba(16, 94, 166, .15);
}

.ramas-item__btn--del {
    background: rgba(239, 68, 68, .07);
    border-color: rgba(239, 68, 68, .2);
    color: var(--hbs-danger, #ef4444);
}

.ramas-item__btn--del:hover {
    background: rgba(239, 68, 68, .15);
}

/* ─── Estado vacío ────────────────────────────────────────────────────────── */

.ramas-empty {
    text-align: center;
    padding: 3.5rem 1.5rem;
    color: var(--hbs-muted, #64748b);
}

.ramas-empty i {
    font-size: 2.5rem;
    opacity: .2;
    display: block;
    margin-bottom: .85rem;
}

.ramas-empty__title {
    font-size: .95rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: .3rem;
}

.ramas-empty p {
    font-size: .85rem;
    margin: 0;
    line-height: 1.5;
}

.ramas-empty--sub p {
    font-style: italic;
}

/* ─── Modal compartido ────────────────────────────────────────────────────── */

.ramas-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: hbs-fade-in .2s ease both;
}

.ramas-modal[hidden] {
    display: none;
}

.ramas-modal__box {
    background: #fff;
    border-radius: 20px;
    padding: 1.75rem;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .25);
    animation: hbs-pop-in .28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    position: relative;
}

.ramas-modal__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    cursor: pointer;
    display: grid;
    place-items: center;
    color: #64748b;
    font-size: .88rem;
    transition: background .15s, transform .2s ease;
}

.ramas-modal__close:hover {
    background: #e2e8f0;
    transform: rotate(90deg);
}

.ramas-modal__title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 1.25rem;
    padding-right: 2.5rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.ramas-modal__title i {
    color: var(--hbs-primary, #105ea6);
    font-size: 1rem;
}

.ramas-modal__field {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    margin-bottom: 1rem;
}

.ramas-modal__label {
    font-size: .83rem;
    font-weight: 600;
    color: #374151;
}

.ramas-modal__label span {
    color: var(--hbs-danger, #ef4444);
}

.ramas-modal__input {
    padding: .62rem .85rem;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    font: inherit;
    font-size: .9rem;
    color: #1e293b;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
    width: 100%;
    box-sizing: border-box;
}

.ramas-modal__input:focus {
    border-color: var(--hbs-primary, #105ea6);
    box-shadow: 0 0 0 4px rgba(16, 94, 166, .1);
}

.ramas-modal__input.is-invalid {
    border-color: var(--hbs-danger, #ef4444);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, .1);
}

.ramas-modal__error {
    font-size: .78rem;
    color: var(--hbs-danger, #ef4444);
    display: flex;
    align-items: center;
    gap: .3rem;
    margin: 0;
}

.ramas-modal__error[hidden] {
    display: none;
}

.ramas-modal__footer {
    margin-top: 1.4rem;
    padding-top: 1rem;
    border-top: 1px solid #f1f5f9;
    display: flex;
    gap: .65rem;
    justify-content: flex-end;
}

/* ─── Diálogo de confirmación ─────────────────────────────────────────────── */

.ramas-confirm {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(15, 23, 42, .6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: hbs-fade-in .18s ease both;
}

.ramas-confirm[hidden] {
    display: none;
}

.ramas-confirm__box {
    background: #fff;
    border-radius: 18px;
    padding: 2rem 1.75rem 1.5rem;
    max-width: 380px;
    width: 100%;
    text-align: center;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .28);
    animation: hbs-pop-in .26s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.ramas-confirm__icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(239, 68, 68, .1);
    color: var(--hbs-danger, #ef4444);
    display: grid;
    place-items: center;
    font-size: 1.35rem;
    margin: 0 auto .9rem;
}

.ramas-confirm__title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 .4rem;
}

.ramas-confirm__body {
    font-size: .88rem;
    color: #64748b;
    margin: 0 0 1.4rem;
    line-height: 1.5;
}

.ramas-confirm__footer {
    display: flex;
    gap: .65rem;
    justify-content: center;
}

.ramas-confirm__ok {
    background: var(--hbs-danger, #ef4444);
    color: #fff;
    border-color: var(--hbs-danger, #ef4444);
}

.ramas-confirm__ok:hover {
    background: #dc2626;
    border-color: #dc2626;
}

/* ─── Toast ───────────────────────────────────────────────────────────────── */

@keyframes ramas-toast-in {
    from { opacity: 0; transform: translateY(12px) scale(.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes ramas-toast-out {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(6px) scale(.97); }
}

.ramas-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .75rem 1.1rem;
    background: #1e293b;
    color: #fff;
    border-radius: 12px;
    font-size: .9rem;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
    animation: ramas-toast-in .3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    max-width: min(340px, calc(100vw - 3rem));
}

.ramas-toast[hidden] {
    display: none;
}

.ramas-toast__icon {
    font-size: 1rem;
    color: var(--hbs-success, #10b981);
    flex-shrink: 0;
}

.ramas-toast--error .ramas-toast__icon {
    color: #f87171;
}

.ramas-toast.is-hiding {
    animation: ramas-toast-out .22s ease forwards;
}

/* ─── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
    .ramas-layout {
        grid-template-columns: 1fr;
    }

    .ramas-panel {
        max-height: 55vh;
    }
}

@media (max-width: 640px) {
    .ramas-item__actions {
        opacity: 1;
    }

    .ramas-modal__box {
        border-radius: 16px;
        padding: 1.35rem;
    }

    .ramas-confirm__box {
        border-radius: 14px;
        padding: 1.5rem 1.25rem 1.25rem;
    }

    .ramas-toast {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: none;
    }
}
