/* ============================================
   Dashboard - Modulo Agenda
   ============================================ */

/* Lista: una fila por ítem (horizontal) */
.agenda-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    align-items: stretch;
    overflow: visible;
}

.agenda-list > .text-center {
    width: 100%;
}

.agenda-item {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 0.45rem 0.6rem;
    transition: box-shadow 0.2s, border-color 0.2s;
    min-height: 0;
    min-width: 0;
}

.agenda-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.agenda-item-pinned { border-left: 4px solid #f59e0b; background: #fffdf5; }

/* Fila en grilla: hora arriba; cliente + badges debajo en columna izquierda */
.agenda-item.agenda-item--row {
    display: grid;
    grid-template-columns:
        17.5rem
        5.5rem
        minmax(8rem, 1fr)
        minmax(10rem, auto)
        auto;
    align-items: start;
    column-gap: 0.55rem;
    row-gap: 0.2rem;
    cursor: pointer;
    overflow: visible;
}

.agenda-item-col {
    min-width: 0;
}

.agenda-item-col-leading {
    grid-column: 1;
    min-width: 17.5rem;
    max-width: none;
    overflow: visible;
    display: flex;
    flex-direction: column;
    gap: 0.22rem;
    padding-right: 0.15rem;
}

.agenda-item-leading-sub {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    width: 100%;
    min-width: 0;
    overflow: visible;
}

.agenda-item-col-lawyer {
    grid-column: 2;
}

/* Sin columna suelta de abogado: el nombre va en "Asignado:" */
.agenda-item.agenda-item--row.agenda-item--sin-col-abogado {
    grid-template-columns:
        17.5rem
        minmax(8rem, 1fr)
        minmax(10rem, auto)
        auto;
}

.agenda-item--sin-col-abogado .agenda-item-col-detail {
    grid-column: 2;
}

.agenda-item--sin-col-abogado .agenda-item-col-estado {
    grid-column: 3;
}

.agenda-item--sin-col-abogado .agenda-item-col-actions {
    grid-column: 4;
}

.agenda-item-personas {
    font-size: 0.78rem;
    line-height: 1.35;
    margin-top: 0.15rem;
}

.agenda-item-persona-line {
    display: block;
}

.agenda-item-personas strong {
    font-weight: 600;
    color: #495057;
}

.agenda-item-col-detail {
    grid-column: 3;
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
}

.agenda-item-col-estado {
    grid-column: 4;
    justify-self: end;
}

.agenda-item-col-actions {
    grid-column: 5;
    justify-self: end;
    align-self: center;
}

.agenda-item-time {
    font-variant-numeric: tabular-nums;
    font-size: 0.82rem;
    font-weight: 700;
    color: #212529;
    white-space: nowrap;
    line-height: 1.25;
}

.agenda-item-cliente {
    display: block;
    width: 100%;
    font-size: 0.72rem;
    font-weight: 500;
    color: #0d6efd;
    line-height: 1.3;
    white-space: normal;
    word-break: break-word;
}

.agenda-item-badges-compact {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.3rem;
    width: 100%;
    min-width: 0;
    overflow: visible;
}

.agenda-item-badges-compact .badge {
    font-size: 0.68rem;
    padding: 0.22em 0.5em;
    white-space: normal;
    word-break: break-word;
    flex: 0 1 auto;
    line-height: 1.25;
    max-width: 100%;
    overflow: visible;
    text-overflow: clip;
    display: inline-block;
}

.agenda-item-lawyer {
    display: block;
    font-size: 0.78rem;
    color: #495057;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
}

.agenda-item-title-strong {
    font-size: 0.84rem;
    font-weight: 600;
    color: #212529;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.agenda-item-sub {
    font-size: 0.75rem;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.agenda-item-tags-compact {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem;
    min-width: 0;
}

.agenda-item-tags-compact .badge {
    font-size: 0.62rem;
    padding: 0.15em 0.35em;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1.2;
}

.agenda-item-tags-compact .btn-group {
    flex-shrink: 0;
    white-space: nowrap;
}

.agenda-item-toolbar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.2rem;
}

.agenda-item-toolbar .btn-group-sm > .btn,
.agenda-item-toolbar .btn-sm {
    padding: 0.15rem 0.35rem;
    font-size: 0.72rem;
}

.agenda-item-toolbar .btn-group-sm .dropdown-toggle {
    padding: 0.15rem 0.4rem;
}

/* Legacy (por si queda HTML antiguo en caché) */
.agenda-item-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 0.5rem; gap: 0.35rem; }
.agenda-item-title { font-weight: 600; font-size: 0.95rem; color: #212529; flex: 1; margin-right: 0; min-width: 0; }
.agenda-item-expediente { font-size: 0.85rem; color: #6c757d; font-family: monospace; }
.agenda-item-tags { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; flex-wrap: wrap; }

.badge-fuente-pjn { background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%) !important; color: #fff !important; border: none; }
.badge-fuente-srt { background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%) !important; color: #fff !important; border: none; }
.badge-fuente-mev { background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important; color: #fff !important; border: none; }
.badge-fuente-eje { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important; color: #fff !important; border: none; }
.badge-fuente-manual {
    background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%) !important;
    color: #fff !important;
    border: none;
    font-weight: 600;
    letter-spacing: 0.02em;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.agenda-item-caratula,
.agenda-item-damnificado {
    color: #495057;
    font-size: 0.88rem;
    line-height: 1.4;
    word-break: break-word;
    max-width: 100%;
}
.agenda-item-col-detail .agenda-item-caratula {
    margin-top: 0.35rem;
    font-style: normal;
}
.agenda-item-caratula-label {
    font-weight: 600;
    color: #1e5c38;
    background-color: #d4edda;
    padding: 0.1rem 0.4rem;
    border-radius: 0.25rem;
    margin-right: 0.15rem;
}
.agenda-item-caratula-text {
    font-weight: 700;
    color: #212529;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.agenda-demo-card .agenda-item-caratula {
    margin: 0.35rem 0 0.5rem;
}
.agenda-item-body {
    color: #495057;
    font-size: 0.82rem;
    margin-bottom: 0.5rem;
    line-height: 1.35;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    max-height: 7.5rem;
}

.agenda-item-footer { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; margin-top: auto; }
.agenda-item-meta { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.agenda-item-responsable { display: flex; align-items: center; gap: 0.25rem; }
.agenda-item-vencimiento { display: flex; align-items: center; gap: 0.25rem; color: #dc3545; font-weight: 500; }
.agenda-item-vencimiento.vencido { color: #dc3545; }
.agenda-item-vencimiento.proximo { color: #ffc107; }
.agenda-item-acciones { display: flex; gap: 0.5rem; }
.agenda-item-acciones button {
    background: none; border: none; padding: 0.25rem 0.5rem; cursor: pointer; color: #6c757d; transition: color 0.2s;
}
.agenda-item-acciones button:hover { color: #212529; }

.badge-importante { background-color: #0d6efd; color: white; }
.badge-judicial { background-color: #6f42c1; color: white; }
.badge-pendiente { background-color: #dc3545; color: white; }
.badge-hecho { background-color: #6c757d; color: white; }

@media (max-width: 991.98px) {
    .agenda-list-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .agenda-item.agenda-item--row {
        min-width: 50rem;
    }
}

@media (max-width: 767.98px) {
    .agenda-item.agenda-item--row {
        min-width: 44rem;
        grid-template-columns:
            15rem
            4.5rem
            minmax(7rem, 1fr)
            minmax(9rem, auto)
            auto;
        column-gap: 0.35rem;
    }

    .agenda-item.agenda-item--row.agenda-item--sin-col-abogado {
        min-width: 40rem;
        grid-template-columns:
            15rem
            minmax(7rem, 1fr)
            minmax(9rem, auto)
            auto;
    }

    .agenda-item-col-leading {
        min-width: 15rem;
    }
}

/* --- Ordenar por (estilo menú tipo marketplace) --- */
.agenda-sort-inline-label {
    font-size: 0.9rem;
    font-weight: 400;
    color: #212529;
    white-space: nowrap;
}

.agenda-sort-dropdown {
    position: relative;
}

.agenda-sort-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: transparent;
    border: none;
    padding: 0.2rem 0.3rem;
    font-size: 0.9rem;
    color: #212529;
    cursor: pointer;
    border-radius: 4px;
    line-height: 1.2;
}

.agenda-sort-trigger:hover {
    background: rgba(13, 110, 253, 0.06);
}

.agenda-sort-trigger[aria-expanded="true"] .agenda-sort-chevron {
    transform: rotate(180deg);
}

.agenda-sort-chevron {
    color: #0d6efd;
    font-size: 0.8rem;
    transition: transform 0.2s ease;
}

.agenda-sort-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 240px;
    margin: 0;
    padding: 0.4rem 0;
    list-style: none;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.12);
    border: 1px solid #e8eaed;
    z-index: 1080;
}

.agenda-sort-option {
    padding: 0.55rem 1rem 0.55rem 0.75rem;
    margin: 0;
    cursor: pointer;
    font-size: 0.9rem;
    color: #212529;
    border-bottom: 1px solid #ececec;
    border-left: 4px solid transparent;
    transition: background 0.15s ease;
}

.agenda-sort-option:last-child {
    border-bottom: none;
}

.agenda-sort-option:hover {
    background: #f8f9fa;
}

.agenda-sort-option.is-active {
    color: #0d6efd;
    font-weight: 600;
    border-left-color: #0d6efd;
    background: #fff;
}

/* Vista comercial de agenda en DEMO */
.agenda-demo-card {
    background: #fff;
    border: 1px solid rgba(13, 110, 253, 0.15);
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
    padding: 0.75rem 0.9rem;
    margin-bottom: 0.65rem;
    cursor: pointer;
}

.agenda-demo-card:hover {
    border-color: rgba(13, 110, 253, 0.35);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.10);
}

.agenda-demo-card__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.6rem;
}

.agenda-demo-card__title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1f2a44;
    line-height: 1.35;
}

.agenda-demo-card__badges {
    display: inline-flex;
    gap: 0.3rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.agenda-demo-card__novedad {
    margin-top: 0.35rem;
    font-size: 0.87rem;
    color: #2f3e55;
}

.agenda-demo-card__meta {
    margin-top: 0.45rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: #6c757d;
}

/* --- Paginación bajo la lista --- */
.agenda-list-wrapper {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-width: 0;
}

/* Evitar recorte de fuente / nº expediente / cliente en la columna izquierda */
#tab-agenda .agenda-item-col-leading,
#tab-agenda .agenda-item-leading-sub,
#tab-agenda .agenda-item-badges-compact,
#tab-agenda .agenda-item-badges-compact .badge {
    overflow: visible !important;
    text-overflow: clip !important;
}

#tab-agenda .agenda-item-badges-compact .badge.bg-secondary {
    max-width: 100% !important;
    white-space: normal !important;
    word-break: break-word !important;
}

.agenda-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem 1rem;
    padding: 0.65rem 0.5rem;
    margin-top: 0.25rem;
    border-top: 1px solid #e9ecef;
}

.agenda-pagination-info {
    min-width: 8rem;
    text-align: center;
}
