/* ============================================
   Dashboard - Header + Notificaciones + WhatsApp
   ============================================ */

.dashboard-header {
    background: #1e3a5f;
    color: white;
    padding: 0.75rem 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.header-content { display: flex; justify-content: space-between; align-items: center; }
.logo-section { display: flex; align-items: center; gap: 0.75rem; }
.logo { font-size: 1.4rem; font-weight: 700; margin: 0; }
.subtitle { font-size: 0.8rem; opacity: 0.9; }
.header-actions { display: flex; align-items: center; gap: 1rem; }
.user-info { font-size: 0.9rem; }

/* Modo claro / oscuro (navbar, entre campanita y usuario) */
.theme-toggle-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.92);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}
.theme-toggle-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    transform: scale(1.08);
}
.theme-toggle-btn .bi {
    font-size: 1.2rem;
}

.notifications-container { position: relative; }
.notification-bell {
    background: transparent; border: none; color: white; font-size: 1.3rem; cursor: pointer;
    padding: 0.5rem; position: relative; transition: transform 0.2s ease;
    display: flex; align-items: center; justify-content: center;
}
.notification-bell:hover { transform: scale(1.1); }

.notification-badge {
    position: absolute; top: 0; right: 0; background: #dc3545; color: white; border-radius: 50%;
    width: 20px; height: 20px; font-size: 0.7rem; font-weight: bold;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #1e3a5f; animation: pulse 2s infinite;
}

@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.1)} }

.whatsapp-alerts-container { position: relative; margin-right: 0.25rem; flex-shrink: 0; }
.whatsapp-alerts-btn {
    background: transparent; border: none; color: #25D366; cursor: pointer; padding: 0.5rem;
    position: relative; display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s ease, color 0.2s ease; width: 40px; height: 40px;
}
.whatsapp-alerts-btn:hover { color: #34e077; transform: scale(1.1); }
.whatsapp-alerts-btn .bi-whatsapp { font-size: 1.35rem; }
.whatsapp-alerts-badge {
    position: absolute; top: 0; right: 0; background: #dc3545; color: white; border-radius: 50%;
    min-width: 18px; height: 18px; font-size: 0.7rem; font-weight: bold;
    display: flex; align-items: center; justify-content: center; border: 2px solid #1e3a5f; padding: 0 4px;
}

.whatsapp-alerts-dropdown,
.notifications-dropdown {
    position: absolute; top: calc(100% + 10px); right: 0; background: white; border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15); display: none; flex-direction: column; z-index: 1000; overflow: hidden;
}
.whatsapp-alerts-dropdown { width: 320px; max-height: 400px; }
.notifications-dropdown { width: 400px; max-height: 500px; }
.whatsapp-alerts-dropdown.show, .notifications-dropdown.show { display: flex; }

.whatsapp-alerts-header {
    padding: 0.75rem 1rem; border-bottom: 1px solid #e0e0e0; display: flex; flex-direction: column; gap: 0.5rem;
    background: #f0f9f4; flex-shrink: 0;
}
.whatsapp-alerts-header h6 { margin: 0; font-size: 0.95rem; font-weight: 600; color: #128C7E; }
.whatsapp-alerts-header-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.whatsapp-alerts-header-actions .btn { font-size: 0.75rem; padding: 0.25rem 0.5rem; }
.whatsapp-alerts-list { overflow-y: auto; max-height: 320px; padding: 0.5rem 0; }
.whatsapp-alerts-empty { padding: 1rem; text-align: center; color: #6c757d; font-size: 0.9rem; }
.whatsapp-alerts-item { padding: 0.6rem 1rem; border-bottom: 1px solid #f0f0f0; cursor: pointer; transition: background 0.15s ease; }
.whatsapp-alerts-item:hover { background: #f0f9f4; }
.whatsapp-alerts-item:last-child { border-bottom: none; }
.whatsapp-alerts-fecha { display: block; font-size: 0.75rem; color: #6c757d; margin-top: 0.15rem; }
.whatsapp-alerts-obs { font-size: 0.8rem; color: #495057; margin-top: 0.25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.notifications-header {
    padding: 1rem; border-bottom: 1px solid #e0e0e0; display: flex; flex-direction: column; gap: 0.75rem; background: #f8f9fa;
}
.notifications-header h6 { margin: 0; font-size: 1rem; font-weight: 600; color: #1e3a5f; }
.notifications-header-actions { display: flex; flex-wrap: nowrap; gap: 0.5rem; align-items: center; }
.notifications-header-actions .btn-mark-all-read,
.notifications-header-actions .btn-empty-notifications { flex: 1 1 0; min-width: 0; white-space: normal; text-align: center; }
.btn-mark-all-read { background: #007bff; color: white; border: none; padding: 0.4rem 0.8rem; border-radius: 4px; font-size: 0.85rem; cursor: pointer; transition: background 0.2s ease; }
.btn-mark-all-read:hover:not(:disabled) { background: #0056b3; }
.btn-mark-all-read:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-empty-notifications { background: transparent; color: #c82333; border: 1px solid #f5c6cb; padding: 0.4rem 0.8rem; border-radius: 4px; font-size: 0.85rem; cursor: pointer; transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease; }
.btn-empty-notifications:hover:not(:disabled) { background: #fff5f5; color: #a71d2a; border-color: #f1aeb5; }
.btn-empty-notifications:disabled { opacity: 0.45; cursor: not-allowed; color: #6c757d; border-color: #dee2e6; }
.notifications-list { max-height: 400px; overflow-y: auto; padding: 0.5rem 0; }
.notification-item { padding: 1rem; border-bottom: 1px solid #f0f0f0; cursor: pointer; transition: background 0.2s ease; display: flex; flex-direction: column; gap: 0.5rem; }
.notification-item:hover { background: #f8f9fa; }
.notification-item:last-child { border-bottom: none; }
.notification-item--read { opacity: 0.85; }
.notification-item-header { display: flex; justify-content: space-between; align-items: start; gap: 0.5rem; }
.notification-expediente { font-weight: 600; color: #1e3a5f; font-size: 0.95rem; }
.notification-fuente { background: #e3f2fd; color: #1976d2; padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.notification-tipo { color: #495057; font-size: 0.9rem; font-weight: 500; }
.notification-fecha { color: #6c757d; font-size: 0.8rem; }
.notification-observaciones { color: #6c757d; font-size: 0.85rem; margin-top: 0.25rem; line-height: 1.4; max-height: 60px; overflow: hidden; text-overflow: ellipsis; }
.notification-empty { padding: 2rem; text-align: center; color: #6c757d; font-size: 0.9rem; }
.notifications-list::-webkit-scrollbar { width: 6px; }
.notifications-list::-webkit-scrollbar-track { background: #f1f1f1; }
.notifications-list::-webkit-scrollbar-thumb { background: #888; border-radius: 3px; }
.notifications-list::-webkit-scrollbar-thumb:hover { background: #555; }

/* Móvil: panel anclado al viewport para que no quede cortado a un costado */
@media (max-width: 767.98px) {
    .dashboard-header {
        overflow: visible;
    }
    .dashboard-header .header-content {
        flex-wrap: wrap;
        row-gap: 0.5rem;
    }
    .dashboard-header .header-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
        align-items: center;
        gap: 0.35rem 0.5rem;
        max-width: 100%;
        width: 100%;
        overflow: visible;
    }
    .dashboard-header .user-info {
        max-width: min(200px, 42vw);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.8rem;
    }
    .dashboard-header #btn-logout {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    .notifications-dropdown,
    .whatsapp-alerts-dropdown {
        position: fixed;
        left: max(8px, env(safe-area-inset-left, 0px));
        right: max(8px, env(safe-area-inset-right, 0px));
        top: calc(60px + env(safe-area-inset-top, 0px));
        width: auto !important;
        max-width: none;
        max-height: min(72vh, 520px);
        z-index: 2050;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    }
}
