/* ===== Agenda ===== */
:root {
    --navy: #14213d;
    --navy-2: #1d2d50;
    --ink: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;
    --bg: #f4f6fa;
    --accent: #f59e0b;
    --radius: 14px;
}

* { font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; }
body { background: var(--bg); color: var(--ink); }
.min-w-0 { min-width: 0; }

/* ---- Estructura ---- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px; flex-shrink: 0;
    background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
    color: #fff; padding: 20px 16px;
    display: flex; flex-direction: column;
}
@media (min-width: 992px) {
    .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
}
@media (max-width: 991.98px) {
    .sidebar.offcanvas-lg { background: var(--navy); }
}

.sidebar-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand-mark {
    width: 42px; height: 42px; border-radius: 12px;
    background: var(--accent); color: var(--navy);
    display: grid; place-items: center; font-size: 1.3rem;
}
.brand-name { font-weight: 700; font-size: 1.15rem; line-height: 1; }
.brand-sub { font-size: .75rem; color: rgba(255,255,255,.55); letter-spacing: .08em; text-transform: uppercase; }

.btn-new { background: var(--accent); color: var(--navy); font-weight: 600; border: 0; border-radius: 10px; padding: 10px; }
.btn-new:hover { background: #fbbf24; color: var(--navy); }

.side-nav .nav-link {
    color: rgba(255,255,255,.75); border-radius: 10px; padding: 9px 12px;
    display: flex; align-items: center; gap: 10px; font-size: .93rem;
}
.side-nav .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.side-nav .nav-link.active { background: rgba(255,255,255,.13); color: #fff; font-weight: 600; }
.side-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: rgba(255,255,255,.4); margin: 18px 12px 6px; }

.side-cats { display: flex; flex-direction: column; gap: 2px; }
.side-cat { color: rgba(255,255,255,.75); text-decoration: none; padding: 5px 12px; border-radius: 8px; font-size: .88rem; display: flex; align-items: center; gap: 9px; }
.side-cat:hover { background: rgba(255,255,255,.07); color: #fff; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; flex-shrink: 0; box-shadow: 0 0 0 2px rgba(255,255,255,.15); }

.sidebar-user { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.15);
    display: grid; place-items: center; font-weight: 600; font-size: .85rem; flex-shrink: 0;
}
.avatar.sm { width: 28px; height: 28px; font-size: .7rem; background: #e0e7ff; color: #3730a3; }
.u-name { color: #fff; text-decoration: none; font-weight: 600; font-size: .9rem; }
.u-role { font-size: .75rem; color: rgba(255,255,255,.55); }

.content { flex-grow: 1; min-width: 0; }
.topbar { display: flex; align-items: center; padding: 22px 28px 8px; }
.page-title { font-size: 1.5rem; font-weight: 700; margin: 0; }
.page-sub { color: var(--muted); font-size: .9rem; }
.content-body { padding: 12px 28px 40px; }
@media (max-width: 575.98px) {
    .topbar { padding: 16px 16px 6px; flex-wrap: wrap; gap: 8px; }
    .content-body { padding: 10px 16px 30px; }
}

/* ---- Tarjetas ---- */
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.panel-head h2 { font-size: 1rem; font-weight: 700; margin: 0; }
.panel-body { padding: 14px 18px; }

.stat {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 14px 16px; display: flex; align-items: center; gap: 12px;
    text-decoration: none; color: var(--ink); transition: transform .12s, box-shadow .12s;
}
.stat:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(20,33,61,.08); color: var(--ink); }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.25rem; }
.stat-num { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .8rem; color: var(--muted); }

/* ---- Tarea ---- */
.task {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 14px; border: 1px solid var(--line); border-left: 5px solid var(--cat, #6c757d);
    border-radius: 12px; background: #fff; margin-bottom: 10px;
    transition: box-shadow .12s;
}
.task:hover { box-shadow: 0 4px 14px rgba(20,33,61,.07); }
.task.is-done { opacity: .65; }
.task.is-done .task-title { text-decoration: line-through; }
.task.is-overdue { background: #fff7f7; }
.task-title { font-weight: 600; color: var(--ink); text-decoration: none; }
.task-title:hover { color: #0d6efd; }
.task-meta { font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; }
.task-check {
    width: 26px; height: 26px; border-radius: 50%; border: 2px solid #cbd5e1; background: #fff;
    display: grid; place-items: center; flex-shrink: 0; color: transparent; padding: 0; margin-top: 1px;
}
.task-check:hover { border-color: #198754; color: #198754; }
.task-check.done { background: #198754; border-color: #198754; color: #fff; }

.cat-chip {
    display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; font-weight: 600;
    padding: 2px 9px; border-radius: 999px; white-space: nowrap;
}

.section-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .95rem; margin: 0 0 10px; }
.section-title .count { background: #eef2f7; color: var(--muted); font-size: .75rem; padding: 1px 8px; border-radius: 999px; }
.empty { color: var(--muted); font-size: .88rem; padding: 14px; text-align: center; border: 1px dashed var(--line); border-radius: 12px; }

/* ---- Notas ---- */
.note { border-left: 3px solid #c7d2fe; padding: 6px 0 6px 12px; margin-bottom: 14px; }
.note-head { font-size: .8rem; color: var(--muted); }
.note-body { white-space: pre-line; }

/* ---- Login ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--navy), #2b4380); padding: 20px; }
.login-card { width: 100%; max-width: 410px; background: #fff; border-radius: 18px; padding: 34px 30px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }

/* ---- Calendario ---- */
.fc { --fc-border-color: var(--line); --fc-today-bg-color: #fff8e6; font-size: .88rem; }
.fc .fc-toolbar-title { font-size: 1.2rem; font-weight: 700; text-transform: capitalize; }
.fc .fc-button-primary { background: var(--navy); border-color: var(--navy); }
.fc .fc-button-primary:not(:disabled).fc-button-active, .fc .fc-button-primary:hover { background: var(--navy-2); border-color: var(--navy-2); }
.fc-event { cursor: pointer; border-radius: 6px; padding: 1px 3px; }
.fc-event.ev-done { opacity: .5; text-decoration: line-through; }
.fc-event.ev-overdue { box-shadow: inset 0 0 0 2px #b02a37; }

.form-control, .form-select { border-radius: 10px; }
.btn { border-radius: 10px; }
.table > :not(caption) > * > * { vertical-align: middle; }

/* =====================================================================
   VERSIÓN CELULAR
   ===================================================================== */
.brand-mark.sm { width: 28px; height: 28px; border-radius: 8px; font-size: .9rem; }
.m-header, .bottom-nav { display: none; }

@media (max-width: 991.98px) {
    body { background: var(--bg); -webkit-tap-highlight-color: transparent; }

    /* Barra superior fija */
    .m-header {
        display: flex; align-items: center; gap: 10px;
        position: sticky; top: 0; z-index: 1030;
        background: var(--navy); color: #fff;
        padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
    }
    .m-icon-btn { background: transparent; border: 0; color: #fff; font-size: 1.6rem; line-height: 1; padding: 4px 6px; }
    .m-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; }
    .m-avatar { margin-left: auto; width: 34px; height: 34px; color: #fff; text-decoration: none; font-size: .78rem; }

    /* Título de la página más compacto */
    .topbar { padding: 14px 14px 4px; flex-wrap: wrap; gap: 8px; }
    .page-title { font-size: 1.25rem; }
    .page-sub { font-size: .8rem; }
    .content-body { padding: 8px 12px calc(96px + env(safe-area-inset-bottom)); }

    /* Navegación inferior tipo app */
    .bottom-nav {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
        background: #fff; border-top: 1px solid var(--line);
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
        box-shadow: 0 -4px 18px rgba(20,33,61,.06);
    }
    .bottom-nav a {
        flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
        color: var(--muted); text-decoration: none; font-size: .68rem; font-weight: 500; padding: 4px 0;
    }
    .bottom-nav a i { font-size: 1.3rem; line-height: 1; }
    .bottom-nav a.active { color: var(--navy); font-weight: 700; }
    .bottom-nav a.active i { color: var(--accent); }
    .bottom-nav .bn-add {
        flex: 0 0 auto; width: 58px; height: 58px; margin-top: -26px; border-radius: 50%;
        background: var(--accent); color: var(--navy); justify-content: center;
        box-shadow: 0 6px 16px rgba(245,158,11,.45); border: 4px solid var(--bg);
    }
    .bottom-nav .bn-add i { font-size: 1.6rem; color: var(--navy); }

    /* Menú lateral como cajón */
    .sidebar.offcanvas-lg { width: 82vw; max-width: 300px; padding-top: calc(env(safe-area-inset-top) + 18px); }

    /* Indicadores en carrusel horizontal */
    .stats-row { flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x mandatory; margin-right: -12px; padding-right: 12px; scrollbar-width: none; }
    .stats-row::-webkit-scrollbar { display: none; }
    .stats-row > [class*="col"] { flex: 0 0 auto; width: 42%; scroll-snap-align: start; }
    .stat { padding: 12px; }
    .stat-num { font-size: 1.35rem; }
    .stat-icon { width: 38px; height: 38px; font-size: 1.1rem; }

    /* Tarjetas de tarea más fáciles de tocar */
    .task { padding: 12px; gap: 12px; }
    .task-check { width: 32px; height: 32px; }
    .task-title { font-size: .98rem; }
    .panel-body { padding: 12px; }
    .panel { border-radius: 16px; }

    /* Botones y campos al tamaño del dedo */
    .form-control, .form-select { font-size: 16px; min-height: 44px; } /* 16px evita el zoom en iPhone */
    .form-select-sm, .form-control-sm { min-height: 38px; font-size: 15px; }
    .btn { min-height: 40px; }
    .btn-sm { min-height: 34px; }

    /* Filtros desplazables */
    .filters-scroll { flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; }
    .filters-scroll::-webkit-scrollbar { display: none; }
    .filters-scroll > * { flex-shrink: 0; }
    .filters-scroll .w-auto { max-width: 70vw; }

    /* Botones de guardar fijos abajo en formularios */
    .form-actions {
        position: sticky; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 5;
        background: #fff; border-radius: 0 0 16px 16px; box-shadow: 0 -6px 14px rgba(20,33,61,.06);
    }
    .form-actions .btn { flex: 1; }

    /* Modal "completar" como hoja inferior */
    .modal-dialog.m-sheet { margin: 0; position: fixed; bottom: 0; left: 0; right: 0; max-width: none; min-height: auto; }
    .modal.fade .modal-dialog.m-sheet { transform: translateY(100%); }
    .modal.show .modal-dialog.m-sheet { transform: none; }
    .m-sheet .modal-content { border-radius: 20px 20px 0 0; border: 0; padding-bottom: env(safe-area-inset-bottom); }

    /* Calendario */
    .fc .fc-toolbar { flex-direction: column; gap: 8px; }
    .fc .fc-toolbar-title { font-size: 1.05rem; }
    .fc .fc-button { padding: .3rem .6rem; font-size: .85rem; }
    .fc .fc-list-event-title a { font-weight: 600; }

    /* Tablas de admin: se pueden deslizar */
    .table { font-size: .88rem; }
}

/* Cuando está instalada como app (pantalla completa) */
@media (display-mode: standalone) {
    .login-wrap { padding-top: calc(env(safe-area-inset-top) + 20px); }
}

/* =====================================================================
   EDITAR / ELIMINAR / HISTORIAL
   ===================================================================== */
.task-menu { flex-shrink: 0; margin: -4px -6px 0 0; }
.task-menu-btn { background: transparent; border: 0; color: var(--muted); width: 32px; height: 32px; padding: 0; min-height: 0 !important; }
.task-menu-btn:hover, .task-menu-btn[aria-expanded="true"] { background: #eef2f7; color: var(--ink); }
.task-menu .dropdown-item { padding: 8px 14px; font-size: .9rem; }

.edited-badge { background: #eef2f7; color: var(--muted); font-weight: 500; }
.edited-badge.is-recent { background: #dbeafe; color: #1d4ed8; }

.activity { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.activity:last-child { border-bottom: 0; }
.activity.is-new { background: #f0f7ff; margin: 0 -12px; padding: 10px 12px; border-radius: 10px; animation: flash-new 2.5s ease-out; }
@keyframes flash-new { from { background: #bfdbfe; } to { background: #f0f7ff; } }
.activity-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; font-size: .85rem; }
.change-list { list-style: none; padding: 0; margin: 6px 0 0; font-size: .85rem; }
.change-list li { padding: 3px 0; overflow-wrap: anywhere; }
.change-field { font-weight: 600; margin-right: 4px; }
.change-old { color: #b91c1c; text-decoration: line-through; background: #fef2f2; padding: 0 4px; border-radius: 4px; }
.change-new { color: #15803d; background: #f0fdf4; padding: 0 4px; border-radius: 4px; font-weight: 500; }

@media (max-width: 991.98px) {
    .task-menu-btn { width: 36px; height: 36px; font-size: 1.1rem; }
    .task-menu .dropdown-item { padding: 12px 16px; }
}

/* =====================================================================
   AVISOS / NOTIFICACIONES
   ===================================================================== */
.bell-btn {
    position: relative; background: #fff; border: 1px solid var(--line); color: var(--ink);
    width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 1.15rem;
}
.bell-btn:hover { background: #f8fafc; }
.m-bell .bell-btn { background: transparent; border: 0; color: #fff; font-size: 1.35rem; }
.bell-count {
    position: absolute; top: -5px; right: -5px; min-width: 19px; height: 19px; padding: 0 5px;
    border-radius: 999px; background: #dc2626; color: #fff; font-size: .68rem; font-weight: 700;
    display: grid; place-items: center; border: 2px solid #fff;
}
.m-bell .bell-count { border-color: var(--navy); top: -2px; right: -4px; }
.bell-menu { width: 360px; max-width: calc(100vw - 24px); padding: 0; border-radius: 14px; overflow: hidden; }
.bell-head { display: flex; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.bell-list { max-height: 60vh; overflow-y: auto; }
.bell-item { display: flex; gap: 10px; padding: 11px 14px; text-decoration: none; color: var(--ink); border-bottom: 1px solid #f1f5f9; }
.bell-item:hover { background: #f8fafc; color: var(--ink); }
.bell-item.unread { background: #f0f7ff; }
.bell-item.unread .bell-title::after { content: ''; display: inline-block; width: 7px; height: 7px; background: #2563eb; border-radius: 50%; margin-left: 6px; vertical-align: middle; }
.bell-ico { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.bell-title { display: block; font-weight: 600; font-size: .88rem; }
.bell-body { display: block; font-size: .82rem; color: #475569; overflow-wrap: anywhere; }
.bell-time { display: block; font-size: .72rem; color: var(--muted); margin-top: 2px; }
.bell-empty { padding: 26px; text-align: center; color: var(--muted); font-size: .9rem; }
.bell-foot { display: block; text-align: center; padding: 10px; font-size: .85rem; font-weight: 600; text-decoration: none; background: #f8fafc; }

.push-banner {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 16px;
    background: linear-gradient(90deg, #fff7e6, #fff); border: 1px solid #fde68a; border-radius: 14px;
}
.push-banner.d-none { display: none !important; }
.push-banner-ico { font-size: 1.5rem; color: var(--accent); }
.push-state { font-size: .9rem; font-weight: 600; padding: 8px 12px; border-radius: 10px; background: #f1f5f9; }
.push-state[data-state="activo"] { background: #dcfce7; color: #166534; }
.push-state[data-state="bloqueado"] { background: #fee2e2; color: #991b1b; }

@media (max-width: 991.98px) {
    .push-banner { flex-wrap: wrap; }
    .push-banner .btn-warning { flex: 1; }
    .bell-menu { position: fixed !important; inset: auto 12px auto 12px !important; top: 60px !important; transform: none !important; width: auto; }
    .toast-container { top: auto !important; bottom: calc(80px + env(safe-area-inset-bottom)); left: 0; right: 0; }
}
