/* ==========================================================================
   Congregación sobre AdminLTE 4 — ajustes mínimos de marca
   Base: Bootstrap 5.3 + AdminLTE (CDN). Aquí solo identidad y utilidades
   propias (buscador global, encabezado de página, avatar de iniciales).
   ========================================================================== */

:root {
    --brand-600: #4f46e5;
    --brand-700: #4338ca;
    --brand-50: #eef2ff;
    --bs-primary: var(--brand-600);
    --bs-primary-rgb: 79, 70, 229;
    --bs-link-color-rgb: 79, 70, 229;
    --bs-body-font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ---------- Menú: opción activa bien visible (claro y oscuro) ---------- */
#navbar-menu .nav-link.active {
    color: var(--brand-600);
    background: var(--brand-50);
    border-radius: 0.375rem;
    font-weight: 600;
}
#navbar-menu .nav-link.active .nav-link-icon {
    color: var(--brand-600);
}
#navbar-menu .dropdown-item.active {
    background: var(--brand-600);
    color: #fff;
    font-weight: 600;
}
[data-bs-theme="dark"] #navbar-menu .nav-link.active {
    color: #fff;
    background: rgba(79, 70, 229, 0.35);
}
[data-bs-theme="dark"] #navbar-menu .nav-link.active .nav-link-icon {
    color: #fff;
}

/* ---------- Utilidades propias ---------- */
.min-w-0 { min-width: 0; }
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---------- Buscador global (navbar) ---------- */
.search-trigger {
    display: inline-flex; align-items: center; gap: 0.6rem;
    background: var(--tblr-tertiary-bg); border: 1px solid var(--tblr-border-color);
    color: var(--tblr-secondary); border-radius: 0.375rem;
    padding: 0.4rem 0.7rem; font-size: 0.85rem; cursor: pointer; min-width: 220px;
}
.search-trigger:hover { border-color: var(--brand-600); color: var(--tblr-body-color); }
.search-trigger kbd, .command-palette kbd {
    font-family: inherit; font-size: 0.7rem; font-weight: 600; margin-left: auto; white-space: nowrap;
    background: var(--tblr-body-bg); border: 1px solid var(--tblr-border-color);
    border-bottom-width: 2px; border-radius: 0.375rem; padding: 0.1rem 0.4rem;
    color: var(--tblr-secondary);
}
.nav-icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 0.375rem;
    background: transparent; border: 1px solid transparent;
    color: var(--tblr-secondary); font-size: 1.15rem; cursor: pointer;
}
.nav-icon-btn:hover { background: var(--tblr-tertiary-bg); color: var(--tblr-body-color); }

/* ---------- Paleta de comandos ---------- */
.command-palette-dialog { max-width: 560px; }
.command-palette-input { display: flex; align-items: center; gap: 0.7rem; padding: 0.9rem 1rem; border-bottom: 1px solid var(--tblr-border-color); }
.command-palette-input i { color: var(--tblr-secondary); font-size: 1.1rem; }
.command-palette-input input { flex: 1; border: none; outline: none; font-size: 1rem; background: transparent; color: var(--tblr-body-color); min-width: 0; }
.command-palette-input kbd { margin-left: 0; }
.command-palette-list { max-height: 340px; overflow-y: auto; padding: 0.5rem; }
.command-group { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--tblr-secondary); padding: 0.6rem 0.75rem 0.25rem; }
.command-item {
    display: flex; align-items: center; gap: 0.75rem; width: 100%;
    background: transparent; border: none; border-radius: 0.375rem; text-align: left;
    padding: 0.6rem 0.75rem; font-size: 0.92rem; color: var(--tblr-body-color); cursor: pointer;
}
.command-item i:first-child { color: var(--brand-600); font-size: 1.05rem; width: 22px; text-align: center; }
.command-item .command-go { margin-left: auto; color: var(--tblr-secondary); opacity: 0; }
.command-item.active { background: var(--tblr-primary-bg-subtle); }
.command-item.active .command-go { opacity: 1; color: var(--brand-600); }
.command-empty { text-align: center; color: var(--tblr-secondary); padding: 2rem 1rem; }
.command-palette-footer { display: flex; gap: 1rem; padding: 0.6rem 1rem; border-top: 1px solid var(--tblr-border-color); background: var(--tblr-tertiary-bg); font-size: 0.75rem; color: var(--tblr-secondary); }
.command-palette-footer span { display: inline-flex; align-items: center; gap: 0.35rem; }
.command-palette-footer kbd { margin-left: 0; }

/* ---------- Encabezado de página (componente x-page-header) ---------- */
.page-header { margin-bottom: 1.25rem; }
.page-header h4 { font-weight: 600; font-size: 1.25rem; margin-bottom: 0.15rem; }
.page-header p { color: var(--tblr-secondary); margin-bottom: 0; }

/* ---------- Avatar de iniciales (navbar, publicadores, grupos) ---------- */
.avatar-initial {
    width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.9rem; color: #fff; background: var(--brand-600);
}

/* ---------- Modal de eventos: encabezado con contraste garantizado ---------- */
.evento-modal-header {
    background-color: var(--brand-700);
    color: #fff;
}
.evento-modal-header .modal-title {
    color: #fff;
}
.evento-modal-header .modal-title i {
    color: #fff;
}

/* ---------- Modal: se usa el fondo nativo de Tabler (opaco en claro/oscuro) ---------- */

/* ---------- Sidebar azul profundo ---------- */
.app-sidebar { background-color: #1e3a5f; }
.app-sidebar .nav-header { color: rgba(255, 255, 255, 0.6); }

/* ---------- Badges con contraste garantizado (modo claro y oscuro) ---------- */
.badge.bg-primary,
.badge.bg-secondary,
.badge.bg-success,
.badge.bg-danger,
.badge.bg-dark { color: #fff; }
.badge.bg-warning,
.badge.bg-info,
.badge.bg-light { color: #212529; }

/* ---------- Badge compacto para listados ---------- */
.badge-sm { font-size: 0.7em; font-weight: 600; padding: 0.25em 0.5em; }

@media (max-width: 767.98px) {
    .search-trigger { min-width: 0; }
    .search-trigger-text, .search-trigger kbd { display: none; }
    .command-palette-footer { display: none; }
}

/* ---------- Notas: botón flotante, modal y tablero Kanban ---------- */
.nota-fab {
    position: fixed; right: 1.5rem; bottom: 1.5rem; z-index: 1035;
    width: 56px; height: 56px; border-radius: 50%; border: none;
    background: var(--brand-600); color: #fff; font-size: 1.5rem;
    display: inline-flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25); cursor: pointer;
}
.nota-fab:hover { background: var(--brand-700); }

.nota-modal-header { background-color: var(--brand-700); color: #fff; }
.nota-modal-header .modal-title,
.nota-modal-header .modal-title i { color: #fff; }

.notas-board {
    display: grid; gap: 1rem; align-items: start;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
@media (max-width: 1199.98px) {
    .notas-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767.98px) {
    .notas-board { grid-template-columns: minmax(0, 1fr); }
}
.notas-col { min-width: 0; }
.notas-col-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.5rem 0.75rem; font-size: 0.9rem;
    background: var(--tblr-tertiary-bg); border: 1px solid var(--tblr-border-color);
    border-radius: 0.375rem 0.375rem 0 0;
}
.notas-list {
    min-height: 100px; padding: 0.6rem; display: flex; flex-direction: column; gap: 0.6rem;
    background: var(--tblr-tertiary-bg); border: 1px solid var(--tblr-border-color);
    border-top: 0; border-radius: 0 0 0.375rem 0.375rem;
}
.nota-card {
    background: var(--tblr-body-bg); border: 1px solid var(--tblr-border-color);
    border-left: 3px solid var(--brand-600);
    border-radius: 0.375rem; padding: 0.6rem 0.7rem; cursor: grab;
}
.nota-card:active { cursor: grabbing; }
.nota-card .nota-titulo { font-size: 0.9rem; }

/* ---------- Calendario mensual (dashboard) ---------- */
.calendar-table { table-layout: fixed; width: 100%; }
.calendar-table th,
.calendar-table td { overflow: hidden; }
.calendar-table td { vertical-align: top; overflow-wrap: anywhere; }

.cal-event {
    display: block; max-width: 100%; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    border-left: 3px solid; border-top: 0; border-right: 0; border-bottom: 0;
    border-radius: 0.25rem; padding: 0.15rem 0.4rem; margin-bottom: 0.2rem;
    font-size: 0.72rem; line-height: 1.25; text-align: left;
}

.calendar-agenda .cal-event { white-space: normal; }

/* Evento: pastel violeta (distinto del gris de estado) */
.cal-event--evento { background-color: #ede9fe; color: #5b21b6; border-color: #8b5cf6; }

/* Nota: pastel ámbar */
.cal-event--nota { background-color: #fef3c7; color: #92400e; border-color: #f59e0b; }

/* ---------- Mapas (Leaflet/OSM) ---------- */
.map-picker { height: 300px; width: 100%; border-radius: 8px; border: 1px solid var(--tblr-border-color); }
.map-picker-lg { height: 380px; width: 100%; border-radius: 8px; border: 1px solid var(--tblr-border-color); }
@media (max-width: 576px) {
    .map-picker { height: 220px; }
    .map-picker-lg { height: 280px; }
}

/* ---------- Tablero de grupos (drag & drop) ---------- */
.board-columns {
    display: grid; gap: 1rem; align-items: start;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 1199.98px) {
    .board-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767.98px) {
    .board-columns { grid-template-columns: minmax(0, 1fr); }
}
.board-column { min-width: 0; transition: opacity 0.2s ease; }
.board-column.sin-coincidencias { opacity: 0.45; }
.board-list {
    min-height: 90px; max-height: 62vh; overflow-y: auto;
    padding: 0.6rem; background: var(--tblr-tertiary-bg);
    display: flex; flex-direction: column; gap: 0.5rem;
    border-top: 1px solid var(--tblr-border-color);
}
.board-card {
    display: flex; align-items: center; gap: 0.6rem;
    background: var(--tblr-body-bg); border: 1px solid var(--tblr-border-color);
    border-radius: 0.375rem; padding: 0.5rem 0.6rem;
    font-size: 0.88rem; font-weight: 500; cursor: grab;
}
.board-card:active { cursor: grabbing; }
.board-card .badge { flex-shrink: 0; }
.board-ghost { opacity: 0.4; background: var(--brand-50); border-style: dashed; }

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

/* Drawer lateral tipo app (solo móvil; en escritorio sigue la navbar superior) */
@media (max-width: 991.98px) {
    #navbar-menu { width: min(84vw, 320px); }
    #navbar-menu .offcanvas-body { display: flex; flex-direction: column; }
    #navbar-menu .navbar-nav { flex-direction: column; width: 100%; }
    #navbar-menu .nav-link { padding: 0.6rem 1rem; border-radius: 0.375rem; }
    #navbar-menu .dropdown-menu {
        position: static; float: none; width: 100%;
        border: 0; box-shadow: none; background: transparent;
        padding: 0 0 0 2rem; margin: 0;
    }
    #navbar-menu .dropdown-item { padding: 0.5rem 1rem; border-radius: 0.375rem; }
}
@media (min-width: 992px) {
    #navbar-menu .offcanvas-body { display: flex; align-items: center; padding: 0; overflow: visible; }
}

/* ---------- Barra inferior tipo app (solo móvil) ---------- */
:root { --app-tabbar-h: 58px; }
.app-tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    display: flex; align-items: stretch; justify-content: space-around;
    background: var(--tblr-body-bg);
    border-top: 1px solid var(--tblr-border-color);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -1px 10px rgba(0, 0, 0, 0.06);
}
.app-tabbar-item {
    flex: 1 1 0; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; padding: 0.45rem 0.15rem 0.35rem;
    border: 0; background: transparent; text-decoration: none;
    color: var(--tblr-secondary); font-size: 0.66rem; font-weight: 600;
    -webkit-tap-highlight-color: transparent;
}
.app-tabbar-item i { font-size: 1.3rem; line-height: 1; }
.app-tabbar-item.active { color: var(--brand-600); }
.app-tabbar-item:active { background: var(--brand-50); }
[data-bs-theme="dark"] .app-tabbar-item.active { color: #a5b4fc; }
[data-bs-theme="dark"] .app-tabbar-item:active { background: rgba(79, 70, 229, 0.25); }

@media (max-width: 991.98px) {
    body { padding-bottom: calc(var(--app-tabbar-h) + env(safe-area-inset-bottom)); }
    .nota-fab { bottom: calc(var(--app-tabbar-h) + env(safe-area-inset-bottom) + 1rem); }
    .footer { margin-bottom: 0; }
}
